From bfdc22a0f3d30eb85b0f0ad4d2f748a7ca64c0d0 Mon Sep 17 00:00:00 2001 From: Kenny Leung Date: Fri, 15 Jun 2018 10:55:29 -0700 Subject: [PATCH] Change the reconcile logic to include machines being deleted (#342) This changes the logic from not counting machines that are being deleted towards the machineset replica to counting them. The reason for the change is that due to machine deletion taking non-trivial amount of time, machine deployment rolling update may exceed the expected number of machines utilized. For example, for a machine set with 3 replicas and max surge 1, for a max of 4 machines. - create new machine in new machineset (4 machines) - once new machine is ready, delete a machine from old machineset (4 machines, as machine is still being deleted) - create new machine as deleted machine is not counted (5 machines) For the duration of the old machine being deleted, we would exceed the number of machines by 1. --- pkg/controller/machineset/controller.go | 5 ----- pkg/controller/machineset/reconcile_test.go | 5 ++--- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/pkg/controller/machineset/controller.go b/pkg/controller/machineset/controller.go index 03910d5c907e..b61c13527f20 100644 --- a/pkg/controller/machineset/controller.go +++ b/pkg/controller/machineset/controller.go @@ -257,11 +257,6 @@ func (c *MachineSetControllerImpl) createMachine(machineSet *v1alpha1.MachineSet // shoudExcludeMachine returns true if the machine should be filtered out, false otherwise. func shouldExcludeMachine(machineSet *v1alpha1.MachineSet, machine *v1alpha1.Machine) bool { // Ignore inactive machines. - if machine.DeletionTimestamp != nil || !machine.DeletionTimestamp.IsZero() { - glog.V(4).Infof("Skipping machine (%v), as it is being deleted.", machine.Name) - return true - } - if metav1.GetControllerOf(machine) != nil && !metav1.IsControlledBy(machine, machineSet) { glog.V(4).Infof("%s not controlled by %v", machine.Name, machineSet.Name) return true diff --git a/pkg/controller/machineset/reconcile_test.go b/pkg/controller/machineset/reconcile_test.go index fb5e46fbf5bb..dadfebd1d538 100644 --- a/pkg/controller/machineset/reconcile_test.go +++ b/pkg/controller/machineset/reconcile_test.go @@ -165,13 +165,12 @@ func TestMachineSetControllerReconcileHandler(t *testing.T) { expectedMachine: machineFromMachineSet(createMachineSet(1, "foo", "bar2", "acme"), "bar2"), }, { - name: "scenario 9: the current machine is being deleted, thus a machine is created.", + name: "scenario 9: the current machine is being deleted, is still counted towards the machine set, no machine resource is created.", startingMachineSets: []*v1alpha1.MachineSet{createMachineSet(1, "foo", "bar2", "acme")}, startingMachines: []*v1alpha1.Machine{setMachineDeleting(machineFromMachineSet(createMachineSet(1, "foo", "bar1", "acme"), "bar1"))}, machineSetToSync: "foo", namespaceToSync: "acme", - expectedActions: []string{"create"}, - expectedMachine: machineFromMachineSet(createMachineSet(1, "foo", "bar2", "acme"), "bar2"), + expectedActions: []string{}, }, { name: "scenario 10: the current machine has no controller refs, owner refs preserved, machine should be adopted.",