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.11] Revert "⏪ reverted userAssignedIdenties logic based on PR #2214" #4068

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
11 changes: 10 additions & 1 deletion controllers/azurejson_machine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"k8s.io/utils/ptr"
infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1"
"sigs.k8s.io/cluster-api-provider-azure/azure/scope"
"sigs.k8s.io/cluster-api-provider-azure/azure/services/identities"
"sigs.k8s.io/cluster-api-provider-azure/util/reconciler"
"sigs.k8s.io/cluster-api-provider-azure/util/tele"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
Expand Down Expand Up @@ -214,7 +215,15 @@
// Construct secret for this machine
userAssignedIdentityIfExists := ""
if len(azureMachine.Spec.UserAssignedIdentities) > 0 {
userAssignedIdentityIfExists = azureMachine.Spec.UserAssignedIdentities[0].ProviderID
idsClient, err := identities.NewClient(clusterScope)
if err != nil {
return reconcile.Result{}, errors.Wrap(err, "failed to create identities client")
}
userAssignedIdentityIfExists, err = idsClient.GetClientID(
ctx, azureMachine.Spec.UserAssignedIdentities[0].ProviderID)
if err != nil {
return reconcile.Result{}, errors.Wrap(err, "failed to get user-assigned identity ClientID")
}

Check warning on line 226 in controllers/azurejson_machine_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/azurejson_machine_controller.go#L218-L226

Added lines #L218 - L226 were not covered by tests
}

if azureMachine.Spec.Identity == infrav1.VMIdentityNone {
Expand Down
11 changes: 10 additions & 1 deletion controllers/azurejson_machinepool_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"k8s.io/utils/ptr"
infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1"
"sigs.k8s.io/cluster-api-provider-azure/azure/scope"
"sigs.k8s.io/cluster-api-provider-azure/azure/services/identities"
infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1"
"sigs.k8s.io/cluster-api-provider-azure/util/reconciler"
"sigs.k8s.io/cluster-api-provider-azure/util/tele"
Expand Down Expand Up @@ -174,7 +175,15 @@
// Construct secret for this machine
userAssignedIdentityIfExists := ""
if len(azureMachinePool.Spec.UserAssignedIdentities) > 0 {
userAssignedIdentityIfExists = azureMachinePool.Spec.UserAssignedIdentities[0].ProviderID
idsClient, err := identities.NewClient(clusterScope)
if err != nil {
return reconcile.Result{}, errors.Wrap(err, "failed to create identities client")
}
userAssignedIdentityIfExists, err = idsClient.GetClientID(
ctx, azureMachinePool.Spec.UserAssignedIdentities[0].ProviderID)
if err != nil {
return reconcile.Result{}, errors.Wrap(err, "failed to get user-assigned identity ClientID")
}

Check warning on line 186 in controllers/azurejson_machinepool_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/azurejson_machinepool_controller.go#L178-L186

Added lines #L178 - L186 were not covered by tests
}

apiVersion, kind := infrav1.GroupVersion.WithKind("AzureMachinePool").ToAPIVersionAndKind()
Expand Down
11 changes: 10 additions & 1 deletion controllers/azurejson_machinetemplate_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"k8s.io/utils/ptr"
infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1"
"sigs.k8s.io/cluster-api-provider-azure/azure/scope"
"sigs.k8s.io/cluster-api-provider-azure/azure/services/identities"
"sigs.k8s.io/cluster-api-provider-azure/util/reconciler"
"sigs.k8s.io/cluster-api-provider-azure/util/tele"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
Expand Down Expand Up @@ -174,7 +175,15 @@
// Construct secret for this machine template
userAssignedIdentityIfExists := ""
if len(azureMachineTemplate.Spec.Template.Spec.UserAssignedIdentities) > 0 {
userAssignedIdentityIfExists = azureMachineTemplate.Spec.Template.Spec.UserAssignedIdentities[0].ProviderID
idsClient, err := identities.NewClient(clusterScope)
if err != nil {
return reconcile.Result{}, errors.Wrap(err, "failed to create identities client")
}
userAssignedIdentityIfExists, err = idsClient.GetClientID(
ctx, azureMachineTemplate.Spec.Template.Spec.UserAssignedIdentities[0].ProviderID)
if err != nil {
return reconcile.Result{}, errors.Wrap(err, "failed to get user-assigned identity ClientID")
}

Check warning on line 186 in controllers/azurejson_machinetemplate_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/azurejson_machinetemplate_controller.go#L178-L186

Added lines #L178 - L186 were not covered by tests
}

if azureMachineTemplate.Spec.Template.Spec.Identity == infrav1.VMIdentityNone {
Expand Down