Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retry Counter for Rollout Hook #1508

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions artifacts/flagger/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,9 @@ spec:
description: URL address of this webhook
type: string
format: url
retrylimit:
type: integer
description: Number of retry if Rollout hook failed
timeout:
description: Request timeout for this webhook
type: string
Expand Down
3 changes: 3 additions & 0 deletions charts/flagger/crds/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,9 @@ spec:
description: URL address of this webhook
type: string
format: url
retrylimit:
type: integer
description: Number of retry if Rollout hook failed
timeout:
description: Request timeout for this webhook
type: string
Expand Down
3 changes: 3 additions & 0 deletions kustomize/base/flagger/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,9 @@ spec:
description: URL address of this webhook
type: string
format: url
retrylimit:
type: integer
description: Number of retry if Rollout hook failed
timeout:
description: Request timeout for this webhook
type: string
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/flagger/v1beta1/canary.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,11 @@ type CanaryWebhook struct {
// Metadata (key-value pairs) for this webhook
// +optional
Metadata *map[string]string `json:"metadata,omitempty"`

// FailureThreshold for rollout hook
// +optional
WebhookRetries int `json:"webhookRetries,omitempty"`

}

// CanaryWebhookPayload holds the deployment info and metadata sent to webhooks
Expand Down
17 changes: 17 additions & 0 deletions pkg/controller/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ func (c *Controller) advanceCanary(name string, namespace string) {
return
}
} else {
c.runRolloutWebhooks(cd);
if ok := c.runAnalysis(cd); !ok {
if err := canaryController.SetStatusFailedChecks(cd, cd.Status.FailedChecks+1); err != nil {
c.recordEventWarningf(cd, "%v", err)
Expand Down Expand Up @@ -749,6 +750,22 @@ func (c *Controller) runAnalysis(canary *flaggerv1.Canary) bool {
return true
}

func (c *Controller) runRolloutWebhooks(canary *flaggerv1.Canary,retryLimit int) bool {
for _, webhook := range canary.GetAnalysis().Webhooks {
if webhook.Type == "" || webhook.Type == flaggerv1.RolloutHook {
if canary.Status.WebhookRetries >= retryLimit {
c.recordEventWarningf(canary, "Retries exceeded limit for webhook %s", webhook.Name)
return false
}
if err := CallWebhook(canary.Name, canary.Namespace, flaggerv1.CanaryPhaseProgressing, webhook); err != nil {
canary.Status.WebhookRetries++
return false
}
}
}
return true
}

func (c *Controller) shouldSkipAnalysis(canary *flaggerv1.Canary, canaryController canary.Controller, meshRouter router.Interface, scalerReconciler canary.ScalerReconciler, err error, retriable bool) bool {
if !canary.SkipAnalysis() {
return false
Expand Down
Loading