Skip to content

Commit d2cbd40

Browse files
authored
Merge pull request #240 from weaveworks/refactor
Refactor canary change detection and status
2 parents 559cbd0 + 3786a49 commit d2cbd40

File tree

17 files changed

+522
-137
lines changed

17 files changed

+522
-137
lines changed

artifacts/flagger/crd.yaml

+51
Original file line numberDiff line numberDiff line change
@@ -102,71 +102,122 @@ spec:
102102
canaryAnalysis:
103103
properties:
104104
interval:
105+
description: Canary schedule interval
105106
type: string
106107
pattern: "^[0-9]+(m|s)"
107108
iterations:
109+
description: Number of checks to run for A/B Testing and Blue/Green
108110
type: number
109111
threshold:
112+
description: Max number of failed checks before rollback
110113
type: number
111114
maxWeight:
115+
description: Max traffic percentage routed to canary
112116
type: number
113117
stepWeight:
118+
description: Canary incremental traffic percentage step
114119
type: number
115120
metrics:
121+
description: Prometheus query list for this canary
116122
type: array
117123
properties:
118124
items:
119125
type: object
120126
required: ['name', 'threshold']
121127
properties:
122128
name:
129+
description: Name of the Prometheus metric
123130
type: string
124131
interval:
132+
description: Interval of the promql query
125133
type: string
126134
pattern: "^[0-9]+(m|s)"
127135
threshold:
136+
description: Max scalar value accepted for this metric
128137
type: number
129138
query:
139+
description: Prometheus query
130140
type: string
131141
webhooks:
142+
description: Webhook list for this canary
132143
type: array
133144
properties:
134145
items:
135146
type: object
136147
required: ['name', 'url', 'timeout']
137148
properties:
138149
name:
150+
description: Name of the webhook
139151
type: string
140152
type:
153+
description: Type of the webhook pre, post or during rollout
141154
type: string
142155
enum:
143156
- ""
144157
- pre-rollout
145158
- rollout
146159
- post-rollout
147160
url:
161+
description: URL address of this webhook
148162
type: string
149163
format: url
150164
timeout:
165+
description: Request timeout for this webhook
151166
type: string
152167
pattern: "^[0-9]+(m|s)"
153168
status:
154169
properties:
155170
phase:
171+
description: Analysis phase of this canary
156172
type: string
157173
enum:
158174
- ""
175+
- Initializing
159176
- Initialized
160177
- Progressing
161178
- Succeeded
162179
- Failed
163180
canaryWeight:
181+
description: Traffic weight percentage routed to canary
164182
type: number
165183
failedChecks:
184+
description: Failed check count of the current canary analysis
166185
type: number
167186
iterations:
187+
description: Iteration count of the current canary analysis
168188
type: number
169189
lastAppliedSpec:
190+
description: LastAppliedSpec of this canary
170191
type: string
171192
lastTransitionTime:
193+
description: LastTransitionTime of this canary
194+
format: date-time
172195
type: string
196+
conditions:
197+
description: Status conditions of this canary
198+
type: array
199+
properties:
200+
items:
201+
type: object
202+
required: ['type', 'status', 'reason']
203+
properties:
204+
lastTransitionTime:
205+
description: LastTransitionTime of this condition
206+
format: date-time
207+
type: string
208+
lastUpdateTime:
209+
description: LastUpdateTime of this condition
210+
format: date-time
211+
type: string
212+
message:
213+
description: Message associated with this condition
214+
type: string
215+
reason:
216+
description: Reason for the current status of this condition
217+
type: string
218+
status:
219+
description: Status of this condition
220+
type: string
221+
type:
222+
description: Type of this condition
223+
type: string

charts/flagger/templates/crd.yaml

+51
Original file line numberDiff line numberDiff line change
@@ -103,72 +103,123 @@ spec:
103103
canaryAnalysis:
104104
properties:
105105
interval:
106+
description: Canary schedule interval
106107
type: string
107108
pattern: "^[0-9]+(m|s)"
108109
iterations:
110+
description: Number of checks to run for A/B Testing and Blue/Green
109111
type: number
110112
threshold:
113+
description: Max number of failed checks before rollback
111114
type: number
112115
maxWeight:
116+
description: Max traffic percentage routed to canary
113117
type: number
114118
stepWeight:
119+
description: Canary incremental traffic percentage step
115120
type: number
116121
metrics:
122+
description: Prometheus query list for this canary
117123
type: array
118124
properties:
119125
items:
120126
type: object
121127
required: ['name', 'threshold']
122128
properties:
123129
name:
130+
description: Name of the Prometheus metric
124131
type: string
125132
interval:
133+
description: Interval of the promql query
126134
type: string
127135
pattern: "^[0-9]+(m|s)"
128136
threshold:
137+
description: Max scalar value accepted for this metric
129138
type: number
130139
query:
140+
description: Prometheus query
131141
type: string
132142
webhooks:
143+
description: Webhook list for this canary
133144
type: array
134145
properties:
135146
items:
136147
type: object
137148
required: ['name', 'url', 'timeout']
138149
properties:
139150
name:
151+
description: Name of the webhook
140152
type: string
141153
type:
154+
description: Type of the webhook pre, post or during rollout
142155
type: string
143156
enum:
144157
- ""
145158
- pre-rollout
146159
- rollout
147160
- post-rollout
148161
url:
162+
description: URL address of this webhook
149163
type: string
150164
format: url
151165
timeout:
166+
description: Request timeout for this webhook
152167
type: string
153168
pattern: "^[0-9]+(m|s)"
154169
status:
155170
properties:
156171
phase:
172+
description: Analysis phase of this canary
157173
type: string
158174
enum:
159175
- ""
176+
- Initializing
160177
- Initialized
161178
- Progressing
162179
- Succeeded
163180
- Failed
164181
canaryWeight:
182+
description: Traffic weight percentage routed to canary
165183
type: number
166184
failedChecks:
185+
description: Failed check count of the current canary analysis
167186
type: number
168187
iterations:
188+
description: Iteration count of the current canary analysis
169189
type: number
170190
lastAppliedSpec:
191+
description: LastAppliedSpec of this canary
171192
type: string
172193
lastTransitionTime:
194+
description: LastTransitionTime of this canary
195+
format: date-time
173196
type: string
197+
conditions:
198+
description: Status conditions of this canary
199+
type: array
200+
properties:
201+
items:
202+
type: object
203+
required: ['type', 'status', 'reason']
204+
properties:
205+
lastTransitionTime:
206+
description: LastTransitionTime of this condition
207+
format: date-time
208+
type: string
209+
lastUpdateTime:
210+
description: LastUpdateTime of this condition
211+
format: date-time
212+
type: string
213+
message:
214+
description: Message associated with this condition
215+
type: string
216+
reason:
217+
description: Reason for the current status of this condition
218+
type: string
219+
status:
220+
description: Status of this condition
221+
type: string
222+
type:
223+
description: Type of this condition
224+
type: string
174225
{{- end }}

