Skip to content

Fix the Destroy workflow: avoid the Azure CLI crash - #178

Merged
jaredthivener merged 1 commit into
mainfrom
destroy-without-the-cli-bug
Oct 7, 2026
Merged

jaredthivener merged 1 commit into
mainfrom
destroy-without-the-cli-bug

Conversation

@jaredthivener

Copy link
Copy Markdown
Owner

The Destroy workflow failed on its first real run (run), in the step I added in #173 and had not been able to test. Nothing was deleted: the next step, which deletes the resource group, was skipped.

Cause

az monitor log-analytics workspace delete --force crashed inside the Azure CLI before it sent anything:

ERROR: deadlock detected by _ModuleLock('requests.structures')

This is Azure/azure-cli#33996, open, with a fix proposed but not merged. On GitHub's Ubuntu runners the CLI bundles Python 3.14. Its long-running commands create their credential on a worker thread, and that thread's import of requests intermittently collides with the main thread's. Others report it for az network vnet create, az network nsg rule create and az lab create; rerunning sometimes passes.

Change

  • The step sends the same permanent delete as the REST call Microsoft documents (DELETE …?force=true), through az rest. az rest does its work on one thread, so the collision cannot happen there.
  • It then waits until the workspace is gone before the group is deleted.
  • infra/README.md: the manual teardown uses the same call. The Azure CLI on a Mac from Homebrew also runs on Python 3.14.

Checked

Ran the step's script, as written in the workflow, against a scratch workspace in a scratch resource group: the workspace was gone 13 seconds later and was not in the recycle bin, so the delete is permanent.

Not checked

  • That it avoids the crash on a runner. The bug is intermittent, so no single run proves it; the argument is that az rest has no second thread.
  • The other commands in the workflows. az group delete --no-wait and the Deploy workflow's az aks start go through a different part of the CLI, which makes its first request on the main thread. Neither has failed so far.

🤖 Generated with Claude Code

The Destroy workflow failed in the step added by #173. On GitHub's
runners, `az monitor log-analytics workspace delete` crashed inside the
Azure CLI before sending anything:

    deadlock detected by _ModuleLock('requests.structures')

That is Azure/azure-cli#33996, open and unfixed: with the CLI's bundled
Python 3.14, long-running commands create their credential on a worker
thread, and its import of `requests` intermittently collides with the
main thread's.

The step now sends the same permanent delete as a REST call through
`az rest`, which has no worker thread, and waits for the workspace to
be gone before the group is deleted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jaredthivener
jaredthivener merged commit 1c99926 into main Oct 7, 2026
8 checks passed
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.

1 participant