From ab84ac207a373aacc8159118f1d2971067d053db Mon Sep 17 00:00:00 2001 From: Ying Liu Date: Thu, 17 Mar 2022 10:32:01 +0800 Subject: [PATCH] shorten the metric analysis cycle after confirmpromption gate is open and make the analysis check still works during waitingpromption status Signed-off-by: Ying Liu --- pkg/canary/status.go | 3 +++ pkg/controller/scheduler.go | 2 +- pkg/controller/scheduler_hooks.go | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/canary/status.go b/pkg/canary/status.go index d0c2c433..178ed6ea 100644 --- a/pkg/canary/status.go +++ b/pkg/canary/status.go @@ -158,6 +158,9 @@ func setStatusPhase(flaggerClient clientset.Interface, cd *flaggerv1.Canary, pha if phase != flaggerv1.CanaryPhaseProgressing && phase != flaggerv1.CanaryPhaseWaiting { cdCopy.Status.CanaryWeight = 0 cdCopy.Status.Iterations = 0 + if phase == flaggerv1.CanaryPhaseWaitingPromotion { + cdCopy.Status.Iterations = cd.GetAnalysis().Iterations - 1 + } } // on promotion set primary spec hash diff --git a/pkg/controller/scheduler.go b/pkg/controller/scheduler.go index 7b52322f..6bc81ef4 100644 --- a/pkg/controller/scheduler.go +++ b/pkg/controller/scheduler.go @@ -347,7 +347,7 @@ func (c *Controller) advanceCanary(name string, namespace string) { } // check if the number of failed checks reached the threshold - if cd.Status.Phase == flaggerv1.CanaryPhaseProgressing && + if (cd.Status.Phase == flaggerv1.CanaryPhaseProgressing || cd.Status.Phase == flaggerv1.CanaryPhaseWaitingPromotion) && (!retriable || cd.Status.FailedChecks >= cd.GetAnalysisThreshold()) { if !retriable { c.recordEventWarningf(cd, "Rolling back %s.%s progress deadline exceeded %v", diff --git a/pkg/controller/scheduler_hooks.go b/pkg/controller/scheduler_hooks.go index 3382dacd..7d2349be 100644 --- a/pkg/controller/scheduler_hooks.go +++ b/pkg/controller/scheduler_hooks.go @@ -90,6 +90,10 @@ func (c *Controller) runConfirmPromotionHooks(canary *flaggerv1.Canary, canaryCo if !webhook.MuteAlert { c.alert(canary, "Canary promotion is waiting for approval.", false, flaggerv1.SeverityWarn) } + } else { + if err := canaryController.SetStatusIterations(canary, canary.GetAnalysis().Iterations-1); err != nil { + c.recordEventWarningf(canary, "%v", err) + } } return false } else {