Run post-rollout hooks when skipAnalysis is true

When skipAnalysis is enabled and the canary is promoted, the
post-rollout webhooks were not being executed. This fix ensures
that runPostRolloutHooks is called in shouldSkipAnalysis, matching
the behavior of the normal promotion path.

Fixes fluxcd/flagger#1195

Signed-off-by: Vishal Kumar Singh <vishal.kr.singh2021@gmail.com>
This commit is contained in:
Vishal Kumar Singh
2026-05-16 14:46:39 +05:30
parent 3b0c9d654f
commit f33cae5426
2 changed files with 5 additions and 0 deletions
+4
View File
@@ -58,11 +58,15 @@ func TestWebhooks(t *testing.T) {
{Phase: flaggerv1.CanaryPhaseInitialized, Metadata: map[string]string{"eventMessage": "Confirm-rollout check confirm-rollout-webhook passed"}},
{Phase: flaggerv1.CanaryPhaseProgressing, Metadata: map[string]string{"eventMessage": "New revision detected! Scaling up podinfo.default"}},
{Phase: flaggerv1.CanaryPhaseProgressing, Metadata: map[string]string{"eventMessage": "Copying podinfo.default template spec to podinfo-primary.default"}},
{Phase: flaggerv1.CanaryPhaseSucceeded, Metadata: map[string]string{"eventMessage": "Post-rollout check post-rollout-webhook passed"}},
{Phase: flaggerv1.CanaryPhaseSucceeded, Metadata: map[string]string{"eventMessage": "Promotion completed! Canary analysis was skipped for podinfo.default"}},
},
"confirm-rollout": {
{Phase: flaggerv1.CanaryPhaseInitialized, Metadata: map[string]string{"eventMessage": ""}},
},
"post-rollout": {
{Phase: flaggerv1.CanaryPhaseSucceeded, Metadata: map[string]string{"eventMessage": ""}},
},
},
test: func(t *testing.T, mocks fixture) {
mocks.ctrl.advanceCanary("podinfo", "default")
+1
View File
@@ -833,6 +833,7 @@ func (c *Controller) shouldSkipAnalysis(canary *flaggerv1.Canary, canaryControll
canarySucceeded := canary.DeepCopy()
canarySucceeded.Status.Phase = flaggerv1.CanaryPhaseSucceeded
c.runPostRolloutHooks(canarySucceeded, flaggerv1.CanaryPhaseSucceeded)
c.recordEventInfof(canarySucceeded, "Promotion completed! Canary analysis was skipped for %s.%s",
canary.Spec.TargetRef.Name, canary.Namespace)
c.alert(canarySucceeded, "Canary analysis was skipped, promotion finished.",