Repository navigation
fix(azure): deploy to a second region without re-creating groups - #86
autoidm-jon wants to merge 5 commits into
Conversation
Bugbot is paused — on-demand spend limit reachedBugbot uses usage-based billing for this team and has hit its on-demand spend limit. A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue. |
|
PR tier:
A changed diff is scored again. Job log: https://github.com/AutoIDM/pdt/actions/runs/37006898248 |
9c24ec7 to
774b1c7
Compare
|
PR tier:
A changed diff is scored again. Job log: https://github.com/AutoIDM/pdt/actions/runs/38892821448 |
The test fails: ensure_group_and_vault, ensure_shared_group, and ensure_store send az group create with the new region for groups that already exist in the first region. Azure refuses that call with InvalidResourceGroupLocation. Refs #77 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`az group create` on an existing group with another location fails with InvalidResourceGroupLocation, so a deploy to a second region stopped at the first group it reconciled. A group's location is only where its metadata lives, and its resources may be in any region, so an existing group is used as it is. Refs #77 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
774b1c7 to
06f638c
Compare
A single pdt-logs workspace sat in the region of the first deploy, so a second region's environment sent its logs across regions. Each region now gets pdt-logs-<region>. An existing environment keeps the workspace it already logs to, and logs are read from the workspace the environment names, so subscriptions set up with pdt-logs keep working. Destroy deletes a region's workspace with its environment when pdt-shared stays for other regions. Refs #77 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`az containerapp job update` cannot change a job's environment, so a deploy after a region change updated the job where it was, reported an update, and locked an environment the job never used. Deploy now stops before the plan and says how to keep the job or move it. Refs #77 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
06f638c to
96a54ee
Compare
|
Goal: an app deploys to an additional Azure region without an InvalidResourceGroupLocation error, with a Log Analytics workspace for each region. Reviewer: Cursor
Conflict resolutions in this rebase (unchanged from the review):
Checks that passed at 96a54ee: |
|
PR tier:
A changed diff is scored again. Job log: https://github.com/AutoIDM/pdt/actions/runs/41847620266 |
Why
A deploy to a second Azure region failed at the first group step. Deploy sent
az group create --location <new region>forpdt-sharedandpdton every run. Azure refuses that call for a group that exists in another region (InvalidResourceGroupLocation). A group's location is only where Azure keeps the group's metadata. Microsoft Learn says "the resources in a resource group can be located in different regions than the resource group", so pdt does not need a group for each region. It must stop re-creating groups that exist.Once the groups pass, two more problems show. The shared
pdt-logsworkspace takes the logs of every region, so a new region's logs cross to the first region. And an app whose region changed gets its job updated in the old region, becauseaz containerapp job updatecannot change a job's environment.Scope
deploy_azure.ensure_groupcreates a group only whenaz group showfinds none.ensure_group_and_vault(pdt),ensure_environment(pdt-shared), andensure_store(pdt-data) call it.ensure_shared_groupis gone.pdt-logs-<region>, next to the environmentpdt-<region>.ensure_environmentreturns early for an existing environment, so an environment that logs to the oldpdt-logskeeps it. The plan shows a workspace line only when it creates the environment.log_queryreads the workspace customer id from the environment (properties.appLogsConfiguration.logAnalyticsConfiguration.customerId), not from a workspace name. This works forpdt-logs,pdt-logs-<region>, and a user's own environment.--force, no soft delete) when it releases that region's environment and other regions keeppdt-shared.Releasehas a newworkspacefield.deploystops before the plan when the app's job exists in another region. The message names both regions and the destroy and deploy steps to move the job.deploy_azure_container_appsdocstring describe one environment and one workspace per region.Out of scope, see #33: one data store for each region, and a real move of a job to a new region. Google Cloud and AWS behave the same way for both, so each needs a change on every provider.
Tradeoffs
pdt-logsworkspace stays untilpdt-sharedis deleted. It serves only the first region's environment, because a second region could not deploy before this change.PDT_AZURE_LOG_WORKSPACEstill names one workspace for every region. Destroy of one region could then delete a workspace that another region uses. No default setup sets that variable.Blast Radius
Azure deploy, destroy,
pdt runs, andpdt logs. A single-region project sees one change: deploy no longer re-sendsaz group createfor its groups, which also stops that call from replacing tags a user put on the group. New regions getpdt-logs-<region>. Google Cloud and AWS code does not change.Verification
tests/test_azure_second_region.pycame first and failed onorigin/dev: 3 failed, 773 passed. The group commit makes it pass. The full suite has 782 passed at the head.ruff check src testspasses.InvalidResourceGroupLocationfor a create in a second region. A managed identity inwestus2inside theeastus2group worked. The group is deleted.pdt-examples:pdt runs hello-worldandpdt logs hello-worldwith the new code read theeastus2runs and the log lineHello, world!through the environment's customer id. That id is the id of the oldpdt-logsworkspace.region: centralus,pdt deploy hello-worldonorigin/devprinted a plan that reusedpdt-logs, createdpdt-centraluswith a lock, and said "update Container Apps Job pdt-hello-world". The job stays ineastus2. The new code stops before the plan with the region message.centralus, the new plan says "use existing resource group pdt-shared", "create Log Analytics workspace pdt-logs-centralus in pdt-shared", and "create Container Apps Job".--yesinto a second region, followed by destroy. It creates billed resources in the shared test subscription.Closes #33
🤖 Generated with Claude Code
Moved from GitLab
autoidm/pdt!144(https://gitlab.com/autoidm/pdt/-/merge_requests/144), opened by autoidm-jon on 2026-09-26.