Skip to content

Commit 4622ae4

Browse files
committed
fix: nil pointer dereference when reconciling paused blue-green rollout (argoproj#1378)
Signed-off-by: Jesse Suen <[email protected]>
1 parent 8b53b2c commit 4622ae4

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

rollout/bluegreen.go

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -163,22 +163,24 @@ func (c *rolloutContext) reconcileBlueGreenPause(activeSvc, previewSvc *corev1.S
163163
return
164164
}
165165
pauseCond := getPauseCondition(c.rollout, v1alpha1.PauseReasonBlueGreenPause)
166-
if pauseCond == nil && !c.rollout.Status.ControllerPause {
167-
if pauseCond == nil {
168-
c.log.Info("pausing")
169-
}
170-
c.pauseContext.AddPauseCondition(v1alpha1.PauseReasonBlueGreenPause)
171-
return
172-
}
173-
174-
if !c.pauseContext.CompletedBlueGreenPause() {
175-
c.log.Info("pause incomplete")
176-
if c.rollout.Spec.Strategy.BlueGreen.AutoPromotionSeconds > 0 {
177-
c.checkEnqueueRolloutDuringWait(pauseCond.StartTime, c.rollout.Spec.Strategy.BlueGreen.AutoPromotionSeconds)
166+
if pauseCond != nil {
167+
// We are currently paused. Check if we completed our pause duration
168+
if !c.pauseContext.CompletedBlueGreenPause() {
169+
c.log.Info("pause incomplete")
170+
if c.rollout.Spec.Strategy.BlueGreen.AutoPromotionSeconds > 0 {
171+
c.checkEnqueueRolloutDuringWait(pauseCond.StartTime, c.rollout.Spec.Strategy.BlueGreen.AutoPromotionSeconds)
172+
}
173+
} else {
174+
c.log.Infof("pause completed")
175+
c.pauseContext.RemovePauseCondition(v1alpha1.PauseReasonBlueGreenPause)
178176
}
179177
} else {
180-
c.log.Infof("pause completed")
181-
c.pauseContext.RemovePauseCondition(v1alpha1.PauseReasonBlueGreenPause)
178+
// no pause condition exists. If Status.ControllerPause is true, the user manually resumed
179+
// the rollout. e.g. `kubectl argo rollouts promote ROLLOUT`
180+
if !c.rollout.Status.ControllerPause {
181+
c.log.Info("pausing")
182+
c.pauseContext.AddPauseCondition(v1alpha1.PauseReasonBlueGreenPause)
183+
}
182184
}
183185
}
184186

0 commit comments

Comments
 (0)