Skip to content

Commit

Permalink
rollout code optimization
Browse files Browse the repository at this point in the history
Signed-off-by: liheng.zms <[email protected]>
  • Loading branch information
zmberg committed Apr 12, 2022
1 parent 0b23feb commit 95b5ca1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/controller/rollout/trafficrouting.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (
)

func (r *rolloutContext) doCanaryTrafficRouting() (bool, error) {
if r.rollout.Spec.Strategy.Canary.TrafficRoutings == nil {
if len(r.rollout.Spec.Strategy.Canary.TrafficRoutings) == 0 {
return true, nil
}

Expand Down Expand Up @@ -134,7 +134,7 @@ func (r *rolloutContext) doCanaryTrafficRouting() (bool, error) {
}

func (r *rolloutContext) restoreStableService() (bool, error) {
if r.rollout.Spec.Strategy.Canary.TrafficRoutings == nil {
if len(r.rollout.Spec.Strategy.Canary.TrafficRoutings) == 0 {
return true, nil
}

Expand Down Expand Up @@ -179,7 +179,7 @@ func (r *rolloutContext) restoreStableService() (bool, error) {
}

func (r *rolloutContext) doFinalisingTrafficRouting() (bool, error) {
if r.rollout.Spec.Strategy.Canary.TrafficRoutings == nil {
if len(r.rollout.Spec.Strategy.Canary.TrafficRoutings) == 0 {
return true, nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ func validateRolloutSpecCanaryStrategy(canary *appsv1alpha1.CanaryStrategy, fldP
}

errList := validateRolloutSpecCanarySteps(canary.Steps, fldPath.Child("Steps"))
if len(canary.TrafficRoutings) > 1 {
errList = append(errList, field.Invalid(fldPath, canary.TrafficRoutings, "Rollout currently only support single TrafficRouting."))
}
for _, traffic := range canary.TrafficRoutings {
errList = append(errList, validateRolloutSpecCanaryTraffic(traffic, fldPath.Child("TrafficRouting"))...)
}
Expand Down

0 comments on commit 95b5ca1

Please sign in to comment.