Skip to content

Commit 4a16622

Browse files
sm4ll-3ggk8s-infra-cherrypick-robot
authored andcommitted
Fix second rolling update for MD rolloutAfter
1 parent 0bd9850 commit 4a16622

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

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

internal/controllers/machinedeployment/mdutil/util_test.go

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

424+
msCreatedExactlyInRolloutAfter := generateMS(deployment)
425+
msCreatedExactlyInRolloutAfter.CreationTimestamp = rolloutAfter
426+
424427
tests := []struct {
425428
Name string
426429
deployment clusterv1.MachineDeployment
@@ -483,6 +486,14 @@ func TestFindNewMachineSet(t *testing.T) {
483486
reconciliationTime: &twoAfterRolloutAfter,
484487
expected: &msCreatedAfterRolloutAfter,
485488
},
489+
{
490+
// https://github.com/kubernetes-sigs/cluster-api/issues/12260
491+
Name: "Get MachineSet created exactly in RolloutAfter if reconciliationTime > rolloutAfter",
492+
deployment: *deploymentWithRolloutAfter,
493+
msList: []*clusterv1.MachineSet{&msCreatedExactlyInRolloutAfter, &msCreatedTwoBeforeRolloutAfter},
494+
reconciliationTime: &oneAfterRolloutAfter,
495+
expected: &msCreatedExactlyInRolloutAfter,
496+
},
486497
{
487498
Name: "Get MachineSet created after RolloutAfter if reconciliationTime is > rolloutAfter (inverse order in ms list)",
488499
deployment: *deploymentWithRolloutAfter,

0 commit comments

Comments
 (0)