Skip to content

Commit aac74bd

Browse files
committed
add spec.suspend to allow suspending canary
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. Signed-off-by: Sanskar Jaiswal <[email protected]>
1 parent b71f0ce commit aac74bd

File tree

6 files changed

+29
-0
lines changed

6 files changed

+29
-0
lines changed

artifacts/flagger/crd.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,9 @@ spec:
850850
revertOnDeletion:
851851
description: Revert mutated resources to original spec on deletion
852852
type: boolean
853+
suspend:
854+
description: Suspend Canary disabling/pausing all canary runs
855+
type: boolean
853856
analysis:
854857
description: Canary analysis for this canary
855858
type: object

charts/flagger/crds/crd.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,9 @@ spec:
850850
revertOnDeletion:
851851
description: Revert mutated resources to original spec on deletion
852852
type: boolean
853+
suspend:
854+
description: Suspend Canary disabling/pausing all canary runs
855+
type: boolean
853856
analysis:
854857
description: Canary analysis for this canary
855858
type: object

docs/gitbook/usage/how-it-works.md

+7
Original file line numberDiff line numberDiff line change
@@ -379,3 +379,10 @@ On each run, Flagger calls the webhooks, checks the metrics and if the failed ch
379379
stops the analysis and rolls back the canary.
380380
If alerting is configured, Flagger will post the analysis result using the alert providers.
381381

382+
## Canary suspend
383+
384+
The `suspend` field can be set to true to suspend the Canary. If a Canary is suspended,
385+
its reconciliation is completely paused. This means that changes to target workloads,
386+
tracked ConfigMaps and Secrets don't trigger a Canary run and changes to resources generated
387+
by Flagger are not corrected. If the Canary was suspended during an active Canary run,
388+
then the run is paused without disturbing the workloads or the traffic weights.

kustomize/base/flagger/crd.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,9 @@ spec:
850850
revertOnDeletion:
851851
description: Revert mutated resources to original spec on deletion
852852
type: boolean
853+
suspend:
854+
description: Suspend Canary disabling/pausing all canary runs
855+
type: boolean
853856
analysis:
854857
description: Canary analysis for this canary
855858
type: object

pkg/apis/flagger/v1beta1/canary.go

+6
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ type CanarySpec struct {
110110
// revert canary mutation on deletion of canary resource
111111
// +optional
112112
RevertOnDeletion bool `json:"revertOnDeletion,omitempty"`
113+
114+
// Suspend, if set to true will suspend the Canary, disabling any canary runs
115+
// regardless of any changes to its target, services, etc. Note that if the
116+
// Canary is suspended during an analysis, its paused until the Canary is unsuspended.
117+
// +optional
118+
Suspend bool `json:"suspend,omitempty"`
113119
}
114120

115121
// CanaryService defines how ClusterIP services, service mesh or ingress routing objects are generated

pkg/controller/scheduler.go

+7
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,12 @@ func (c *Controller) advanceCanary(name string, namespace string) {
164164
return
165165
}
166166

167+
if cd.Spec.Suspend {
168+
c.logger.With("canary", fmt.Sprintf("%s.%s", name, namespace)).
169+
Info("skipping canary run as object is suspended")
170+
return
171+
}
172+
167173
// override the global provider if one is specified in the canary spec
168174
provider := c.meshProvider
169175
if cd.Spec.Provider != "" {
@@ -172,6 +178,7 @@ func (c *Controller) advanceCanary(name string, namespace string) {
172178

173179
// init controller based on target kind
174180
canaryController := c.canaryFactory.Controller(cd.Spec.TargetRef.Kind)
181+
175182
labelSelector, labelValue, ports, err := canaryController.GetMetadata(cd)
176183
if err != nil {
177184
c.recordEventWarningf(cd, "%v", err)

0 commit comments

Comments
 (0)