Skip to content

Commit ffd649b

Browse files
committed
Fix second rolling update for MD rolloutAfter
1 parent a8e4187 commit ffd649b

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
@@ -499,9 +499,9 @@ func FindNewMachineSet(deployment *clusterv1.MachineDeployment, msList []*cluste
499499
return matchingMachineSets[0], "", nil
500500
}
501501

502-
// Pick the first matching MachineSet that has been created after RolloutAfter.
502+
// Pick the first matching MachineSet that has been created at RolloutAfter or later.
503503
for _, ms := range matchingMachineSets {
504-
if ms.CreationTimestamp.After(deployment.Spec.RolloutAfter.Time) {
504+
if ms.CreationTimestamp.Sub(deployment.Spec.RolloutAfter.Time) >= 0 {
505505
return ms, "", nil
506506
}
507507
}

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)