Introduce logic to clean up primary HPA
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
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.
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
Codecov Report
Merging #1030 (d24e413) into main (01d4780) will increase coverage by
0.02%. The diff coverage is70.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
@@ 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 dataPowered by Codecov. Last update 01d4780...b6b5ade. Read the comment docs.
@stefanprodan curious if you had any feedback on this approach
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 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