Handle Azure NIC reservation during VM deletion#359
Conversation
da29daa to
a1a26d4
Compare
|
I think proactively detaching NICs from VMs during cleanup could be a more robust approach, as it would help avoid orphaned resources and also allow for better parallelization. If this sounds like a preferable alternative, I’d be happy to explore its feasibility. (ref) |
a1a26d4 to
38098d5
Compare
There was a problem hiding this comment.
Pull request overview
This PR improves Azure resource cleanup reliability by handling the transient NicReservedForAnotherVm condition that can occur after VM deletion or failed provisioning, which otherwise can leave orphaned NICs (and consequently Public IPs).
Changes:
- Adds a
maxRetryDurationconstant (180s) used to wait out Azure’s NIC reservation window. - Updates
DeleteNetworkInterfaceIfExiststo detect the NIC-reserved error, wait, and retry NIC deletion once, while respecting context cancellation.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
jiaqiluo
left a comment
There was a problem hiding this comment.
Left one comment. Also, please review the Copilot comments.
FYI, this repo is not branched for Rancher release lines, so you might need to backport the changes to other lines.
38098d5 to
c30c4e7
Compare
c30c4e7 to
b8cf1bd
Compare
Issue: rancher/rancher#47903
Azure may temporarily retain NIC reservations after VM deletion or failed VM provisioning, causing cleanup to fail with the
NicReservedForAnotherVmerror.This commit:
This improves cleanup reliability by preventing orphaned NICs and, consequently, orphaned Public IPs.
Test Validation:
To Reproducesection on the issue.