Delete stale primary HPAs when autoscalerRef is removed - #1965
Open
nedal87 wants to merge 1 commit into
Open
Conversation
Delete Flagger-managed primary HPAs after autoscalerRef is removed. Require the Canary controller owner and expected primary target. Keep discovery failures from blocking Canary reconciliation. Signed-off-by: Nedal Eskaf <nedaleskaif87@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Removing
spec.autoscalerReffrom a Canary leaves the generated primary HPAbehind. It continues scaling the primary Deployment after autoscaling was
intended to be disabled.
Fixes #1654. Related: #259.
Solution
When
autoscalerRefis absent, Flagger searches the Canary namespace for astale primary HPA and deletes it only when all of these checks pass:
-primary;<targetRef.name>-primary;No HPA is deleted based on its name alone. This addresses the ownership-safety
concern raised in #1030.
Successful cleanup is memoized per Canary UID, so Flagger performs one
namespace-scoped HPA list after startup or after
autoscalerRefis removed,rather than on every analysis tick. Failures are reported and retried without
blocking normal Canary reconciliation.
A pure Canary
UpdateFunccleanup would miss references removed while Flaggerwas unavailable and HPAs that were already stale before upgrading.
No RBAC changes are required; the upstream chart and kustomize manifests
already grant Flagger HPA list and delete permissions. This change is limited
to
autoscaling/v2HorizontalPodAutoscalers.Testing
Added tests for:
autoscalerRef;Validated with:
go test ./...pkg/canaryandpkg/controllergo vetandgo build ./...Canary deletion garbage collection