Skip to content

Commit

Permalink
Bugfix: Drain machines with only a valid NodeName
Browse files Browse the repository at this point in the history
  • Loading branch information
prashanth26 committed Jun 26, 2020
1 parent fba8a1b commit 2da2e4f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/controller/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,9 @@ func (c *controller) machineDelete(machine *v1alpha1.Machine, driver driver.Driv
}
}

if machineID != "" {
if machineID != "" && nodeName != "" {
// Begin drain logic only when the nodeName & providerID exist's for the machine

var (
forceDeletePods = false
forceDeleteMachine = false
Expand Down
36 changes: 36 additions & 0 deletions pkg/controller/machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1387,6 +1387,42 @@ var _ = Describe("machine", func() {
machineDeleted: false,
},
}),
Entry("Allow machine object deletion where nodeName doesn't exist", &data{
setup: setup{
secrets: []*corev1.Secret{
{
ObjectMeta: *newObjectMeta(objMeta, 0),
},
},
aws: []*machinev1.AWSMachineClass{
{
ObjectMeta: *newObjectMeta(objMeta, 0),
Spec: machinev1.AWSMachineClassSpec{
SecretRef: newSecretReference(objMeta, 0),
},
},
},
machines: newMachines(1, &machinev1.MachineTemplateSpec{
ObjectMeta: *newObjectMeta(objMeta, 0),
Spec: machinev1.MachineSpec{
Class: machinev1.ClassSpec{
Kind: "AWSMachineClass",
Name: "machine-0",
},
},
}, nil, nil, nil, nil),
},
action: action{
machine: "machine-0",
fakeProviderID: "fakeID-0",
fakeNodeName: "", //NodeName is set to emptyString
fakeError: nil,
},
expect: expect{
errOccurred: true,
machineDeleted: true,
},
}),
)
})

Expand Down

0 comments on commit 2da2e4f

Please sign in to comment.