From d1e0b5efa6a6fa783d9ca615700bd6a22c9441bc Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Fri, 5 Oct 2018 11:06:03 -0700 Subject: [PATCH] Remove BalanceAttachedNodeVolumes --- pkg/features/kube_features.go | 9 ----- .../algorithm/predicates/predicates.go | 6 ---- .../balanced_resource_allocation.go | 16 --------- .../priorities/resource_allocation.go | 33 +++++-------------- pkg/scheduler/internal/cache/cache.go | 9 +---- pkg/scheduler/nodeinfo/node_info.go | 9 ----- 6 files changed, 9 insertions(+), 73 deletions(-) diff --git a/pkg/features/kube_features.go b/pkg/features/kube_features.go index a369986b67..3ec326dee8 100644 --- a/pkg/features/kube_features.go +++ b/pkg/features/kube_features.go @@ -249,14 +249,6 @@ const ( // volume limits AttachVolumeLimit utilfeature.Feature = "AttachVolumeLimit" - // owner: @ravig - // alpha: v1.11 - // - // Include volume count on node to be considered for balanced resource allocation while scheduling. - // A node which has closer cpu,memory utilization and volume count is favoured by scheduler - // while making decisions. - BalanceAttachedNodeVolumes utilfeature.Feature = "BalanceAttachedNodeVolumes" - // owner @freehan // GA: v1.14 // @@ -426,7 +418,6 @@ var defaultKubernetesFeatureGates = map[utilfeature.Feature]utilfeature.FeatureS RunAsGroup: {Default: true, PreRelease: utilfeature.Beta}, CSIMigrationOpenStack: {Default: false, PreRelease: utilfeature.Alpha}, VolumeSubpath: {Default: true, PreRelease: utilfeature.GA}, - BalanceAttachedNodeVolumes: {Default: false, PreRelease: utilfeature.Alpha}, PodReadinessGates: {Default: true, PreRelease: utilfeature.GA, LockToDefault: true}, // remove in 1.16 VolumeSubpathEnvExpansion: {Default: false, PreRelease: utilfeature.Alpha}, KubeletPluginsWatcher: {Default: true, PreRelease: utilfeature.GA, LockToDefault: true}, // remove in 1.16 diff --git a/pkg/scheduler/algorithm/predicates/predicates.go b/pkg/scheduler/algorithm/predicates/predicates.go index 86d9c059db..308790c47a 100644 --- a/pkg/scheduler/algorithm/predicates/predicates.go +++ b/pkg/scheduler/algorithm/predicates/predicates.go @@ -519,12 +519,6 @@ func (c *MaxPDVolumeCountChecker) predicate(pod *v1.Pod, meta PredicateMetadata, // violates MaxEBSVolumeCount or MaxGCEPDVolumeCount return false, []PredicateFailureReason{ErrMaxVolumeCountExceeded}, nil } - if nodeInfo != nil && nodeInfo.TransientInfo != nil && utilfeature.DefaultFeatureGate.Enabled(features.BalanceAttachedNodeVolumes) { - nodeInfo.TransientInfo.TransientLock.Lock() - defer nodeInfo.TransientInfo.TransientLock.Unlock() - nodeInfo.TransientInfo.TransNodeInfo.AllocatableVolumesCount = maxAttachLimit - numExistingVolumes - nodeInfo.TransientInfo.TransNodeInfo.RequestedVolumes = numNewVolumes - } return true, nil, nil } diff --git a/pkg/scheduler/algorithm/priorities/balanced_resource_allocation.go b/pkg/scheduler/algorithm/priorities/balanced_resource_allocation.go index 97635cdddd..bf812e0cc0 100644 --- a/pkg/scheduler/algorithm/priorities/balanced_resource_allocation.go +++ b/pkg/scheduler/algorithm/priorities/balanced_resource_allocation.go @@ -19,8 +19,6 @@ package priorities import ( "math" - utilfeature "k8s.io/apiserver/pkg/util/feature" - "k8s.io/kubernetes/pkg/features" schedulerapi "k8s.io/kubernetes/pkg/scheduler/api" schedulernodeinfo "k8s.io/kubernetes/pkg/scheduler/nodeinfo" ) @@ -42,20 +40,6 @@ func balancedResourceScorer(requested, allocable *schedulernodeinfo.Resource, in cpuFraction := fractionOfCapacity(requested.MilliCPU, allocable.MilliCPU) memoryFraction := fractionOfCapacity(requested.Memory, allocable.Memory) // This to find a node which has most balanced CPU, memory and volume usage. - if includeVolumes && utilfeature.DefaultFeatureGate.Enabled(features.BalanceAttachedNodeVolumes) && allocatableVolumes > 0 { - volumeFraction := float64(requestedVolumes) / float64(allocatableVolumes) - if cpuFraction >= 1 || memoryFraction >= 1 || volumeFraction >= 1 { - // if requested >= capacity, the corresponding host should never be preferred. - return 0 - } - // Compute variance for all the three fractions. - mean := (cpuFraction + memoryFraction + volumeFraction) / float64(3) - variance := float64((((cpuFraction - mean) * (cpuFraction - mean)) + ((memoryFraction - mean) * (memoryFraction - mean)) + ((volumeFraction - mean) * (volumeFraction - mean))) / float64(3)) - // Since the variance is between positive fractions, it will be positive fraction. 1-variance lets the - // score to be higher for node which has least variance and multiplying it with 10 provides the scaling - // factor needed. - return int64((1 - variance) * float64(schedulerapi.MaxPriority)) - } if cpuFraction >= 1 || memoryFraction >= 1 { // if requested >= capacity, the corresponding host should never be preferred. diff --git a/pkg/scheduler/algorithm/priorities/resource_allocation.go b/pkg/scheduler/algorithm/priorities/resource_allocation.go index fea2e68069..3d3acb017a 100644 --- a/pkg/scheduler/algorithm/priorities/resource_allocation.go +++ b/pkg/scheduler/algorithm/priorities/resource_allocation.go @@ -20,9 +20,7 @@ import ( "fmt" "k8s.io/api/core/v1" - utilfeature "k8s.io/apiserver/pkg/util/feature" "k8s.io/klog" - "k8s.io/kubernetes/pkg/features" priorityutil "k8s.io/kubernetes/pkg/scheduler/algorithm/priorities/util" schedulerapi "k8s.io/kubernetes/pkg/scheduler/api" schedulernodeinfo "k8s.io/kubernetes/pkg/scheduler/nodeinfo" @@ -58,31 +56,16 @@ func (r *ResourceAllocationPriority) PriorityMap( requested.Memory += nodeInfo.NonZeroRequest().Memory var score int64 // Check if the pod has volumes and this could be added to scorer function for balanced resource allocation. - if len(pod.Spec.Volumes) >= 0 && utilfeature.DefaultFeatureGate.Enabled(features.BalanceAttachedNodeVolumes) && nodeInfo.TransientInfo != nil { - score = r.scorer(&requested, &allocatable, true, nodeInfo.TransientInfo.TransNodeInfo.RequestedVolumes, nodeInfo.TransientInfo.TransNodeInfo.AllocatableVolumesCount) - } else { - score = r.scorer(&requested, &allocatable, false, 0, 0) - } + score = r.scorer(&requested, &allocatable, false, 0, 0) if klog.V(10) { - if len(pod.Spec.Volumes) >= 0 && utilfeature.DefaultFeatureGate.Enabled(features.BalanceAttachedNodeVolumes) && nodeInfo.TransientInfo != nil { - klog.Infof( - "%v -> %v: %v, capacity %d millicores %d memory bytes, %d volumes, total request %d millicores %d memory bytes %d volumes, score %d", - pod.Name, node.Name, r.Name, - allocatable.MilliCPU, allocatable.Memory, nodeInfo.TransientInfo.TransNodeInfo.AllocatableVolumesCount, - requested.MilliCPU, requested.Memory, - nodeInfo.TransientInfo.TransNodeInfo.RequestedVolumes, - score, - ) - } else { - klog.Infof( - "%v -> %v: %v, capacity %d millicores %d memory bytes, total request %d millicores %d memory bytes, score %d", - pod.Name, node.Name, r.Name, - allocatable.MilliCPU, allocatable.Memory, - requested.MilliCPU, requested.Memory, - score, - ) - } + klog.Infof( + "%v -> %v: %v, capacity %d millicores %d memory bytes, total request %d millicores %d memory bytes, score %d", + pod.Name, node.Name, r.Name, + allocatable.MilliCPU, allocatable.Memory, + requested.MilliCPU, requested.Memory, + score, + ) } return schedulerapi.HostPriority{ diff --git a/pkg/scheduler/internal/cache/cache.go b/pkg/scheduler/internal/cache/cache.go index 790a3bcc6e..4a91d83e77 100644 --- a/pkg/scheduler/internal/cache/cache.go +++ b/pkg/scheduler/internal/cache/cache.go @@ -21,12 +21,10 @@ import ( "sync" "time" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/wait" - utilfeature "k8s.io/apiserver/pkg/util/feature" - "k8s.io/kubernetes/pkg/features" "k8s.io/kubernetes/pkg/scheduler/algorithm" schedulernodeinfo "k8s.io/kubernetes/pkg/scheduler/nodeinfo" @@ -210,7 +208,6 @@ func (cache *schedulerCache) Snapshot() *Snapshot { func (cache *schedulerCache) UpdateNodeInfoSnapshot(nodeSnapshot *NodeInfoSnapshot) error { cache.mu.Lock() defer cache.mu.Unlock() - balancedVolumesEnabled := utilfeature.DefaultFeatureGate.Enabled(features.BalanceAttachedNodeVolumes) // Get the last generation of the the snapshot. snapshotGeneration := nodeSnapshot.Generation @@ -222,10 +219,6 @@ func (cache *schedulerCache) UpdateNodeInfoSnapshot(nodeSnapshot *NodeInfoSnapsh // all the nodes are updated before the existing snapshot. We are done. break } - if balancedVolumesEnabled && node.info.TransientInfo != nil { - // Transient scheduler info is reset here. - node.info.TransientInfo.ResetTransientSchedulerInfo() - } if np := node.info.Node(); np != nil { nodeSnapshot.NodeInfoMap[np.Name] = node.info.Clone() } diff --git a/pkg/scheduler/nodeinfo/node_info.go b/pkg/scheduler/nodeinfo/node_info.go index 6a6703a4fa..df188e857a 100644 --- a/pkg/scheduler/nodeinfo/node_info.go +++ b/pkg/scheduler/nodeinfo/node_info.go @@ -126,15 +126,6 @@ func NewTransientSchedulerInfo() *TransientSchedulerInfo { return tsi } -// ResetTransientSchedulerInfo resets the TransientSchedulerInfo. -func (transientSchedInfo *TransientSchedulerInfo) ResetTransientSchedulerInfo() { - transientSchedInfo.TransientLock.Lock() - defer transientSchedInfo.TransientLock.Unlock() - // Reset TransientNodeInfo. - transientSchedInfo.TransNodeInfo.AllocatableVolumesCount = 0 - transientSchedInfo.TransNodeInfo.RequestedVolumes = 0 -} - // Resource is a collection of compute resource. type Resource struct { MilliCPU int64