Repository navigation
fix(keda): keep the autoscaled replica count on redeploy - #4089
Elvand-Lie wants to merge 1 commit into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Elvand-Lie The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @Elvand-Lie. Thanks for your PR. I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with Tip We noticed you've done this a few times! Consider joining the org to skip this step and gain Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/ok-to-test |
|
Keeping the HPA's count on redeploy seems obviously right to me. Needs a rebase, but I ran this against Two things from an adversarial AI review came up (both nonblocking and FYI):
Rebase and we can merge. |
KEDA's HPA owns the live replica count, but redeploying replaces it with scale.min and can remove capacity under load. Preserve the count within new bounds while raw keeps its fixed count. Assisted-by: Codex (gpt-6.1-sol) Signed-off-by: Elvand Lie Nababan <elvandlie@gmail.com>
66c9290 to
525c0aa
Compare
Changes
kedadeployer no longer resets its replica count. The raw deployer, whichkedaembeds, replaces the Deployment on every update withspec.replicasset tomax(1, scale.min). KEDA's HPA owns that field, so a function the HPA had scaled to 6 replicas dropped to 1 on redeploy, and pods serving traffic were terminated until the HPA scaled it back up.kedadeployer now keeps the live replica count, raised toscale.min(at least 1) and lowered to an explicitscale.max. This follows the existingpreserveDeploymentSelectorpattern for cluster-owned Deployment state. HTTP and Kafka triggers both go through it.rawdeployer is unchanged. Its documented contract is a fixed replica count, soscale.minstays authoritative there. Akedafunction scaled to zero is still started at one replica on redeploy, as before./kind bug
There is no issue for this. The Kubernetes HPA docs describe the failure: while an HPA is active, applying an object that sets
spec.replicas"will instruct Kubernetes to scale the current number of Pods to the value of thespec.replicaskey".Testing
TestDeploy_ReplicasOnRedeployruns the fullkedaDeploy(HTTP and Kafka triggers) against a fake Kubernetes API server and checks the replica count sent in the Deployment update. Onmain, the live count, Kafka andscale.maxcases fail withreplicas = 1. The scale from zero, raisedscale.minandrawcases pass on both, as controls.Test_preserveAutoscaledReplicascovers the bounds directly.go test -race ./pkg/keda/ ./pkg/k8s/andgo vetpass locally, apart from two existingpkg/k8stests that need a reachable cluster. Not run: an end to end test on a cluster with KEDA installed.Release Note
Docs