Skip to content

Commit

Permalink
scale old replicaset if it is still ref
Browse files Browse the repository at this point in the history
Signed-off-by: BrunoTarijon <[email protected]>
  • Loading branch information
BrunoTarijon authored and zachaller committed Aug 2, 2024
1 parent bca5579 commit f16226c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions rollout/canary.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,15 @@ func (c *rolloutContext) scaleDownOldReplicaSetsForCanary(oldRSs []*appsv1.Repli
annotationedRSs := int32(0)
for _, targetRS := range oldRSs {
if c.rollout.Spec.Strategy.Canary.TrafficRouting != nil && c.isReplicaSetReferenced(targetRS) {
// We might get here if user interrupted an an update in order to move back to stable.
// We might get here if user interrupted an update in order to move back to stable or if the controller could not switch the canary service to the new RS.
c.log.Infof("Skip scale down of older RS '%s': still referenced", targetRS.Name)
c.reconcileStableAndCanaryService()

// If the replicaset is still referenced, the controller should scale it
_, desiredRSReplicaCount := replicasetutil.CalculateReplicaCountsForTrafficRoutedCanary(c.rollout, c.rollout.Status.Canary.Weights)
_, _, err = c.scaleReplicaSetAndRecordEvent(targetRS, desiredRSReplicaCount)
if err != nil {
c.log.Errorf("Failed to scale old RS '%s': %v", targetRS.Name, err)

Check warning on line 195 in rollout/canary.go

View check run for this annotation

Codecov / codecov/patch

rollout/canary.go#L195

Added line #L195 was not covered by tests
}
continue
}
if maxScaleDown <= 0 {
Expand Down

0 comments on commit f16226c

Please sign in to comment.