Skip to content

Commit 6fb2bcc

Browse files
fix: Abort rollout doesn't remove all canary pods for setCanaryScale (argoproj#1352)
Signed-off-by: Chinmoy Samant <[email protected]>
1 parent d2753c2 commit 6fb2bcc

File tree

3 files changed

+123
-0
lines changed

3 files changed

+123
-0
lines changed
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: istio-host-split-canary
5+
spec:
6+
ports:
7+
- port: 80
8+
targetPort: http
9+
protocol: TCP
10+
name: http
11+
selector:
12+
app: istio-host-split
13+
14+
---
15+
apiVersion: v1
16+
kind: Service
17+
metadata:
18+
name: istio-host-split-stable
19+
spec:
20+
ports:
21+
- port: 80
22+
targetPort: http
23+
protocol: TCP
24+
name: http
25+
selector:
26+
app: istio-host-split
27+
28+
---
29+
apiVersion: networking.istio.io/v1alpha3
30+
kind: VirtualService
31+
metadata:
32+
name: istio-host-split-vsvc
33+
spec:
34+
hosts:
35+
- istio-host-split
36+
http:
37+
- name: primary
38+
route:
39+
- destination:
40+
host: istio-host-split-stable
41+
weight: 100
42+
- destination:
43+
host: istio-host-split-canary
44+
weight: 0
45+
46+
---
47+
apiVersion: argoproj.io/v1alpha1
48+
kind: Rollout
49+
metadata:
50+
name: istio-host-split
51+
spec:
52+
replicas: 5
53+
strategy:
54+
canary:
55+
canaryService: istio-host-split-canary
56+
stableService: istio-host-split-stable
57+
trafficRouting:
58+
istio:
59+
virtualService:
60+
name: istio-host-split-vsvc
61+
routes:
62+
- primary
63+
steps:
64+
- setCanaryScale:
65+
replicas: 2
66+
- setWeight: 20
67+
- pause: {}
68+
- setCanaryScale:
69+
replicas: 4
70+
- setWeight: 40
71+
- pause: {}
72+
selector:
73+
matchLabels:
74+
app: istio-host-split
75+
template:
76+
metadata:
77+
labels:
78+
app: istio-host-split
79+
spec:
80+
containers:
81+
- name: istio-host-split
82+
image: nginx:1.19-alpine
83+
ports:
84+
- name: http
85+
containerPort: 80
86+
protocol: TCP
87+
resources:
88+
requests:
89+
memory: 16Mi
90+
cpu: 5m

test/e2e/istio_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,3 +224,32 @@ func (s *IstioSuite) TestIstioAbortUpdate() {
224224
Then().
225225
ExpectRevisionPodCount("2", 1)
226226
}
227+
228+
func (s *IstioSuite) TestIstioAbortUpdateDeleteAllCanaryPods() {
229+
s.Given().
230+
RolloutObjects("@istio/istio-rollout-abort-delete-all-canary-pods.yaml").
231+
When().
232+
ApplyManifests().
233+
WaitForRolloutStatus("Healthy").
234+
Then().
235+
When().
236+
UpdateSpec().
237+
WaitForRolloutStatus("Paused").
238+
Then().
239+
ExpectRevisionPodCount("2", 2).
240+
When().
241+
PromoteRollout().
242+
WaitForRolloutStatus("Paused").
243+
Then().
244+
When().
245+
PromoteRollout().
246+
WaitForRolloutStatus("Paused").
247+
Then().
248+
ExpectRevisionPodCount("2", 4).
249+
When().
250+
AbortRollout().
251+
WaitForRolloutStatus("Degraded").
252+
Then().
253+
ExpectRevisionPodCount("2", 0).
254+
ExpectRevisionPodCount("1", 5)
255+
}

utils/replicaset/canary.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,10 @@ func GetCurrentSetWeight(rollout *v1alpha1.Rollout) int32 {
331331
// TrafficRouting is required to be set for SetCanaryScale to be applicable.
332332
// If MatchTrafficWeight is set after a previous SetCanaryScale step, it will likewise be ignored.
333333
func UseSetCanaryScale(rollout *v1alpha1.Rollout) *v1alpha1.SetCanaryScale {
334+
// Return nil when rollout is aborted
335+
if rollout.Status.Abort {
336+
return nil
337+
}
334338
currentStep, currentStepIndex := GetCurrentCanaryStep(rollout)
335339
if currentStep == nil {
336340
return nil

0 commit comments

Comments
 (0)