mirror of
https://github.com/fluxcd/flagger.git
synced 2026-04-15 06:57:34 +00:00
Add webhook confirm-traffic-increase for manually approving traffic increase
Signed-off-by: Mayank Shah <mayankshah1614@gmail.com>
This commit is contained in:
@@ -940,6 +940,7 @@ spec:
|
||||
- post-rollout
|
||||
- event
|
||||
- rollback
|
||||
- confirm-traffic-increase
|
||||
url:
|
||||
description: URL address of this webhook
|
||||
type: string
|
||||
|
||||
@@ -940,6 +940,7 @@ spec:
|
||||
- post-rollout
|
||||
- event
|
||||
- rollback
|
||||
- confirm-traffic-increase
|
||||
url:
|
||||
description: URL address of this webhook
|
||||
type: string
|
||||
|
||||
@@ -314,6 +314,8 @@ const (
|
||||
EventHook HookType = "event"
|
||||
// RollbackHook rollback canary analysis if webhook returns HTTP 200
|
||||
RollbackHook HookType = "rollback"
|
||||
// ConfirmTrafficIncreaseHook increases traffic weight if webhook returns HTTP 200
|
||||
ConfirmTrafficIncreaseHook = "confirm-traffic-increase"
|
||||
)
|
||||
|
||||
// CanaryWebhook holds the reference to external checks used for canary analysis
|
||||
|
||||
@@ -412,6 +412,12 @@ func (c *Controller) advanceCanary(name string, namespace string) {
|
||||
|
||||
// strategy: Canary progressive traffic increase
|
||||
if c.nextStepWeight(cd, canaryWeight) > 0 {
|
||||
// run hook only if traffic is not mirrored
|
||||
if !mirrored {
|
||||
if promote := c.runConfirmTrafficIncreaseHooks(cd); !promote {
|
||||
return
|
||||
}
|
||||
}
|
||||
c.runCanary(cd, canaryController, meshRouter, mirrored, canaryWeight, primaryWeight, maxWeight)
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,22 @@ import (
|
||||
"github.com/fluxcd/flagger/pkg/canary"
|
||||
)
|
||||
|
||||
func (c *Controller) runConfirmTrafficIncreaseHooks(canary *flaggerv1.Canary) bool {
|
||||
for _, webhook := range canary.GetAnalysis().Webhooks {
|
||||
if webhook.Type == flaggerv1.ConfirmTrafficIncreaseHook {
|
||||
err := CallWebhook(canary.Name, canary.Namespace, flaggerv1.CanaryPhaseProgressing, webhook)
|
||||
if err != nil {
|
||||
c.recordEventWarningf(canary, "Halt %s.%s advancement waiting for traffic increase approval %s",
|
||||
canary.Name, canary.Namespace, webhook.Name)
|
||||
c.alert(canary, "Canary traffic increase is waiting for approval.", false, flaggerv1.SeverityWarn)
|
||||
return false
|
||||
}
|
||||
c.recordEventInfof(canary, "Confirm-traffic-increase check %s passed", webhook.Name)
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (c *Controller) runConfirmRolloutHooks(canary *flaggerv1.Canary, canaryController canary.Controller) bool {
|
||||
for _, webhook := range canary.GetAnalysis().Webhooks {
|
||||
if webhook.Type == flaggerv1.ConfirmRolloutHook {
|
||||
|
||||
Reference in New Issue
Block a user