Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-1.10] ignore AKS user-assigned ClientID/PrincipalID in diff #3963

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions azure/services/managedclusters/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,14 @@ func computeDiffOfNormalizedClusters(managedCluster containerservice.ManagedClus
Type: existingMC.Identity.Type,
UserAssignedIdentities: existingMC.Identity.UserAssignedIdentities,
}

// ClientID and PrincipalID are read-only and should not trigger a diff.
for _, id := range existingMCClusterNormalized.Identity.UserAssignedIdentities {
if id != nil {
id.ClientID = nil
id.PrincipalID = nil
}
}
}

if managedCluster.Sku != nil {
Expand Down
37 changes: 37 additions & 0 deletions azure/services/managedclusters/spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,27 @@ func TestParameters(t *testing.T) {
g.Expect(result).To(BeNil())
},
},
{
name: "managedcluster exists with UserAssigned identity, no update needed",
existing: getExistingClusterWithUserAssignedIdentity(),
spec: &ManagedClusterSpec{
Name: "test-managedcluster",
ResourceGroup: "test-rg",
Location: "test-location",
Tags: map[string]string{
"test-tag": "test-value",
},
Version: "v1.22.0",
LoadBalancerSKU: "standard",
Identity: &infrav1.Identity{
Type: infrav1.ManagedControlPlaneIdentityTypeUserAssigned,
UserAssignedIdentityResourceID: "some id",
},
},
expect: func(g *WithT, result interface{}) {
g.Expect(result).To(BeNil())
},
},
}
for _, tc := range testcases {
tc := tc
Expand Down Expand Up @@ -331,6 +352,22 @@ func getExistingCluster() containerservice.ManagedCluster {
return mc
}

func getExistingClusterWithUserAssignedIdentity() containerservice.ManagedCluster {
mc := getSampleManagedCluster()
mc.ProvisioningState = pointer.String("Succeeded")
mc.ID = pointer.String("test-id")
mc.Identity = &containerservice.ManagedClusterIdentity{
Type: containerservice.ResourceIdentityTypeUserAssigned,
UserAssignedIdentities: map[string]*containerservice.ManagedClusterIdentityUserAssignedIdentitiesValue{
"some id": {
ClientID: pointer.String("some client id"),
PrincipalID: pointer.String("some principal id"),
},
},
}
return mc
}

func getSampleManagedCluster() containerservice.ManagedCluster {
return containerservice.ManagedCluster{
ManagedClusterProperties: &containerservice.ManagedClusterProperties{
Expand Down