From f33cae5426efb68590025c9a9dc6bd25b051c3ed Mon Sep 17 00:00:00 2001 From: Vishal Kumar Singh Date: Sat, 16 May 2026 14:46:39 +0530 Subject: [PATCH] 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 --- pkg/controller/events_test.go | 4 ++++ pkg/controller/scheduler.go | 1 + 2 files changed, 5 insertions(+) diff --git a/pkg/controller/events_test.go b/pkg/controller/events_test.go index 6c4f48116..507edf484 100644 --- a/pkg/controller/events_test.go +++ b/pkg/controller/events_test.go @@ -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") diff --git a/pkg/controller/scheduler.go b/pkg/controller/scheduler.go index 12a94befc..0ffe2c432 100644 --- a/pkg/controller/scheduler.go +++ b/pkg/controller/scheduler.go @@ -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.",