Skip to content

Commit 5528b1a

Browse files
authored
Merge pull request #12261 from sm4ll-3gg/fix-second-rollout-for-md-rollout-after
🐛 Fix second rolling update for MD rolloutAfter
2 parents aa41297 + ffd649b commit 5528b1a

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

internal/controllers/machinedeployment/mdutil/util.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,9 +504,9 @@ func FindNewMachineSet(deployment *clusterv1.MachineDeployment, msList []*cluste
504504
return matchingMachineSets[0], "", nil
505505
}
506506

507-
// Pick the first matching MachineSet that has been created after RolloutAfter.
507+
// Pick the first matching MachineSet that has been created at RolloutAfter or later.
508508
for _, ms := range matchingMachineSets {
509-
if ms.CreationTimestamp.After(deployment.Spec.RolloutAfter.Time) {
509+
if ms.CreationTimestamp.Sub(deployment.Spec.RolloutAfter.Time) >= 0 {
510510
return ms, "", nil
511511
}
512512
}

internal/controllers/machinedeployment/mdutil/util_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,9 @@ func TestFindNewMachineSet(t *testing.T) {
423423
msCreatedAfterRolloutAfter := generateMS(deployment)
424424
msCreatedAfterRolloutAfter.CreationTimestamp = oneAfterRolloutAfter
425425

426+
msCreatedExactlyInRolloutAfter := generateMS(deployment)
427+
msCreatedExactlyInRolloutAfter.CreationTimestamp = rolloutAfter
428+
426429
tests := []struct {
427430
Name string
428431
deployment clusterv1.MachineDeployment
@@ -485,6 +488,14 @@ func TestFindNewMachineSet(t *testing.T) {
485488
reconciliationTime: &twoAfterRolloutAfter,
486489
expected: &msCreatedAfterRolloutAfter,
487490
},
491+
{
492+
// https://github.com/kubernetes-sigs/cluster-api/issues/12260
493+
Name: "Get MachineSet created exactly in RolloutAfter if reconciliationTime > rolloutAfter",
494+
deployment: *deploymentWithRolloutAfter,
495+
msList: []*clusterv1.MachineSet{&msCreatedExactlyInRolloutAfter, &msCreatedTwoBeforeRolloutAfter},
496+
reconciliationTime: &oneAfterRolloutAfter,
497+
expected: &msCreatedExactlyInRolloutAfter,
498+
},
488499
{
489500
Name: "Get MachineSet created after RolloutAfter if reconciliationTime is > rolloutAfter (inverse order in ms list)",
490501
deployment: *deploymentWithRolloutAfter,

0 commit comments

Comments
 (0)