From 44fb747a4a823da4bee604a8a0315fcaa305f9ae Mon Sep 17 00:00:00 2001 From: Avesh Agarwal Date: Thu, 3 Aug 2017 00:15:18 -0400 Subject: [PATCH] Update eviction util implementation. --- pkg/rescheduler/evictions/utils.go | 58 ------------------------------ 1 file changed, 58 deletions(-) delete mode 100644 pkg/rescheduler/evictions/utils.go diff --git a/pkg/rescheduler/evictions/utils.go b/pkg/rescheduler/evictions/utils.go deleted file mode 100644 index 738fd3f50..000000000 --- a/pkg/rescheduler/evictions/utils.go +++ /dev/null @@ -1,58 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package utils - -import ( - "k8s.io/kubernetes/pkg/client/clientset_generated/clientset" -) - -const ( - EvictionKind = "Eviction" - EvictionSubresource = "pods/eviction" -) - -// SupportEviction uses Discovery API to find out if the server support eviction subresource -// If support, it will return its groupVersion; Otherwise, it will return "" -func SupportEviction(clientset clientset.Interface) (string, error) { - discoveryClient := clientset.Discovery() - groupList, err := discoveryClient.ServerGroups() - if err != nil { - return "", err - } - foundPolicyGroup := false - var policyGroupVersion string - for _, group := range groupList.Groups { - if group.Name == "policy" { - foundPolicyGroup = true - policyGroupVersion = group.PreferredVersion.GroupVersion - break - } - } - if !foundPolicyGroup { - return "", nil - } - resourceList, err := discoveryClient.ServerResourcesForGroupVersion("v1") - if err != nil { - return "", err - } - for _, resource := range resourceList.APIResources { - if resource.Name == EvictionSubresource && resource.Kind == EvictionKind { - return policyGroupVersion, nil - } - } - return "", nil -}