Add canary analysis interval to CRD

This commit is contained in:
stefanprodan
2019-01-07 00:24:43 +02:00
parent 322c83bdad
commit 537e8fdaf7
4 changed files with 24 additions and 0 deletions
+2
View File
@@ -27,6 +27,8 @@ spec:
hosts:
- app.iowa.weavedx.com
canaryAnalysis:
# schedule interval (default 60s)
interval: 10s
# max number of failed metric checks before rollback
threshold: 10
# max traffic percentage routed to canary
+3
View File
@@ -56,6 +56,9 @@ spec:
type: number
canaryAnalysis:
properties:
interval:
type: string
pattern: "^[0-9]+(m)"
threshold:
type: number
maxWeight:
+3
View File
@@ -57,6 +57,9 @@ spec:
type: number
canaryAnalysis:
properties:
interval:
type: string
pattern: "^[0-9]+(m)"
threshold:
type: number
maxWeight:
+16
View File
@@ -19,11 +19,13 @@ package v1alpha2
import (
hpav1 "k8s.io/api/autoscaling/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"time"
)
const (
CanaryKind = "Canary"
ProgressDeadlineSeconds = 600
AnalysisInterval = 60 * time.Second
)
// +genclient
@@ -96,6 +98,7 @@ type CanaryService struct {
// CanaryAnalysis is used to describe how the analysis should be done
type CanaryAnalysis struct {
Interval string `json:"interval"`
Threshold int `json:"threshold"`
MaxWeight int `json:"maxWeight"`
StepWeight int `json:"stepWeight"`
@@ -134,3 +137,16 @@ func (c *Canary) GetProgressDeadlineSeconds() int {
return ProgressDeadlineSeconds
}
func (c *Canary) GetAnalysisInterval() time.Duration {
if c.Spec.CanaryAnalysis.Interval == "" {
return AnalysisInterval
}
interval, err := time.ParseDuration(c.Spec.CanaryAnalysis.Interval)
if err != nil {
return AnalysisInterval
}
return interval
}