Skip to content

Commit

Permalink
safte index check
Browse files Browse the repository at this point in the history
Signed-off-by: yunbo <[email protected]>
  • Loading branch information
Funinu committed May 29, 2024
1 parent 1508638 commit 28303e1
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pkg/controller/rollout/rollout_progressing.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,17 @@ func setRolloutSucceededCondition(status *v1beta1.RolloutStatus, condStatus core
}

func newTrafficRoutingContext(c *RolloutContext) *trafficrouting.TrafficRoutingContext {
currentStep := c.Rollout.Spec.Strategy.GetSteps()[c.NewStatus.GetSubStatus().CurrentStepIndex-1]
currentIndex := c.NewStatus.GetSubStatus().CurrentStepIndex - 1
var currentStep v1beta1.CanaryStep
//TODO - need better designed logic
if currentIndex < 0 || int(currentIndex) >= len(c.Rollout.Spec.Strategy.GetSteps()) {
klog.Warningf("Rollout(%s/%s) encounters a special case when constructing newTrafficRoutingContext", c.Rollout.Namespace, c.Rollout.Name)
// usually this only happens when deleting the rollout or rolling back
// in this situation, it's no matter which step the current is
currentStep = c.Rollout.Spec.Strategy.GetSteps()[0]
} else {
currentStep = c.Rollout.Spec.Strategy.GetSteps()[currentIndex]
}
var revisionLabelKey string
if c.Workload != nil {
revisionLabelKey = c.Workload.RevisionLabelKey
Expand Down

0 comments on commit 28303e1

Please sign in to comment.