Skip to content

[WIP] Detect active deployments before provisioning#7288

Draft
Copilot wants to merge 12 commits intofix/deployment-active-conflictfrom
copilot/sub-pr-7251
Draft

[WIP] Detect active deployments before provisioning#7288
Copilot wants to merge 12 commits intofix/deployment-active-conflictfrom
copilot/sub-pr-7251

Conversation

Copy link
Contributor

Copilot AI commented Mar 24, 2026

Thanks for the feedback on #7251. I've created this new PR, which merges into #7251, to address your comment. I will work on the changes and keep this PR's description up to date as I make progress.

Original PR: #7251
Triggering comment (#7251 (comment)):

@copilot - will you check to ensure we have metrics coverage so we can see how often this error and fix occur after merging this change?


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

spboyer and others added 12 commits March 24, 2026 06:34
Before starting a Bicep deployment, check the target scope for
in-progress ARM deployments and wait for them to complete. This avoids
the DeploymentActive error that ARM returns after ~5 minutes when a
concurrent deployment is already running on the same resource group.

Changes:
- Add IsActiveDeploymentState() helper in azapi to classify provisioning
  states as active or terminal.
- Add ListActiveDeployments() to the infra.Scope interface and both
  ResourceGroupScope / SubscriptionScope implementations.
- Add waitForActiveDeployments() in the Bicep provider, called after
  preflight validation and before deployment submission. It polls until
  active deployments clear or a 30-minute timeout is reached.
- Add a DeploymentActive error suggestion rule to error_suggestions.yaml.
- Add unit tests for state classification, polling, timeout, error
  handling, and context cancellation.

Fixes #7248

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…per, refresh timeout names

- Fix 'range 200' compile error (not valid in all Go versions)
- Make DeploymentActive YAML rule scope-agnostic
- Extract filterActiveDeployments helper to deduplicate scope logic
- Refresh deployment names from latest poll on timeout message

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Move ListActiveDeployments to a standalone function instead of adding
it to the exported Scope interface. Adding methods to exported
interfaces is a breaking change for any external implementation
(including test mocks in CI).

The standalone infra.ListActiveDeployments(ctx, scope) function calls
scope.ListDeployments and filters for active states, achieving the
same result without widening the interface contract.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The agent rewrote the entire YAML file causing a 925-line diff that
broke CI tests. Reset to main and add only the DeploymentActive rule
(11 lines) as intended.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The deployment object returned by generateDeploymentObject embeds a
Scope that can be nil in test environments (e.g. mockedScope returns
an empty SubscriptionDeployment). Using scopeForTemplate resolves
the scope from the provider's configuration, avoiding nil panics
in existing tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

3 participants