Skip to content

Commit

Permalink
retry limit on rolloutHook
Browse files Browse the repository at this point in the history
  • Loading branch information
tyagian committed Sep 8, 2023
1 parent 8dbd8d5 commit 61e128c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
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
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
RetryLimit int `json:"retrylimit,omitempty"`

}

// CanaryWebhookPayload holds the deployment info and metadata sent to webhooks
Expand Down
21 changes: 16 additions & 5 deletions pkg/controller/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -727,11 +727,22 @@ func (c *Controller) runAnalysis(canary *flaggerv1.Canary) bool {
// run external checks
for _, webhook := range canary.GetAnalysis().Webhooks {
if webhook.Type == "" || webhook.Type == flaggerv1.RolloutHook {
err := CallWebhook(canary.Name, canary.Namespace, flaggerv1.CanaryPhaseProgressing, webhook)
if err != nil {
c.recordEventWarningf(canary, "Halt %s.%s advancement external check %s failed %v",
canary.Name, canary.Namespace, webhook.Name, err)
return false
retries := 0
for {
err := CallWebhook(canary.Name, canary.Namespace, flaggerv1.CanaryPhaseProgressing, webhook)
if err != nil {
c.recordEventWarningf(canary, "Retrying %s.%s advancement external check %s failed %v",
canary.Name, canary.Namespace, webhook.Name, err)
retries++
if retries >= retrylimit {
c.recordEventWarningf(canary, "Halt %s.%s advancement external check %s failed %v",
canary.Name, canary.Namespace, webhook.Name, err)
return false // retry limit crossed retrylimit
}
} else {
break // Success, exit the retry loop
}

}
}
}
Expand Down

0 comments on commit 61e128c

Please sign in to comment.