Extract isNodeBeingDeleted function
This commit is contained in:
parent
1ca3f3673a
commit
519064e1ec
|
|
@ -133,8 +133,7 @@ func computeScaleDownResourcesLeftLimits(nodes []*apiv1.Node, resourceLimiter *c
|
||||||
func calculateCoresAndMemoryTotal(nodes []*apiv1.Node, timestamp time.Time) (int64, int64) {
|
func calculateCoresAndMemoryTotal(nodes []*apiv1.Node, timestamp time.Time) (int64, int64) {
|
||||||
var coresTotal, memoryTotal int64
|
var coresTotal, memoryTotal int64
|
||||||
for _, node := range nodes {
|
for _, node := range nodes {
|
||||||
deleteTime, _ := deletetaint.GetToBeDeletedTime(node)
|
if isNodeBeingDeleted(node, timestamp) {
|
||||||
if deleteTime != nil && (timestamp.Sub(*deleteTime) < MaxCloudProviderNodeDeletionTime || timestamp.Sub(*deleteTime) < MaxKubernetesEmptyNodeDeletionTime) {
|
|
||||||
// Nodes being deleted do not count towards total cluster resources
|
// Nodes being deleted do not count towards total cluster resources
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
@ -147,6 +146,11 @@ func calculateCoresAndMemoryTotal(nodes []*apiv1.Node, timestamp time.Time) (int
|
||||||
return coresTotal, memoryTotal
|
return coresTotal, memoryTotal
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isNodeBeingDeleted(node *apiv1.Node, timestamp time.Time) bool {
|
||||||
|
deleteTime, _ := deletetaint.GetToBeDeletedTime(node)
|
||||||
|
return deleteTime != nil && (timestamp.Sub(*deleteTime) < MaxCloudProviderNodeDeletionTime || timestamp.Sub(*deleteTime) < MaxKubernetesEmptyNodeDeletionTime)
|
||||||
|
}
|
||||||
|
|
||||||
func noLimitsOnResources() scaleDownResourcesLimits {
|
func noLimitsOnResources() scaleDownResourcesLimits {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
@ -293,8 +297,7 @@ func (sd *ScaleDown) UpdateUnneededNodes(
|
||||||
// Skip nodes marked to be deleted, if they were marked recently.
|
// Skip nodes marked to be deleted, if they were marked recently.
|
||||||
// Old-time marked nodes are again eligible for deletion - something went wrong with them
|
// Old-time marked nodes are again eligible for deletion - something went wrong with them
|
||||||
// and they have not been deleted.
|
// and they have not been deleted.
|
||||||
deleteTime, _ := deletetaint.GetToBeDeletedTime(node)
|
if isNodeBeingDeleted(node, timestamp) {
|
||||||
if deleteTime != nil && (timestamp.Sub(*deleteTime) < MaxCloudProviderNodeDeletionTime || timestamp.Sub(*deleteTime) < MaxKubernetesEmptyNodeDeletionTime) {
|
|
||||||
glog.V(1).Infof("Skipping %s from delete considerations - the node is currently being deleted", node.Name)
|
glog.V(1).Infof("Skipping %s from delete considerations - the node is currently being deleted", node.Name)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue