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

Add spec.suspend to allow suspending canary #1431

Merged
merged 1 commit into from
May 17, 2023
Merged
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
7 changes: 7 additions & 0 deletions artifacts/flagger/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ spec:
- name: Weight
type: string
jsonPath: .status.canaryWeight
- name: Suspended
type: boolean
jsonPath: .spec.suspend
priority: 1
- name: FailedChecks
type: string
jsonPath: .status.failedChecks
Expand Down Expand Up @@ -850,6 +854,9 @@ spec:
revertOnDeletion:
description: Revert mutated resources to original spec on deletion
type: boolean
suspend:
description: Suspend Canary disabling/pausing all canary runs
type: boolean
analysis:
description: Canary analysis for this canary
type: object
Expand Down
7 changes: 7 additions & 0 deletions charts/flagger/crds/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ spec:
- name: Weight
type: string
jsonPath: .status.canaryWeight
- name: Suspended
type: boolean
jsonPath: .spec.suspend
priority: 1
- name: FailedChecks
type: string
jsonPath: .status.failedChecks
Expand Down Expand Up @@ -850,6 +854,9 @@ spec:
revertOnDeletion:
description: Revert mutated resources to original spec on deletion
type: boolean
suspend:
description: Suspend Canary disabling/pausing all canary runs
type: boolean
analysis:
description: Canary analysis for this canary
type: object
Expand Down
7 changes: 7 additions & 0 deletions docs/gitbook/usage/how-it-works.md
Original file line number Diff line number Diff line change
Expand Up @@ -379,3 +379,10 @@ On each run, Flagger calls the webhooks, checks the metrics and if the failed ch
stops the analysis and rolls back the canary.
If alerting is configured, Flagger will post the analysis result using the alert providers.

## Canary suspend

The `suspend` field can be set to true to suspend the Canary. If a Canary is suspended,
its reconciliation is completely paused. This means that changes to target workloads,
tracked ConfigMaps and Secrets don't trigger a Canary run and changes to resources generated
by Flagger are not corrected. If the Canary was suspended during an active Canary run,
then the run is paused without disturbing the workloads or the traffic weights.
7 changes: 7 additions & 0 deletions kustomize/base/flagger/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ spec:
- name: Weight
type: string
jsonPath: .status.canaryWeight
- name: Suspended
type: boolean
jsonPath: .spec.suspend
priority: 1
- name: FailedChecks
type: string
jsonPath: .status.failedChecks
Expand Down Expand Up @@ -850,6 +854,9 @@ spec:
revertOnDeletion:
description: Revert mutated resources to original spec on deletion
type: boolean
suspend:
description: Suspend Canary disabling/pausing all canary runs
type: boolean
analysis:
description: Canary analysis for this canary
type: object
Expand Down
6 changes: 6 additions & 0 deletions pkg/apis/flagger/v1beta1/canary.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ type CanarySpec struct {
// revert canary mutation on deletion of canary resource
// +optional
RevertOnDeletion bool `json:"revertOnDeletion,omitempty"`

// Suspend, if set to true will suspend the Canary, disabling any canary runs
// regardless of any changes to its target, services, etc. Note that if the
// Canary is suspended during an analysis, its paused until the Canary is unsuspended.
// +optional
Suspend bool `json:"suspend,omitempty"`
aryan9600 marked this conversation as resolved.
Show resolved Hide resolved
}

// CanaryService defines how ClusterIP services, service mesh or ingress routing objects are generated
Expand Down
9 changes: 9 additions & 0 deletions pkg/controller/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,14 @@ func (c *Controller) advanceCanary(name string, namespace string) {
return
}

if cd.Spec.Suspend {
msg := "skipping canary run as object is suspended"
c.logger.With("canary", fmt.Sprintf("%s.%s", name, namespace)).
aryan9600 marked this conversation as resolved.
Show resolved Hide resolved
Debug(msg)
c.recordEventInfof(cd, msg)
return
}

// override the global provider if one is specified in the canary spec
provider := c.meshProvider
if cd.Spec.Provider != "" {
Expand All @@ -172,6 +180,7 @@ func (c *Controller) advanceCanary(name string, namespace string) {

// init controller based on target kind
canaryController := c.canaryFactory.Controller(cd.Spec.TargetRef.Kind)

labelSelector, labelValue, ports, err := canaryController.GetMetadata(cd)
if err != nil {
c.recordEventWarningf(cd, "%v", err)
Expand Down