Skip to content

feat(w-m): fast-track azure vm deletion when resources are cascade-deleted - #8790

Merged
petemoore merged 1 commit into
mainfrom
feature/8161-azure-vm-cascade-stopping-capacity
Jun 23, 2026
Merged

feat(w-m): fast-track azure vm deletion when resources are cascade-deleted#8790
petemoore merged 1 commit into
mainfrom
feature/8161-azure-vm-cascade-stopping-capacity

Conversation

@lotas

@lotas lotas commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Since Azure supports fast resource removal with the VM (deleteOption: 'Delete') and our ARM templates are enforcing this, we could save some time by not trying to deprovision each resource manually as before.

We also cannot rely/control what template is used, so we have to check the actual VM model and NIC response from Azure when worker registers. Only after checking that and making sure all resources are "cascadable" we could short-circuit deprovision loop.

Deprovision now becomes: 1. delete VM. 2. if cascade exists, mark all done.
This would skip NIC/IP/Disks steps

Additionally we log new metric and log type to see how it performs.

This should reduce total number of STOPPING workers that are usuallly blocking worker-scanner-azure.

Fixes #8161 - instead of excluding stopping capacity from estimator, we just do this

…leted

Since Azure supports fast resource removal with the VM (`deleteOption:
'Delete'`) and our ARM templates are enforcing this, we could save some
time by not trying to deprovision each resource manually as before.

We also cannot rely/control what template is used, so we have to check
the actual VM model and NIC response from Azure when worker registers.
Only after checking that and making sure all resources are "cascadable"
we could short-circuit deprovision loop.

Deprovision now becomes: 1. delete VM. 2. if cascade exists, mark all
done.
This would skip NIC/IP/Disks steps

Additionally we log new metric and log type to see how it performs.

This should reduce total number of STOPPING workers that are usuallly
blocking worker-scanner-azure.
@lotas
lotas requested a review from a team as a code owner June 23, 2026 11:19
@lotas
lotas requested review from Eijebong, matt-boris and petemoore and removed request for a team June 23, 2026 11:19
@github-project-automation github-project-automation Bot moved this to Backlog / Inbox in TC intake board Jun 23, 2026
if (!vmDeleted || worker.providerData.vm.id) {
return;
}
const nicDeleted = await this.deprovisionResource({

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this part stays as is, it is just moved under if .. else { } block

@petemoore petemoore left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for adding all the tests! This looks pretty solid, the only thing I'm not sure about is how clean up works if deletes fail...

const teardownMode = useFastPath ? 'fast' : 'slow';

if (useFastPath) {
// Mark the cascaded resource records deleted as we trust cascade delete option

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thanks yarik! what happens if the deletes fail? is this a fire-and-forget or is there something that would later drop those resources if the deletes fail?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

so we do this check specifically to make sure that resources got "deleteOption: Delete"
And if all do, then it's on the Azure's resource manager to clean them up

And indeed, once we confirmed that vm is deleted, it might be the case that resources are still "present" on azure side, but I don't think we should worry about this (not at least here)

We had a long standing - #8113 to cover that gap

@petemoore petemoore left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks Yarik. This looks pretty robust, thanks for the extra tests, great job. :-)

@petemoore
petemoore merged commit e22ce54 into main Jun 23, 2026
76 checks passed
@petemoore
petemoore deleted the feature/8161-azure-vm-cascade-stopping-capacity branch June 23, 2026 14:34
@github-project-automation github-project-automation Bot moved this from Backlog / Inbox to Done in TC intake board Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Azure provider stopping capacity

2 participants