You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: internal/controllers/machinedeployment/machinedeployment_rollout_planner_test.go
+73-41Lines changed: 73 additions & 41 deletions
Original file line number
Diff line number
Diff line change
@@ -21,6 +21,7 @@ import (
21
21
"fmt"
22
22
"math/rand"
23
23
"os"
24
+
"slices"
24
25
"sort"
25
26
"strconv"
26
27
"strings"
@@ -505,13 +506,13 @@ func machineSetControllerMutator(log *fileLogger, ms *clusterv1.MachineSet, scop
505
506
// TODO(in-place): when implementing in-place changes in the MachineSetController code make sure to:
506
507
// - detect if there are replicas still pending AcknowledgeMove first, including also handling cleanup of the pendingAcknowledgeMoveAnnotationName on machines
507
508
// - when deleting or moving
508
-
// - first move if possible, then delete
509
-
// - move machines should be capped to avoid unnecessary in-place upgrades (in case of scale down in the middle of rollouts); remaining part should be deleted
510
-
// - do not move machines pending a move Acknowledge, with an in-place upgrade in progress, deleted or marked for deletion, unhealthy
509
+
// - move or delete are mutually exclusive
510
+
// - do not move machines pending a move Acknowledge, with an in-place upgrade in progress, deleted or marked for deletion (TBD if to be remediated)
511
+
// - when deleting, machines updating in place should have higher priority than other machines (first get rid of not at the desired state/try to avoid unnecessary work; also those machines are unavailable).
511
512
512
513
// Sort machines to ensure stable results of move/delete operations during tests.
513
514
// TODO(in-place): this should not be implemented in production code for the MachineSet controller
// Removing updatingInPlaceAnnotation from machines after pendingAcknowledgeMove is gone in a previous reconcile (so inPlaceUpdating lasts one reconcile more)
517
518
// NOTE: This is a testing workaround to simulate inPlaceUpdating being completed; it is implemented in the fake MachineSet controller
@@ -620,27 +621,21 @@ func machineSetControllerMutator(log *fileLogger, ms *clusterv1.MachineSet, scop
620
621
returnerrors.Errorf("[MS controller] - PANIC! %s is set to send replicas to %s, which does not exists", ms.Name, targetMSName)
621
622
}
622
623
623
-
// Limit the number of machines to be moved to avoid to exceed the final number of replicas for the target MS.
624
-
// TODO(in-place): consider using the DesiredReplicasAnnotation which is propagated together with the other decisions of the rollout planner
625
-
// another option to consider is to shift this check on the newMS (so we perform move, but we don't start the in-place upgrade).
returnerrors.Errorf("[MS controller] - PANIC! %s is set to send replicas to %s, but %[2]s only accepts machines from %s", ms.Name, targetMS.Name, validSourceMSs)
637
629
}
638
630
631
+
// Always move all the machine that can be moved.
632
+
// In case the target machine set will end up with more machines than its target replica number, it will take care of this.
633
+
machinesToMove:=machinesToDeleteOrMove
639
634
machinesMoved:= []string{}
640
635
machinesSetMachines:= []*clusterv1.Machine{}
641
636
fori, m:=rangescope.machineSetMachines[ms.Name] {
642
-
// Make sure we are not moving machines still pending AcknowledgeMove
643
-
ifnotAcknowledgeMoveReplicas.Has(m.Name) {
637
+
// Make sure we are not moving machines still updating in place (this includes also machines still pending AcknowledgeMove).
638
+
if_, ok:=m.Annotations[clusterv1.UpdateInProgressAnnotation]; ok {
644
639
machinesSetMachines=append(machinesSetMachines, m)
645
640
continue
646
641
}
@@ -672,31 +667,39 @@ func machineSetControllerMutator(log *fileLogger, ms *clusterv1.MachineSet, scop
672
667
673
668
// Sort machines of the target MS to ensure consistent reporting during tests.
674
669
// Note: this is required because a machine can be moved to a target MachineSet that has been already reconciled before the source MachineSet (it won't sort machine by itself until the next reconcile).
// Note: machines updating in place must be deleted first.
1059
+
// in case of ties:
1060
+
// - if both machines are updating in place, delete first the machine with the highest machine NameIndex (e.g. between m3 and m4, pick m4, aka the last machine being moved)
1061
+
// - if both machines are not updating in place, delete first the machine with the lowest machine NameIndex (e.g. between m3 and m4, pick m3)
Copy file name to clipboardExpand all lines: internal/controllers/machinedeployment/testdata/rollingupdate/in-place rollout, 12 replicas, maxsurge 3, maxunavailable 1, scale down to 6, random(0).test.log.golden
Copy file name to clipboardExpand all lines: internal/controllers/machinedeployment/testdata/rollingupdate/in-place rollout, 12 replicas, maxsurge 3, maxunavailable 1, scale down to 6.test.log.golden
0 commit comments