Skip to content

Commit 7993d64

Browse files
adding support for force delete in azure
1 parent ea6e29e commit 7993d64

File tree

2 files changed

+13
-27
lines changed

2 files changed

+13
-27
lines changed

cluster-autoscaler/cloudprovider/azure/azure_agent_pool.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,11 @@ func (as *AgentPool) DeleteNodes(nodes []*apiv1.Node) error {
446446
return fmt.Errorf("min size reached, nodes will not be deleted")
447447
}
448448

449+
return as.ForceDeleteNodes(nodes)
450+
}
451+
452+
// ForceDeleteNodes deletes nodes from the group regardless of constraints.
453+
func (as *AgentPool) ForceDeleteNodes(nodes []*apiv1.Node) error {
449454
refs := make([]*azureRef, 0, len(nodes))
450455
for _, node := range nodes {
451456
belongs, err := as.Belongs(node)
@@ -463,19 +468,14 @@ func (as *AgentPool) DeleteNodes(nodes []*apiv1.Node) error {
463468
refs = append(refs, ref)
464469
}
465470

466-
err = as.deleteOutdatedDeployments()
471+
err := as.deleteOutdatedDeployments()
467472
if err != nil {
468-
klog.Warningf("DeleteNodes: failed to cleanup outdated deployments with err: %v.", err)
473+
klog.Warningf("ForceDeleteNodes: failed to cleanup outdated deployments with err: %v.", err)
469474
}
470475

471476
return as.DeleteInstances(refs)
472477
}
473478

474-
// ForceDeleteNodes deletes nodes from the group regardless of constraints.
475-
func (as *AgentPool) ForceDeleteNodes(nodes []*apiv1.Node) error {
476-
return cloudprovider.ErrNotImplemented
477-
}
478-
479479
// Debug returns a debug string for the agent pool.
480480
func (as *AgentPool) Debug() string {
481481
return fmt.Sprintf("%s (%d:%d)", as.Name, as.MinSize(), as.MaxSize())

cluster-autoscaler/cloudprovider/azure/azure_scale_set.go

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -598,12 +598,14 @@ func (scaleSet *ScaleSet) DeleteNodes(nodes []*apiv1.Node) error {
598598
if int(size) <= scaleSet.MinSize() {
599599
return fmt.Errorf("min size reached, nodes will not be deleted")
600600
}
601+
return scaleSet.ForceDeleteNodes(nodes)
602+
}
601603

602-
// Distinguish between unregistered node deletion and normal node deletion
604+
// ForceDeleteNodes deletes nodes from the group regardless of constraints.
605+
func (scaleSet *ScaleSet) ForceDeleteNodes(nodes []*apiv1.Node) error {
606+
klog.V(8).Infof("Delete nodes requested: %q\n", nodes)
603607
refs := make([]*azureRef, 0, len(nodes))
604608
hasUnregisteredNodes := false
605-
unregisteredRefs := make([]*azureRef, 0, len(nodes))
606-
607609
for _, node := range nodes {
608610
belongs, err := scaleSet.Belongs(node)
609611
if err != nil {
@@ -620,28 +622,12 @@ func (scaleSet *ScaleSet) DeleteNodes(nodes []*apiv1.Node) error {
620622
ref := &azureRef{
621623
Name: node.Spec.ProviderID,
622624
}
623-
624-
if node.Annotations[cloudprovider.FakeNodeReasonAnnotation] == cloudprovider.FakeNodeUnregistered {
625-
klog.V(5).Infof("Node: %s type is unregistered..Appending to the unregistered list", node.Name)
626-
unregisteredRefs = append(unregisteredRefs, ref)
627-
} else {
628-
refs = append(refs, ref)
629-
}
630-
}
631-
632-
if len(unregisteredRefs) > 0 {
633-
klog.V(3).Infof("Removing unregisteredNodes: %v", unregisteredRefs)
634-
return scaleSet.DeleteInstances(unregisteredRefs, true)
625+
refs = append(refs, ref)
635626
}
636627

637628
return scaleSet.DeleteInstances(refs, hasUnregisteredNodes)
638629
}
639630

640-
// ForceDeleteNodes deletes nodes from the group regardless of constraints.
641-
func (scaleSet *ScaleSet) ForceDeleteNodes(nodes []*apiv1.Node) error {
642-
return cloudprovider.ErrNotImplemented
643-
}
644-
645631
// Id returns ScaleSet id.
646632
func (scaleSet *ScaleSet) Id() string {
647633
return scaleSet.Name

0 commit comments

Comments
 (0)