fix(e2e): set PrincipalType on role assignment to avoid AAD replication race#8251
Merged
ganeshkumarashok merged 1 commit intomainfrom Apr 8, 2026
Merged
Conversation
…on race When creating a managed identity and immediately assigning a role, the role assignment can fail with PrincipalNotFound due to AAD replication delay. Setting PrincipalType to ServicePrincipal tells ARM to skip the AAD principal lookup, avoiding the race condition. This is consistent with assignACRPullToIdentity in cluster.go which already sets PrincipalType for the same managed identity.
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Mitigates intermittent Azure RBAC PrincipalNotFound failures in GPU E2E by explicitly setting the principal type during role assignment, avoiding AAD replication lookup races for newly created managed identities.
Changes:
- Sets
PrincipalType: ServicePrincipalon the “Storage Blob Data Contributor” role assignment inassignRolesToVMIdentity.
cameronmeissner
approved these changes
Apr 8, 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.
Summary
PrincipalType: ServicePrincipalto the Storage Blob Data Contributor role assignment inassignRolesToVMIdentityPrincipalNotFounderrors in GPU E2E tests (e.g.Test_Ubuntu2404_NvidiaDevicePluginRunning_MIG) caused by AAD replication delay when a managed identity is created and immediately assigned a roleassignACRPullToIdentityincluster.gowhich already sets this field for the same managed identityRoot Cause
When
CreateVMManagedIdentitycreates a user-assigned managed identity and immediately callsassignRolesToVMIdentity, ARM tries to look up the principal in AAD. If the AAD replica handling the request hasn't replicated the new principal yet, it returnsPrincipalNotFound. SettingPrincipalTypetells ARM to skip this lookup.Reference: https://learn.microsoft.com/en-us/azure/role-based-access-control/role-assignments-rest#new-service-principal
Test plan
Agentbaker GPU E2E)