From e0eba316152cf37b69df820f29c0604a950bfcf9 Mon Sep 17 00:00:00 2001 From: Andrii Perenesenko Date: Fri, 10 Jun 2022 13:48:29 -0700 Subject: [PATCH] fix: High reconciliation activity and CPU load for invalid rollout Signed-off-by: Andrii Perenesenko --- pkg/apis/rollouts/validation/validation.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/apis/rollouts/validation/validation.go b/pkg/apis/rollouts/validation/validation.go index d71af46ed4..15d10ea7c1 100644 --- a/pkg/apis/rollouts/validation/validation.go +++ b/pkg/apis/rollouts/validation/validation.go @@ -291,8 +291,8 @@ func ValidateRolloutStrategyCanary(rollout *v1alpha1.Rollout, fldPath *field.Pat if step.Pause != nil && step.Pause.DurationSeconds() < 0 { allErrs = append(allErrs, field.Invalid(stepFldPath.Child("pause").Child("duration"), step.Pause.DurationSeconds(), InvalidDurationMessage)) } - if rollout.Spec.Strategy.Canary != nil && rollout.Spec.Strategy.Canary.TrafficRouting == nil && step.SetCanaryScale != nil { - allErrs = append(allErrs, field.Invalid(stepFldPath.Child("setCanaryScale"), step.SetCanaryScale, InvalidSetCanaryScaleTrafficPolicy)) + if step.SetCanaryScale != nil && canary.TrafficRouting == nil { + allErrs = append(allErrs, field.Required(fldPath.Child("trafficRouting"), InvalidSetCanaryScaleTrafficPolicy)) } if step.SetHeaderRouting != nil { trafficRouting := rollout.Spec.Strategy.Canary.TrafficRouting