fix(flux): authenticate to ACR explicitly instead of by discovery - #3912
Open
arealmaas wants to merge 1 commit into
Open
fix(flux): authenticate to ACR explicitly instead of by discovery#3912arealmaas wants to merge 1 commit into
arealmaas wants to merge 1 commit into
Conversation
Altinn/info.altinn.no hit this when moving a workflow that uses flux/build-push-image onto self-hosted runners: error during login with provider: failed to create provider access token for the controller: DefaultAzureCredential: failed to acquire a token ... ManagedIdentityCredential authentication failed RESPONSE 400: Unable to load the proper Managed Identity flux --provider=azure authenticates through the Azure SDK's DefaultAzureCredential, which resolves a credential by discovery rather than using the session azure/login just established, and stops at the first credential that fails outright. On GitHub-hosted runners nothing earlier in the chain is available, so it falls through to the CLI credential and picks up that session. On self-hosted runners, which are Azure Container App Jobs, a managed identity endpoint is present, so ManagedIdentityCredential is attempted instead. It returns HTTP 400 because the job has a user-assigned identity and flux supplies no client id, and the chain aborts before the CLI credential is reached. Every workflow in this repository that uses this action runs on ubuntu-latest, which is why it has not surfaced here. Self-hosted jobs that reach altinncr do so through the az CLI, which uses its own session and never enters this chain. Any team moving a flux workflow onto the self-hosted runners will hit it. Handing the SDK the same federated credentials azure/login uses makes WorkloadIdentityCredential resolve first, so flux authenticates as the same application regardless of runner type. This requires 'permissions: id-token: write' on the calling job, which OIDC-based azure/login already required. Verified against flux 2.6.4 with a mock Container Apps identity endpoint: without these variables the chain stops at ManagedIdentityCredential with the 400 above, and with them set the chain resolves WorkloadIdentityCredential first and never reaches managed identity. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
tjololo
approved these changes
Aug 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes
flux/setup-flux-acrhand the Azure SDK explicit federated credentials, soflux --provider=azureauthenticates the same way regardless of which runner the job lands on.Refs #3838
The problem
Altinn/info.altinn.no hit this when moving a workflow that uses
flux/build-push-imageonto the self-hosted runners:flux --provider=azureauthenticates throughDefaultAzureCredential, which resolves a credential by discovery rather than using the sessionazure/loginjust established — and stops at the first credential that fails outright.ubuntu-latestManagedIdentityCredentialreports unavailable → falls through toAzureCLICredential→ uses theazure/loginsession ✅ManagedIdentityCredentialis attempted → job has a user-assigned identity and flux supplies no client id → HTTP 400 → chain aborts beforeAzureCLICredential❌So
azure/loginsucceeds and its session is then never consulted.Why this hasn't surfaced in this repo
All eight workflows here that use this action run on
ubuntu-latest:And the self-hosted jobs that do reach
altinncr(syncroot-deployment.yml) go through the az CLI (az acr import), which uses its own session and never enters this chain. The two ingredients exist separately here, never together — so this will hit any team that moves a flux workflow onto the self-hosted runners.The fix
After
azure/login, fetch the GitHub OIDC token and point the SDK at the same federated credentials:WorkloadIdentityCredentialsits ahead ofManagedIdentityCredentialin the chain, so it resolves first and the managed identity endpoint is never consulted. Same application, same permissions as today — just selected explicitly rather than by discovery.Requires
permissions: id-token: writeon the calling job, which OIDC-basedazure/loginalready required. The step fails with an explicit message if the OIDC endpoint isn't available, rather than silently falling back to the broken path.Verification
Against flux 2.6.4 in
gh-runner:v0.10.0, with a mock Container Apps identity endpoint returning the same 400:Without the change — chain stops at managed identity, matching the reported failure:
With the change — workload identity resolves first, managed identity never attempted:
That second 400 is AAD rejecting a deliberately fake token — I have no real federated credential locally — but it confirms the chain reaches workload identity, targets the right tenant, and never falls through to the managed identity endpoint, which is the actual bug.
To be explicit about the limit of that: I have not exercised a real token exchange end to end. The mechanism is verified; the successful-auth path needs a real run. I deliberately ran nothing against this repo's workflows or infrastructure.
Related
Altinn/info.altinn.no#706 unblocks the affected workflow today by clearing the endpoint variables for that job. That's a per-repo workaround; this is the durable fix, and #706 can be reverted once this ships.
🤖 Generated with Claude Code