Skip to content

Commit

Permalink
fix: stuck rollout when rollout is paused
Browse files Browse the repository at this point in the history
Signed-off-by: asingh51 <[email protected]>
  • Loading branch information
asingh51 committed Feb 7, 2024
1 parent f305342 commit 7bb1f84
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rollout/canary.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func (c *rolloutContext) scaleDownOldReplicaSetsForCanary(oldRSs []*appsv1.Repli

annotationedRSs := int32(0)
for _, targetRS := range oldRSs {
if c.isReplicaSetReferenced(targetRS) {
if c.rollout.Spec.Strategy.Canary.TrafficRouting != nil && c.isReplicaSetReferenced(targetRS) {
// We might get here if user interrupted an an update in order to move back to stable.
c.log.Infof("Skip scale down of older RS '%s': still referenced", targetRS.Name)
continue
Expand Down
17 changes: 17 additions & 0 deletions test/e2e/canary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,23 @@ func (s *CanarySuite) TestCanaryScaleDownOnAbortNoTrafficRouting() {
ExpectRevisionPodCount("2", 0)
}

func (s *CanarySuite) TestCanaryWhenRolloutPaused() {
s.Given().
HealthyRollout(`@functional/canary-deploy-new-rev-on-paused-rollout.yaml`).
When().
UpdateSpec(). // update to revision 2
WaitForRolloutStatus("Paused").
UpdateSpec(). // update to revision 3
WaitForRolloutStatus("Healthy").
Then().
// Expect that the canary service selector has been moved back to stable
ExpectServiceSelector("canary-next-canary", map[string]string{"app": "canary-next-canary", "rollouts-pod-template-hash": "66597877b7"}, false).
When().
Sleep(3*time.Second).
Then().
ExpectRevisionPodCount("2", 0)
}

func (s *CanarySuite) TestCanaryUnScaleDownOnAbort() {
s.Given().
HealthyRollout(`@functional/canary-unscaledownonabort.yaml`).
Expand Down
91 changes: 91 additions & 0 deletions test/e2e/functional/canary-deploy-new-rev-on-paused-rollout.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
apiVersion: v1
kind: Service
metadata:
name: canary-next-root
spec:
type: NodePort
ports:
- port: 80
targetPort: http
protocol: TCP
name: http
selector:
app: canary-next
---
apiVersion: v1
kind: Service
metadata:
name: canary-next-canary
spec:
type: NodePort
ports:
- port: 80
targetPort: http
protocol: TCP
name: http
selector:
app: canary-next
---
apiVersion: v1
kind: Service
metadata:
name: canary-next-stable
spec:
type: NodePort
ports:
- port: 80
targetPort: http
protocol: TCP
name: http
selector:
app: canary-next
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: canary-next-ingress
annotations:
kubernetes.io/ingress.class: alb
spec:
rules:
- http:
paths:
- path: /*
pathType: Prefix
backend:
service:
name: canary-next-root
port:
name: use-annotation
---
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: canary-scaledownd-on-abort
spec:
selector:
matchLabels:
app: canary-next
template:
metadata:
labels:
app: canary-next
spec:
containers:
- name: canary-next
image: nginx:1.19-alpine
ports:
- name: http
containerPort: 80
protocol: TCP
resources:
requests:
memory: 16Mi
cpu: 5m
strategy:
canary:
canaryService: canary-next-canary
stableService: canary-next-stable
steps:
- setWeight: 50
- pause: {}

0 comments on commit 7bb1f84

Please sign in to comment.