Add webhook confirm-traffic-increase for manually approving traffic increase

Signed-off-by: Mayank Shah <mayankshah1614@gmail.com>
This commit is contained in:
Mayank Shah
2021-03-16 20:18:27 +05:30
parent f2d121a13b
commit 873141b9ca
5 changed files with 26 additions and 0 deletions
+1
View File
@@ -940,6 +940,7 @@ spec:
- post-rollout
- event
- rollback
- confirm-traffic-increase
url:
description: URL address of this webhook
type: string
+1
View File
@@ -940,6 +940,7 @@ spec:
- post-rollout
- event
- rollback
- confirm-traffic-increase
url:
description: URL address of this webhook
type: string
+2
View File
@@ -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
+6
View File
@@ -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)
}
+16
View File
@@ -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 {