mirror of
https://github.com/fluxcd/flagger.git
synced 2026-09-05 02:47:17 +00:00
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:
@@ -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")
|
||||
|
||||
@@ -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.",
|
||||
|
||||
Reference in New Issue
Block a user