Repository navigation
ci: give each Azure SQL service principal job its own app registration - #1849
arthurschreiber wants to merge 4 commits into
Conversation
The service principal configs added a short-lived client secret to the shared test app, but Entra allows that app at most two passwords and it already has two, so provisioning failed with TooManyAppPasswords. With two such configs per run, a cap on one app would also limit how many runs can overlap. For `azure-ad-sp-secret` and `token-credential`, provision.sh now creates an app registration named after the job's server, with its service principal and a client secret that expires after two hours. It makes that app the server's Entra admin, retries server creation while the new app propagates, and waits until the secret can get an Azure SQL token before publishing it. A leaked secret now only reaches its own server. The teardown deletes the attempt's apps and purges them from deleted items, and the hourly cleanup removes any older than two hours. Client secrets on the shared test app are still removed for runs from the previous version. The other configs keep the admin group, and the Entra password tests keep the shared app as their public client. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UtKcuYJkSGXdBxqC7KTtqm
|
Claude review of 7e916ca
|
The hourly cleanup deleted and purged every app it owned whose name started with `tedious-ci-`. That includes the shared public client app if it is named `tedious-ci-test` (as the setup guide suggests) and the provisioner owns it (as earlier setups required), which would break the Entra password tests for good. Only match the per-job name format (`tedious-ci-<run>-<attempt>-...`) and never the app with the shared test app's client ID, in both the cleanup and the purge of deleted items. The teardown gets the same client ID guard. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UtKcuYJkSGXdBxqC7KTtqm
|
Re the review of 7e916ca: confirmed, and fixed in 1ff34e8.
I checked the filters against sample data with those names and a renamed shared app. The teardown mock test still passes. Generated by Claude Code |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1849 +/- ##
=======================================
Coverage 85.24% 85.24%
=======================================
Files 97 97
Lines 4778 4778
Branches 896 896
=======================================
Hits 4073 4073
Misses 447 447
Partials 258 258 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
On #1844's first end-to-end run, teardown hung in the first `az sql server delete` for its whole 30-minute timeout, so the run's second server was never deleted at all. teardown.sh now starts every deletion with --no-wait, then polls the resource group until the attempt's servers are gone, for up to 15 minutes. A slow deletion can no longer stop the others, and Azure carries out an accepted deletion even if the job ends first. The hourly cleanup also deletes with --no-wait and retries anything still there on its next run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UtKcuYJkSGXdBxqC7KTtqm
Fixes the next failure on #1844's first end-to-end run (provisioning job):
The service principal configs added a short-lived client secret to the shared test app, but Entra allows it at most two passwords and it already has two long-lived ones. Even without them, two such configs per run means a cap on one app limits how many runs can overlap.
It also fixes teardown hanging. On #1844's run for eac4ef7, the first
az sql server deleteblocked for the teardown job's whole 30-minute timeout (teardown job), so the second server was never deleted.Changes
azure-ad-sp-secretandtoken-credential.provision.shcreates an app registration named after the job's server (tedious-ci-<run>-<attempt>-<config>), plus its service principal and a client secret that expires after 2h.wait_for_app_token, up to 5 min).Application.ReadWrite.OwnedBycovers creating these apps and managing them, and only them.teardown.sh):delete_ci_app; the purge is best effort);--no-wait, then polls until the attempt's servers are gone, for up to 15 minutes. A slow deletion no longer blocks the others, and Azure carries out an accepted deletion even if the job ends first;tedious-ci-*secrets on the shared test app, which runs from the previous version created.tedious-ci-<run>-<attempt>-…) more than 2h old and purges deleted ones (best effort, with a warning);--no-wait, and retries any still there on its next run.tedious-ci-sql-adminsas Entra admin, and the Entra password tests keep the shared app as their public client. The test side (ci: run Azure SQL tests against per-run servers, including fork PRs #1844) needs no change, because the provisioner already sends the client ID..github/AZURE_SQL_CI.md: updated. The shared app no longer needs to be in the admin group, needs no secrets, and the provisioner no longer needs to own it.After merging,
tedious_appcan be removed fromtedious-ci-sql-admins. Its long-lived secrets can be deleted once the old Azure jobs are gone (#1844).Testing
Mock GitHub API, mock Entra token endpoint and fake
az:azure-ad-sp-secret:Applicationwith the new app's ID;azure-defaultandazure-ad-password: no app is created, and the group stays the admin. The password tests keep the shared client ID.token-credentialwith server creation failing once: the retry succeeds.found=true, so the test job fails fast.--no-waitand waits until they're gone;tedious-ci-test,tedious-ci-provisionerand a renamed shared app; none of them is selected.🤖 Generated with Claude Code
https://claude.ai/code/session_01UtKcuYJkSGXdBxqC7KTtqm