go.mod

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ require (
3030
github.com/mattn/go-isatty v0.0.7 // indirect
3131
github.com/mitchellh/go-homedir v1.1.0 // indirect
3232
github.com/mitchellh/go-testing-interface v1.0.0 // indirect
33+
github.com/mitchellh/hashstructure v1.0.0
34+
github.com/pkg/errors v0.8.1
3335
github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829
3436
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90 // indirect
3537
github.com/prometheus/common v0.3.0 // indirect

go.sum

+7
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,15 @@ github.com/appscode/jsonpatch v0.0.0-20190108182946-7c0e3b262f30/go.mod h1:4AJxU
3131
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
3232
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da h1:8GUt8eRujhVEGZFFEjBj46YV4rDjvGrNxb0KMWYkL2I=
3333
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
34+
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310 h1:BUAU3CGlLvorLI26FmByPp2eC2qla6E1Tw+scpcg/to=
3435
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
3536
github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
3637
github.com/avast/retry-go v2.2.0+incompatible h1:m+w7mVLWa/oKqX2xYqiEKQQkeGH8DDEXB/XnjS54Wyw=
3738
github.com/avast/retry-go v2.2.0+incompatible/go.mod h1:XtSnn+n/sHqQIpZ10K1qAevBhOOCWBLXXy3hyiqqBrY=
3839
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
3940
github.com/beorn7/perks v1.0.0 h1:HWo1m869IqiPhD389kmkxeTalrjNbbJTC8LXupb+sl0=
4041
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
42+
github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY=
4143
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
4244
github.com/bitly/go-simplejson v0.5.0/go.mod h1:cXHtHw4XUPsvGaxgjIAn8PhEWG9NfngEKAMDJEczWVA=
4345
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4=
@@ -80,6 +82,7 @@ github.com/evanphx/json-patch v4.1.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLi
8082
github.com/evanphx/json-patch v4.2.0+incompatible h1:fUDGZCv/7iAN7u0puUVhvKCcsR6vRfwrJatElLBEf0I=
8183
github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
8284
github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d/go.mod h1:ZZMPRZwes7CROmyNKgQzC3XPs6L/G2EJLHddWejkmf4=
85+
github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
8386
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
8487
github.com/fgrosse/zaptest v1.1.0 h1:sK9hP0/xBoNX5qfFo3KWFluDXfc809APomI1QXuYELA=
8588
github.com/fgrosse/zaptest v1.1.0/go.mod h1:vMnRSul6kW7kIUXZgnZZcDwyTn8k49ODfAULL8nmL5w=
@@ -192,6 +195,7 @@ github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa
192195
github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU=
193196
github.com/hashicorp/go-sockaddr v1.0.2 h1:ztczhD1jLxIRjVejw8gFomI1BQZOe2WoVOu0SyteCQc=
194197
github.com/hashicorp/go-sockaddr v1.0.2/go.mod h1:rB4wwRAUzs07qva3c5SdrY/NEtAUjGlgmH/UkBUC97A=
198+
github.com/hashicorp/go-syslog v1.0.0 h1:KaodqZuhUoZereWVIYmpUgZysurB1kBLX2j0MwMrUAE=
195199
github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4=
196200
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
197201
github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE=
@@ -202,6 +206,7 @@ github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+
202206
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
203207
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
204208
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
209+
github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y=
205210
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
206211
github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ=
207212
github.com/hashicorp/memberlist v0.1.3 h1:EmmoJme1matNzb+hMpDuR/0sbJSUisxyqBGG676r31M=
@@ -265,6 +270,7 @@ github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5
265270
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
266271
github.com/miekg/dns v1.0.14 h1:9jZdLNd/P4+SfEJ0TNyxYpsK8N4GtfylBLqtbYN1sbA=
267272
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
273+
github.com/mitchellh/cli v1.0.0 h1:iGBIsUe3+HZ/AD/Vd7DErOt5sU9fa8Uj7A2s1aggv1Y=
268274
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
269275
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
270276
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
@@ -315,6 +321,7 @@ github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
315321
github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
316322
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
317323
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
324+
github.com/posener/complete v1.1.1 h1:ccV59UEOTzVDnDUEFdT95ZzHVZ+5+158q8+SJb2QV5w=
318325
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
319326
github.com/prometheus/client_golang v0.8.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
320327
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=

0 commit comments

Comments
 (0)