Skip to content

Commit 0a0e997

Browse files
More comments
1 parent e1cdf66 commit 0a0e997

8 files changed

+22
-22
lines changed

internal/controllers/machinedeployment/machinedeployment_rollout_planner_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ func machineSetControllerMutator(log *fileLogger, ms *clusterv1.MachineSet, scop
668668
machinesMoved = append(machinesMoved, m.Name)
669669
}
670670
scope.machineSetMachines[ms.Name] = machinesSetMachines
671-
log.Logf("[MS controller] - %s scale down to %d/%[2]d replicas (%s moved to %s)", ms.Name, ptr.Deref(ms.Spec.Replicas, 0), strings.Join(machinesMoved, ","), targetMS.Name)
671+
log.Logf("[MS controller] - %s scale down to %d/%d replicas (%s moved to %s)", ms.Name, len(scope.machineSetMachines[ms.Name]), ptr.Deref(ms.Spec.Replicas, 0), strings.Join(machinesMoved, ","), targetMS.Name)
672672

673673
// Sort machines of the target MS to ensure consistent reporting during tests.
674674
// 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).

internal/controllers/machinedeployment/machinedeployment_rollout_rollingupdate_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ func TestReconcileInPlaceUpdateIntent(t *testing.T) {
711711

712712
{
713713
name: "Move replicas from oldMS to newMS",
714-
md: createMD("v1", 2),
714+
md: createMD("v2", 2),
715715
newMS: createMS("ms2", "v2", 1),
716716
oldMS: []*clusterv1.MachineSet{
717717
createMS("ms1", "v1", 1),
@@ -757,7 +757,7 @@ func TestReconcileInPlaceUpdateIntent(t *testing.T) {
757757
},
758758
{
759759
name: "Do not move replicas from oldMS to newMS when oldMS doesn't have replicas anymore",
760-
md: createMD("v1", 1),
760+
md: createMD("v2", 3),
761761
newMS: createMS("ms2", "v2", 1),
762762
oldMS: []*clusterv1.MachineSet{
763763
createMS("ms1", "v1", 0),
@@ -776,7 +776,7 @@ func TestReconcileInPlaceUpdateIntent(t *testing.T) {
776776
},
777777
{
778778
name: "Do not move replicas from oldMS to newMS when the system does not know if oldMS is eligible for in-place update", // Note: this should never happen, defensive programming.
779-
md: createMD("v1", 2),
779+
md: createMD("v2", 2),
780780
newMS: createMS("ms2", "v2", 1),
781781
oldMS: []*clusterv1.MachineSet{
782782
createMS("ms1", "v1", 1),
@@ -794,7 +794,7 @@ func TestReconcileInPlaceUpdateIntent(t *testing.T) {
794794
},
795795
{
796796
name: "Do not move replicas from oldMS to newMS when oldMS is not eligible for in-place update",
797-
md: createMD("v1", 2),
797+
md: createMD("v2", 2),
798798
newMS: createMS("ms2", "v2", 1),
799799
oldMS: []*clusterv1.MachineSet{
800800
createMS("ms1", "v1", 1),
@@ -814,7 +814,7 @@ func TestReconcileInPlaceUpdateIntent(t *testing.T) {
814814
},
815815
{
816816
name: "Do not move replicas from oldMS to newMS when canUpdateDecision for the oldMS is false",
817-
md: createMD("v1", 2),
817+
md: createMD("v2", 2),
818818
newMS: createMS("ms2", "v2", 1),
819819
oldMS: []*clusterv1.MachineSet{
820820
createMS("ms1", "v1", 1),
@@ -838,7 +838,7 @@ func TestReconcileInPlaceUpdateIntent(t *testing.T) {
838838
},
839839
{
840840
name: "Multiple oldMSs, mixed use cases",
841-
md: createMD("v1", 5),
841+
md: createMD("v6", 6),
842842
newMS: createMS("ms6", "v6", 1),
843843
oldMS: []*clusterv1.MachineSet{
844844
createMS("ms1", "v1", 1), // eligible for in-place, canUpdateDecision true
@@ -880,7 +880,7 @@ func TestReconcileInPlaceUpdateIntent(t *testing.T) {
880880

881881
{
882882
name: "When moving replicas from oldMS to newMS, preserve newMS scale up intent if it does not use maxSurge",
883-
md: createMD("v1", 3, withRollingUpdateStrategy(1, 0)),
883+
md: createMD("v2", 3, withRollingUpdateStrategy(1, 0)),
884884
newMS: createMS("ms2", "v2", 1),
885885
oldMS: []*clusterv1.MachineSet{
886886
createMS("ms1", "v1", 1),
@@ -908,7 +908,7 @@ func TestReconcileInPlaceUpdateIntent(t *testing.T) {
908908
},
909909
{
910910
name: "When moving replicas from oldMS to newMS, preserve one usage of MaxSurge in the newMS scale up intent when required to start the rollout (maxSurge 1, maxUnavailable 0)",
911-
md: createMD("v1", 3, withRollingUpdateStrategy(1, 0)),
911+
md: createMD("v2", 3, withRollingUpdateStrategy(1, 0)),
912912
newMS: createMS("ms2", "v2", 0),
913913
oldMS: []*clusterv1.MachineSet{
914914
createMS("ms1", "v1", 3),
@@ -938,7 +938,7 @@ func TestReconcileInPlaceUpdateIntent(t *testing.T) {
938938
},
939939
{
940940
name: "When moving replicas from oldMS to newMS, preserve one usage of MaxSurge in the newMS scale up intent when required to start the rollout (maxSurge 3, maxUnavailable 0)",
941-
md: createMD("v1", 3, withRollingUpdateStrategy(3, 0)),
941+
md: createMD("v2", 3, withRollingUpdateStrategy(3, 0)),
942942
newMS: createMS("ms2", "v2", 0),
943943
oldMS: []*clusterv1.MachineSet{
944944
createMS("ms1", "v1", 3),
@@ -968,7 +968,7 @@ func TestReconcileInPlaceUpdateIntent(t *testing.T) {
968968
},
969969
{
970970
name: "When moving replicas from oldMS to newMS, drop usage of MaxSurge in the newMS scale up intent when there are oldMS with scale down intent (maxSurge 3, maxUnavailable 1)",
971-
md: createMD("v1", 3, withRollingUpdateStrategy(3, 1)),
971+
md: createMD("v2", 3, withRollingUpdateStrategy(3, 1)),
972972
newMS: createMS("ms2", "v2", 0),
973973
oldMS: []*clusterv1.MachineSet{
974974
createMS("ms1", "v1", 3),
@@ -999,7 +999,7 @@ func TestReconcileInPlaceUpdateIntent(t *testing.T) {
999999
},
10001000
{
10011001
name: "When moving replicas from oldMS to newMS, drop usage of MaxSurge in the newMS scale up intent when there are oldMS with scale down from a previous reconcile (maxSurge 3, maxUnavailable 1)",
1002-
md: createMD("v1", 3, withRollingUpdateStrategy(3, 1)),
1002+
md: createMD("v2", 3, withRollingUpdateStrategy(3, 1)),
10031003
newMS: createMS("ms2", "v2", 0),
10041004
oldMS: []*clusterv1.MachineSet{
10051005
createMS("ms1", "v1", 3, withStatusReplicas(4)), // scale down from a previous reconcile
@@ -1029,7 +1029,7 @@ func TestReconcileInPlaceUpdateIntent(t *testing.T) {
10291029
},
10301030
{
10311031
name: "When moving replicas from oldMS to newMS, drop usage of MaxSurge in the newMS scale up intent when there machines in-place updating (maxSurge 3, maxUnavailable 0)",
1032-
md: createMD("v1", 3, withRollingUpdateStrategy(3, 0)),
1032+
md: createMD("v2", 3, withRollingUpdateStrategy(3, 0)),
10331033
newMS: createMS("ms2", "v2", 0),
10341034
oldMS: []*clusterv1.MachineSet{
10351035
createMS("ms1", "v1", 3),
@@ -1058,7 +1058,7 @@ func TestReconcileInPlaceUpdateIntent(t *testing.T) {
10581058
},
10591059
{
10601060
name: "When moving replicas from oldMS to newMS, drop usage of MaxSurge in the newMS scale up intent when there newMS is scaling from a previous reconcile (maxSurge 3, maxUnavailable 1)",
1061-
md: createMD("v1", 6, withRollingUpdateStrategy(3, 1)),
1061+
md: createMD("v6", 6, withRollingUpdateStrategy(3, 1)),
10621062
newMS: createMS("ms2", "v2", 3, withStatusReplicas(2)), // scaling from a previous reconcile
10631063
oldMS: []*clusterv1.MachineSet{
10641064
createMS("ms1", "v1", 3),

internal/controllers/machinedeployment/testdata/rollingupdate/in-place rollout, 12 replicas, maxsurge 3, maxunavailable 1, scale down to 6, random(0).test.log.golden

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
[Toleration] tolerate maxSurge breach
2020
[MS controller] Iteration 2, Reconcile ms1, 9/2 replicas (m4,m5,m6,m7,m8,m9,m10,m11,m12 => ms2)
2121
[MS controller] - Move capped to 3 replicas to avoid unnecessary in-place upgrades
22-
[MS controller] - ms1 scale down to 2/2 replicas (m4,m5,m6 moved to ms2)
22+
[MS controller] - ms1 scale down to 6/2 replicas (m4,m5,m6 moved to ms2)
2323
[MS controller] - ms1 scale down to 2/2 replicas (m7,m8,m9,m10 deleted)
2424
[MS controller] Iteration 2, Reconcile ms1, 2/2 replicas (m11,m12 => ms2)
2525
[MD controller] Iteration 3, Reconcile md
@@ -76,7 +76,7 @@
7676
- ms2, 6/6 replicas (m1,m2,m3,m4,m5,m6 <= ms1)
7777
[MS controller] Iteration 8, Reconcile ms1, 2/0 replicas (m11,m12 => ms2)
7878
[MS controller] - Move capped to 0 replicas to avoid unnecessary in-place upgrades
79-
[MS controller] - ms1 scale down to 0/0 replicas ( moved to ms2)
79+
[MS controller] - ms1 scale down to 2/0 replicas ( moved to ms2)
8080
[MS controller] - ms1 scale down to 0/0 replicas (m11,m12 deleted)
8181
[MS controller] Iteration 9, Reconcile ms2, 6/6 replicas (m1,m2,m3,m4,m5,m6 <= ms1)
8282
[MS controller] Iteration 9, Reconcile ms1, 0/0 replicas ( => ms2)

internal/controllers/machinedeployment/testdata/rollingupdate/in-place rollout, 12 replicas, maxsurge 3, maxunavailable 1, scale down to 6.test.log.golden

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
[Toleration] tolerate maxSurge breach
1818
[MS controller] Iteration 1, Reconcile ms1, 9/2 replicas (m4,m5,m6,m7,m8,m9,m10,m11,m12 => ms2)
1919
[MS controller] - Move capped to 3 replicas to avoid unnecessary in-place upgrades
20-
[MS controller] - ms1 scale down to 2/2 replicas (m4,m5,m6 moved to ms2)
20+
[MS controller] - ms1 scale down to 6/2 replicas (m4,m5,m6 moved to ms2)
2121
[MS controller] - ms1 scale down to 2/2 replicas (m7,m8,m9,m10 deleted)
2222
[MS controller] Iteration 1, Reconcile ms2, 3/3 replicas (m1,m2,m3,m4🟠🟡,m5🟠🟡,m6🟠🟡 <= ms1)
2323
[MS controller] - Replicas m4,m5,m6 moved from an old MachineSet still pending acknowledge from machine deployment md
@@ -55,7 +55,7 @@
5555
- ms2, 6/6 replicas (m1,m2,m3,m4,m5,m6 <= ms1)
5656
[MS controller] Iteration 4, Reconcile ms1, 2/0 replicas (m11,m12 => ms2)
5757
[MS controller] - Move capped to 0 replicas to avoid unnecessary in-place upgrades
58-
[MS controller] - ms1 scale down to 0/0 replicas ( moved to ms2)
58+
[MS controller] - ms1 scale down to 2/0 replicas ( moved to ms2)
5959
[MS controller] - ms1 scale down to 0/0 replicas (m11,m12 deleted)
6060
[MS controller] Iteration 4, Reconcile ms2, 6/6 replicas (m1,m2,m3,m4,m5,m6 <= ms1)
6161
[MD controller] Iteration 5, Reconcile md

internal/controllers/machinedeployment/testdata/rollingupdate/in-place rollout, 3 replicas, maxsurge 1, maxunavailable 0, random(0).test.log.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
[MS controller] Iteration 16, Reconcile ms2, 3/3 replicas (m1,m2,m4 <= ms1)
130130
[MS controller] Iteration 16, Reconcile ms1, 1/0 replicas (m3 => ms2)
131131
[MS controller] - Move capped to 0 replicas to avoid unnecessary in-place upgrades
132-
[MS controller] - ms1 scale down to 0/0 replicas ( moved to ms2)
132+
[MS controller] - ms1 scale down to 1/0 replicas ( moved to ms2)
133133
[MS controller] - ms1 scale down to 0/0 replicas (m3 deleted)
134134
[MD controller] Iteration 16, Reconcile md
135135
[MD controller] - Input to rollout planner

internal/controllers/machinedeployment/testdata/rollingupdate/in-place rollout, 3 replicas, maxsurge 1, maxunavailable 0.test.log.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
- ms2, 3/3 replicas (m1,m2,m4 <= ms1)
9999
[MS controller] Iteration 8, Reconcile ms1, 1/0 replicas (m3 => ms2)
100100
[MS controller] - Move capped to 0 replicas to avoid unnecessary in-place upgrades
101-
[MS controller] - ms1 scale down to 0/0 replicas ( moved to ms2)
101+
[MS controller] - ms1 scale down to 1/0 replicas ( moved to ms2)
102102
[MS controller] - ms1 scale down to 0/0 replicas (m3 deleted)
103103
[MS controller] Iteration 8, Reconcile ms2, 3/3 replicas (m1,m2,m4 <= ms1)
104104
[MD controller] Iteration 9, Reconcile md

internal/controllers/machinedeployment/testdata/rollingupdate/in-place rollout, 6 replicas, maxsurge 10, maxunavailable 0, random(0).test.log.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@
247247
- ms2, 6/6 replicas (m1,m2,m3,m4,m5,m7 <= ms1)
248248
[MS controller] Iteration 27, Reconcile ms1, 1/0 replicas (m6 => ms2)
249249
[MS controller] - Move capped to 0 replicas to avoid unnecessary in-place upgrades
250-
[MS controller] - ms1 scale down to 0/0 replicas ( moved to ms2)
250+
[MS controller] - ms1 scale down to 1/0 replicas ( moved to ms2)
251251
[MS controller] - ms1 scale down to 0/0 replicas (m6 deleted)
252252
[MS controller] Iteration 27, Reconcile ms2, 6/6 replicas (m1,m2,m3,m4,m5,m7 <= ms1)
253253
[MD controller] Iteration 27, Reconcile md

internal/controllers/machinedeployment/testdata/rollingupdate/in-place rollout, 6 replicas, maxsurge 10, maxunavailable 0.test.log.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@
206206
- ms2, 6/6 replicas (m1,m2,m3,m4,m5,m7 <= ms1)
207207
[MS controller] Iteration 17, Reconcile ms1, 1/0 replicas (m6 => ms2)
208208
[MS controller] - Move capped to 0 replicas to avoid unnecessary in-place upgrades
209-
[MS controller] - ms1 scale down to 0/0 replicas ( moved to ms2)
209+
[MS controller] - ms1 scale down to 1/0 replicas ( moved to ms2)
210210
[MS controller] - ms1 scale down to 0/0 replicas (m6 deleted)
211211
[MS controller] Iteration 17, Reconcile ms2, 6/6 replicas (m1,m2,m3,m4,m5,m7 <= ms1)
212212
[MD controller] Iteration 18, Reconcile md

0 commit comments

Comments
 (0)