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 field spec.analysis.canaryReadyThreshold for configuring canary threshold #1102

Merged
merged 1 commit into from
Feb 10, 2022
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
3 changes: 3 additions & 0 deletions artifacts/flagger/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,9 @@ spec:
primaryReadyThreshold:
description: Percentage of pods that need to be available to consider primary as ready
type: number
canaryReadyThreshold:
description: Percentage of pods that need to be available to consider canary as ready
type: number
match:
description: A/B testing match conditions
type: array
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 @@ -829,6 +829,9 @@ spec:
primaryReadyThreshold:
description: Percentage of pods that need to be available to consider primary as ready
type: number
canaryReadyThreshold:
description: Percentage of pods that need to be available to consider canary as ready
type: number
match:
description: A/B testing match conditions
type: array
Expand Down
4 changes: 4 additions & 0 deletions docs/gitbook/usage/how-it-works.md
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,10 @@ Spec:
# before starting rollout. this is optional and the default is 100
# percentage (0-100)
primaryReadyThreshold: 100
# threshold of canary pods that need to be available to consider it ready
# before starting rollout. this is optional and the default is 100
# percentage (0-100)
canaryReadyThreshold: 100
# canary match conditions
# used for A/B Testing
match:
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 @@ -829,6 +829,9 @@ spec:
primaryReadyThreshold:
description: Percentage of pods that need to be available to consider primary as ready
type: number
canaryReadyThreshold:
description: Percentage of pods that need to be available to consider canary as ready
type: number
match:
description: A/B testing match conditions
type: array
Expand Down
12 changes: 12 additions & 0 deletions pkg/apis/flagger/v1beta1/canary.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const (
ProgressDeadlineSeconds = 600
AnalysisInterval = 60 * time.Second
PrimaryReadyThreshold = 100
CanaryReadyThreshold = 100
MetricInterval = "1m"
)

Expand Down Expand Up @@ -233,6 +234,9 @@ type CanaryAnalysis struct {
// Percentage of pods that need to be available to consider primary as ready
PrimaryReadyThreshold *int `json:"primaryReadyThreshold,omitempty"`

// Percentage of pods that need to be available to consider canary as ready
CanaryReadyThreshold *int `json:"canaryReadyThreshold,omitempty"`

// Alert list for this canary analysis
Alerts []CanaryAlert `json:"alerts,omitempty"`

Expand Down Expand Up @@ -452,6 +456,14 @@ func (c *Canary) GetAnalysisPrimaryReadyThreshold() int {
return PrimaryReadyThreshold
}

// GetAnalysisCanaryReadyThreshold returns the canary canaryReadyThreshold (default 100)
func (c *Canary) GetAnalysisCanaryReadyThreshold() int {
if c.GetAnalysis().CanaryReadyThreshold != nil {
return *c.GetAnalysis().CanaryReadyThreshold
}
return CanaryReadyThreshold
}

// GetMetricInterval returns the metric interval default value (1m)
func (c *Canary) GetMetricInterval() string {
return MetricInterval
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/flagger/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/canary/daemonset_ready.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (c *DaemonSetController) IsCanaryReady(cd *flaggerv1.Canary) (bool, error)
return true, fmt.Errorf("daemonset %s.%s get query error: %w", targetName, cd.Namespace, err)
}

retryable, err := c.isDaemonSetReady(cd, canary, 100)
retryable, err := c.isDaemonSetReady(cd, canary, cd.GetAnalysisCanaryReadyThreshold())
if err != nil {
return retryable, fmt.Errorf("canary damonset %s.%s not ready with retryable %v: %w",
targetName, cd.Namespace, retryable, err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/canary/deployment_ready.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (c *DeploymentController) IsCanaryReady(cd *flaggerv1.Canary) (bool, error)
return true, fmt.Errorf("deployment %s.%s get query error: %w", targetName, cd.Namespace, err)
}

retryable, err := c.isDeploymentReady(canary, cd.GetProgressDeadlineSeconds(), 100)
retryable, err := c.isDeploymentReady(canary, cd.GetProgressDeadlineSeconds(), cd.GetAnalysisCanaryReadyThreshold())
if err != nil {
return retryable, fmt.Errorf(
"canary deployment %s.%s not ready: %w",
Expand Down