cluster-api-provider-azure
cluster-api-provider-azure copied to clipboard
Acknowledge all ASO resource types before creating
What type of PR is this? /kind bug
What this PR does / why we need it:
This PR fixes a potential issue where if CAPZ creates an ASO resource defined by an ASOAPI resource, then crashes or otherwise fails to record that resource in the PATCH to the CAPZ resource status at the end of the reconciliation loop, a quickly following delete of the CAPZ resource (or removing that ASO resource from spec) will not know to also delete that ASO resource if it's not recorded in status.
This change makes CAPZ record each ASO resource group/version/kind in a sigs.k8s.io/cluster-api-provider-azure-owned-aso-kinds annotation and send those changes to the API server before continuing to actually create resources of that type. This way, no matter when a CAPZ ASO API resource is deleted, CAPZ can rely on any ASO resource type that needs to be deleted to be in that annotation.
Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #
Special notes for your reviewer:
I initially split this into a couple commits in case that's easier to review: one for the functional change and one to refactor things a bit.
TODOs:
- [ ] squashed commits
- [ ] includes documentation
- [ ] adds unit tests
- [ ] cherry-pick candidate
Release note:
ASOAPI: Fixed a possible bug that could leave ASO resources dangling when they should be deleted.