diff --git a/pkg/actuators/machine/actuator.go b/pkg/actuators/machine/actuator.go index d73d3b2ca1..40325467b5 100644 --- a/pkg/actuators/machine/actuator.go +++ b/pkg/actuators/machine/actuator.go @@ -18,7 +18,6 @@ package machine import ( "context" - "errors" "fmt" "time" @@ -257,13 +256,11 @@ func (gl *glogLogger) Logf(format string, v ...interface{}) { // DeleteMachine deletes an AWS instance func (a *Actuator) DeleteMachine(cluster *machinev1.Cluster, machine *machinev1.Machine) error { // Drain node before deleting - if _, exists := machine.ObjectMeta.Annotations[ExcludeNodeDrainingAnnotation]; !exists { - if machine.Status.NodeRef == nil { - // Draining a node of a machine without a node needs to be explicitely inspected - err := errors.New("draining node without a node reference during machine deletion operation is forbidden") - glog.Error(err) - return err - } + // If a machine is not linked to a node, just delete the machine. Since a node + // can be unlinked from a machine when the node goes NotReady and is removed + // by cloud controller manager. In that case some machines would never get + // deleted without a manual intervention. + if _, exists := machine.ObjectMeta.Annotations[ExcludeNodeDrainingAnnotation]; !exists && machine.Status.NodeRef != nil { glog.Infof("Draining node before delete") if a.config == nil { err := fmt.Errorf("missing client config, unable to build kube client")