crane icon indicating copy to clipboard operation
crane copied to clipboard

EHPA cron can't scale to specified replicas,because hpa within a globally-configurable tolerance, 0.1 by default

Open chenshiwei-io opened this issue 2 years ago • 2 comments

Describe the bug The Kubernetes Horizontal Pod Autoscaler (HPA) has a default tolerance of 0.1. In EHPA, the cron-based scaling may not scale up or down to the desired number of replicas. For example, if the scheduled scaling is set to 24 replicas but it only scales up to 22, the calculation becomes 24/22 = 1.09. Since 0.09 falls within the tolerance range, it stops further scaling.

  • cron about code: https://github.com/gocrane/crane/blob/2a3f5ede0af001f54fb127c736dad650839b90e9/pkg/controller/ehpa/hpa.go#L307

  • globally-configurable tolerance: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/

Reproduce steps

Expected behavior

Screenshots

Environment (please complete the following information):

  • K8S Version: [e.g. 1.19]
  • Crane Version: [e.g. 0.1.0]
  • Browser [e.g. chrome, safari]

chenshiwei-io avatar Jul 18 '23 05:07 chenshiwei-io

emm.. indeed. @mfanjie any idea?

qmhu avatar Jul 19 '23 08:07 qmhu

In my opinion, if the tolerance is set and it is really needed, there is no requirement for the specific number of instances (22 or 24 is fine). So we don't need to change it, just doc it. In other scenarios, a precise number of instances is really needed, we can set specficReplicas based on cron rules. At this time, because a precise number of instances is required, the feature provided by cronHPA that can work together with cron rules and other indicators is no longer needed.

We can provide an option in cron to indicate whether we need to strictly follow cron rules. @qmhu

whitebear009 avatar Dec 28 '23 06:12 whitebear009