Skip to content

Handle Azure NIC reservation during VM deletion#359

Open
apoorvajagtap wants to merge 1 commit intorancher:masterfrom
apoorvajagtap:8916-azureresources
Open

Handle Azure NIC reservation during VM deletion#359
apoorvajagtap wants to merge 1 commit intorancher:masterfrom
apoorvajagtap:8916-azureresources

Conversation

@apoorvajagtap
Copy link

@apoorvajagtap apoorvajagtap commented Feb 9, 2026

Azure may temporarily retain NIC reservations after VM deletion or failed VM provisioning, causing cleanup to fail with the NicReservedForAnotherVm error.

This commit:

  • Adds retry logic to DeleteNetworkInterfaceIfExists when NICs are temporarily reserved
  • Waits for maxRetryDuration (180 seconds) before re-attempting deletion
  • Handles context cancellation during the wait period

This improves cleanup reliability by preventing orphaned NICs and, consequently, orphaned Public IPs.

@apoorvajagtap apoorvajagtap marked this pull request as draft February 9, 2026 10:27
@apoorvajagtap apoorvajagtap force-pushed the 8916-azureresources branch 4 times, most recently from da29daa to a1a26d4 Compare February 9, 2026 18:49
@apoorvajagtap
Copy link
Author

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)

@apoorvajagtap apoorvajagtap marked this pull request as ready for review February 9, 2026 19:02
@apoorvajagtap apoorvajagtap changed the title [WIP] Handle Azure NIC reservation during VM deletion Handle Azure NIC reservation during VM deletion Feb 9, 2026
@apoorvajagtap apoorvajagtap requested review from a team and jakefhyde February 9, 2026 19:06
Copy link

@jakefhyde jakefhyde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 nit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants