Division-by-zero in Horizontal Workload Autoscaler #128847
Labels
kind/bug
Categorizes issue or PR as related to a bug.
needs-triage
Indicates an issue or PR lacks a `triage/foo` label and requires one.
sig/autoscaling
Categorizes an issue or PR as relevant to SIG Autoscaling.
Which component are you using?:
Horizontal workload autoscaler.
What version of the component are you using?:
Not relevant.
What k8s version are you using (
kubectl version
)?:kubectl version
OutputWhat environment is this in?:
Not relevant.
What did you expect to happen?:
When the horizontal autoscaler computes the expected number of replicas, it uses the following formula:
(This formula (or a variation of it) appears a couple of times in this file.)
It's not impossible that
statusReplicas
(i.e. thestatus.replicas
field of the/scale
subresource) equals zero (e.g. if a user kills pods), leading to a division by zero.The Golang spec allows divisions by zero to trigger traps, although most implementations would return +Inf (which leads to the correct behaviour) or NaN (if
usage == 0.
, in which case the func would return a negative number of replicas).What happened instead?:
This problem could lead to a panic, or an incorrect behaviour. This could only happen as a result of a race condition, and in the unlikely situation where
status.replicas == 0
. I'm not sure of its practical significance.How to reproduce it (as minimally and precisely as possible):
This issue only appears as a result of a race condition. I couldn't produce it.
The text was updated successfully, but these errors were encountered: