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

Panic due to division by zero in CalculateDesiredWeightOnAbortOrStableRollback #3814

Open
FredrikAugust opened this issue Aug 29, 2024 · 1 comment

Comments

@FredrikAugust
Copy link

desiredWeight := maxInt(0, weightutil.MaxTrafficWeight(c.rollout)-((weightutil.MaxTrafficWeight(c.rollout)*c.stableRS.Status.AvailableReplicas) / *c.rollout.Spec.Replicas))

Logs:

│ time="2024-08-29T14:26:36Z" level=error msg="Recovered from panic: runtime error: integer divide by zero\ngoroutine 489 [running]:\nruntime/debug.Stack()\n\t/usr/local/go/src/runtime/debug/stack.go:24 +0x5e\ngithub.com/argoproj/argo-rollouts/utils/controller.processNext │
│ WorkItem.func1.1.1()\n\t/go/src/github.com/argoproj/argo-rollouts/utils/controller/controller.go:151 +0x49\npanic({0x2c65f20?, 0x5358650?})\n\t/usr/local/go/src/runtime/panic.go:914 +0x21f\ngithub.com/argoproj/argo-rollouts/rollout.(*rolloutContext).calculateDesiredWeig │
│ htOnAbortOrStableRollback(0xc001e06000?)\n\t/go/src/github.com/argoproj/argo-rollouts/rollout/trafficrouting.go:314 +0xb1\ngithub.com/argoproj/argo-rollouts/rollout.(*rolloutContext).reconcileTrafficRouting(0xc001e16000)\n\t/go/src/github.com/argoproj/argo-rollouts/roll │
│ out/trafficrouting.go:181 +0x425\ngithub.com/argoproj/argo-rollouts/rollout.(*rolloutContext).rolloutCanary(0xc001e16000)\n\t/go/src/github.com/argoproj/argo-rollouts/rollout/canary.go:57 +0x1d3\ngithub.com/argoproj/argo-rollouts/rollout.(*rolloutContext).reconcile(0xc0 │
│ 01e16000)\n\t/go/src/github.com/argoproj/argo-rollouts/rollout/context.go:86 +0xd4\ngithub.com/argoproj/argo-rollouts/rollout.(*Controller).syncHandler(0xc0007d8e00, {0x3944730, 0xc0007efb30}, {0xc0015f0fd8, 0x12})\n\t/go/src/github.com/argoproj/argo-rollouts/rollout/co │
│ ntroller.go:437 +0x4d3\ngithub.com/argoproj/argo-rollouts/utils/controller.processNextWorkItem.func1.1()\n\t/go/src/github.com/argoproj/argo-rollouts/utils/controller/controller.go:155 +0x7d\ngithub.com/argoproj/argo-rollouts/utils/controller.processNextWorkItem.func1({ │
│ 0x39574b0?, 0xc00069e420}, {0x31bf658, 0x7}, 0xc001449e70, {0x3944730?, 0xc0007efb30}, 0xc00062dc20?, {0x2a9bfa0, 0xc000de27b0})\n\t/go/src/github.com/argoproj/argo-rollouts/utils/controller/controller.go:159 +0x3ed\ngithub.com/argoproj/argo-rollouts/utils/controller.pr │
│ ocessNextWorkItem({0x3944730, 0xc0007efb30}, {0x39574b0, 0xc00069e420}, {0x31bf658, 0x7}, 0x0?, 0xc0017ca490?)\n\t/go/src/github.com/argoproj/argo-rollouts/utils/controller/controller.go:178 +0xb5\ngithub.com/argoproj/argo-rollouts/utils/controller.RunWorker(...)\n\t/go │
│ /src/github.com/argoproj/argo-rollouts/utils/controller/controller.go:106\ngithub.com/argoproj/argo-rollouts/rollout.(*Controller).Run.func1()\n\t/go/src/github.com/argoproj/argo-rollouts/rollout/controller.go:358 +0xb2\nk8s.io/apimachinery/pkg/util/wait.BackoffUntil.fu │
│ nc1(0x30?)\n\t/go/pkg/mod/k8s.io/[email protected]/pkg/util/wait/backoff.go:226 +0x33\nk8s.io/apimachinery/pkg/util/wait.BackoffUntil(0x0?, {0x3912c00, 0xc0010e0f60}, 0x1, 0xc000dc4180)\n\t/go/pkg/mod/k8s.io/[email protected]/pkg/util/wait/backoff.go:227 +0xaf\nk8 │
│ s.io/apimachinery/pkg/util/wait.JitterUntil(0x0?, 0x3b9aca00, 0x0, 0x0?, 0x0?)\n\t/go/pkg/mod/k8s.io/[email protected]/pkg/util/wait/backoff.go:204 +0x7f\nk8s.io/apimachinery/pkg/util/wait.Until(0x0?, 0x0?, 0x0?)\n\t/go/pkg/mod/k8s.io/[email protected]/pkg/util/wa │
│ it/backoff.go:161 +0x1e\ncreated by github.com/argoproj/argo-rollouts/rollout.(*Controller).Run in goroutine 439\n\t/go/src/github.com/argoproj/argo-rollouts/rollout/controller.go:357 +0xa7\n" namespace=init rollout=init-tracking                                          │

Hi! I believe this line should have a check for if the rollout has 0 replicas to prevent a panic:)

@zimmertr
Copy link

Duplicate: #3686

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants