cluster-api-provider-aws
cluster-api-provider-aws copied to clipboard
🐛: ec2/byoip: fix EIP leak when creating machine
What type of PR is this?
/kind bug
What this PR does / why we need it:
The instance creation flow is creating by default EIP to instances even if the BYO IP flow is set. BYO IPv4 creates and associates the EIP to instance after it is created, preventing paying for additional EIP (amazon-provided) when creating the instance when the BYO IPv4 Pool is defined to be used by the machine.
Furthermore, the fix provides additional checks to prevent duplicated EIP in the BYO IP reconciliation loop. The extra checks include running the EIP association many times, while the EIP is already associated, and failures in the log when running the EIP association prematurely - when the instance isn't ready, Eg ec2 in pending state.
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 #5038
Special notes for your reviewer:
Checklist:
- [ ] squashed commits
- [ ] includes documentation (N/A)
- [x] includes emojis
- [ ] adds unit tests
- [ ] adds or updates e2e tests
Release note:
fix duplicated/leaked EIP when using BYO IPv4 on Machines.