flagger icon indicating copy to clipboard operation
flagger copied to clipboard

Introduce logic to clean up primary HPA

Open ta924 opened this issue 4 years ago • 5 comments

This PR addresses logic to clean up primary HPA created by Flagger during promotion. If the autoScalerRef is removed and the primary HPA is present the promotion logic will remove the HPA.

Signed-off-by: Tanner Altares [email protected]

#259

ta924 avatar Oct 07 '21 21:10 ta924

We can't delete objects not created by Flagger. Many users have their own HPA setup outside the canary, this will wipe their auto scalers.

stefanprodan avatar Oct 08 '21 08:10 stefanprodan

I do agree if users had the same naming convention that would wipe out the HPA. I could also look at the metadata for owner reference and ensure it is owned by the Flagger operator before deletion

ta924 avatar Oct 08 '21 12:10 ta924

Codecov Report

Merging #1030 (d24e413) into main (01d4780) will increase coverage by 0.02%. The diff coverage is 70.00%.

:exclamation: Current head d24e413 differs from pull request most recent head b6b5ade. Consider uploading reports for the commit b6b5ade to get more accurate results Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1030      +/-   ##
==========================================
+ Coverage   56.88%   56.90%   +0.02%     
==========================================
  Files          76       76              
  Lines        6093     6103      +10     
==========================================
+ Hits         3466     3473       +7     
- Misses       2102     2104       +2     
- Partials      525      526       +1     
Impacted Files Coverage Δ
pkg/canary/deployment_controller.go 65.21% <70.00%> (+0.17%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 01d4780...b6b5ade. Read the comment docs.

codecov-commenter avatar Oct 11 '21 18:10 codecov-commenter

@stefanprodan curious if you had any feedback on this approach

ta924 avatar Oct 26 '21 16:10 ta924

Any updates on this? Why can't you rely on ownerReference being set? Seems to me that the logic should be leave it alone if no ownerReference is set and delete it if owned by the canary, assuming autoscalerref is unset (like implemented now)

oistein avatar Aug 19 '22 06:08 oistein

@oistein The PR is very old at this point, but the situation (if recall correctly) is if autoscalerRef was populated on the initial creation of the canary the primary HPA is created. If at some point the autoscalerRef is removed, for example user decides to define their own HPAs and not let Flagger manage those, the HPA would never be cleaned up. The ownerReference would only kick in if the canary was deleted, in this scenario the canary is not deleted. Instead the user is switching from Flagger managed HPAs to self managed HPAs.

This may not be the scenario in the latest versions

ta924 avatar Apr 05 '23 20:04 ta924