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

fix(controller): stuck in scale event after canary service switch delay. Fixes #3412 #3413

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
9 changes: 8 additions & 1 deletion rollout/canary.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,15 @@
annotationedRSs := int32(0)
for _, targetRS := range oldRSs {
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.
// We might get here if user interrupted an update in order to move back to stable or if the controller could not switch the canary service to the new RS.
c.log.Infof("Skip scale down of older RS '%s': still referenced", targetRS.Name)

// If the replicaset is still referenced, the controller should scale it
_, desiredRSReplicaCount := replicasetutil.CalculateReplicaCountsForTrafficRoutedCanary(c.rollout, c.rollout.Status.Canary.Weights)
_, _, err = c.scaleReplicaSetAndRecordEvent(targetRS, desiredRSReplicaCount)
if err != nil {
c.log.Errorf("Failed to scale old RS '%s': %v", targetRS.Name, err)

Check warning on line 195 in rollout/canary.go

View check run for this annotation

Codecov / codecov/patch

rollout/canary.go#L195

Added line #L195 was not covered by tests
}
continue
}
if maxScaleDown <= 0 {
Expand Down
18 changes: 18 additions & 0 deletions test/e2e/canary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,24 @@ spec:
ExpectCanaryStablePodCount(2, 4)
}

func (s *CanarySuite) TestRolloutScalingWithServiceSwitchDelay() {
s.Given().
RolloutObjects(`@functional/alb-canary-rollout-with-delay.yaml`).
When().
ApplyManifests().
WaitForRolloutStatus("Healthy").
UpdateSpec().
WaitForRolloutStatus("Paused").
UpdateSpec().
Sleep(1*time.Second).
ScaleRollout(3).
WaitForRolloutStatus("Paused").
Then().
ExpectRevisionPodCount("1", 3).
ExpectRevisionPodCount("2", 0).
ExpectRevisionPodCount("3", 1)
}

// TestReduceWeightAndHonorMaxUnavailable verifies we honor maxUnavailable when decreasing weight or aborting
func (s *CanarySuite) TestReduceWeightAndHonorMaxUnavailable() {
s.Given().
Expand Down
104 changes: 104 additions & 0 deletions test/e2e/functional/alb-canary-rollout-with-delay.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
apiVersion: v1
kind: Service
metadata:
name: alb-canary-with-delay-root
spec:
type: NodePort
ports:
- port: 80
targetPort: http
protocol: TCP
name: http
selector:
app: alb-canary-with-delay
---
apiVersion: v1
kind: Service
metadata:
name: alb-canary-with-delay-desired
spec:
type: NodePort
ports:
- port: 80
targetPort: http
protocol: TCP
name: http
selector:
app: alb-canary-with-delay
---
apiVersion: v1
kind: Service
metadata:
name: alb-canary-with-delay-stable
spec:
type: NodePort
ports:
- port: 80
targetPort: http
protocol: TCP
name: http
selector:
app: alb-canary-with-delay
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: alb-canary-with-delay-ingress
annotations:
kubernetes.io/ingress.class: alb
spec:
rules:
- http:
paths:
- path: /*
pathType: ImplementationSpecific
backend:
service:
name: alb-canary-with-delay-root
port:
name: use-annotation
---
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: alb-canary-with-delay
spec:
selector:
matchLabels:
app: alb-canary-with-delay
template:
metadata:
labels:
app: alb-canary-with-delay
spec:
containers:
- name: alb-canary-with-delay
lifecycle:
postStart:
exec:
command:
- sleep
- "2"
image: nginx:1.19-alpine
ports:
- name: http
containerPort: 80
protocol: TCP
resources:
requests:
memory: 16Mi
cpu: 5m
strategy:
canary:
canaryService: alb-canary-with-delay-desired
stableService: alb-canary-with-delay-stable
trafficRouting:
alb:
ingress: alb-canary-with-delay-ingress
rootService: alb-canary-with-delay-root
servicePort: 80
steps:
- setWeight: 10
- pause: {duration: 5s}
- setWeight: 20
- pause: {duration: 5s}
Loading