Skip to content

PoC msi based identities info fetching with two controller stages - #6525

Closed
Miguel Soriano (miguelsorianod) wants to merge 3 commits into
Azure:mainfrom
miguelsorianod:alt-poc-msoriano-fetchinfo-controlplaneoperators-and-smi-mis
Closed

PoC msi based identities info fetching with two controller stages#6525
Miguel Soriano (miguelsorianod) wants to merge 3 commits into
Azure:mainfrom
miguelsorianod:alt-poc-msoriano-fetchinfo-controlplaneoperators-and-smi-mis

Conversation

@miguelsorianod

Copy link
Copy Markdown
Collaborator

PoC that builds on top of #6301.

The FetchMSIIdentitiesInfoi controller now writes ClientID/PrincipalID into
ServiceProviderCluster.Status.MSIManagedIdentities (lowercased resource IDs)
instead of HCPOpenShiftCluster.Identity.

The IdentityMigration controller has been changed to fill the existing
Cluster's Identity.UserAssignedIdentities entries from
that SPC status via case-insensitive lookup, preserving Identity map key casing
and leaving the keys in Identity.UserAssignedIdentities unchanged when there's no
corresponding match in SPC. Entries that exist in SPC but don't exist in Identity.UserAssignedIdentities
are also not added to Identity.UserAssignedIdentities. It no longer reads from Cluster Service.

…tatus

The FetchMSIIdentitiesInfoi controller now writes ClientID/PrincipalID into
ServiceProviderCluster.Status.MSIManagedIdentities (lowercased resource IDs)
instead of HCPOpenShiftCluster.Identity.

The IdentityMigration controller has been changed to fill the existing
Cluster's Identity.UserAssignedIdentities entries from
that SPC status via case-insensitive lookup, preserving Identity map key casing
and leaving the keys in Identity.UserAssignedIdentities unchanged when there's no
corresponding match in SPC. Entries that exist in SPC but don't exist in Identity.UserAssignedIdentities
are also not added to Identity.UserAssignedIdentities. It no longer reads from Cluster Service.
Copilot AI lite review requested due to automatic review settings August 12, 2026 16:40
@openshift-ci

openshift-ci Bot commented Aug 12, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: miguelsorianod
Once this PR has been reviewed and has the lgtm label, please assign janboll for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci

openshift-ci Bot commented Aug 12, 2026

Copy link
Copy Markdown

PR needs rebase.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@openshift-ci

openshift-ci Bot commented Aug 12, 2026

Copy link
Copy Markdown

Miguel Soriano (@miguelsorianod): The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/mega-linter b52ed79 link true /test mega-linter
ci/prow/periodic-healthcheck-images b52ed79 link true /test periodic-healthcheck-images
ci/prow/e2e-parallel b52ed79 link true /test e2e-parallel
ci/prow/config-change-detection b52ed79 link true /test config-change-detection
ci/prow/lint b52ed79 link true /test lint
ci/prow/e2e-images b52ed79 link true /test e2e-images
ci/prow/integration b52ed79 link true /test integration
ci/prow/verify b52ed79 link true /test verify
ci/prow/images b52ed79 link true /test images
ci/prow/test-unit b52ed79 link true /test test-unit
ci/prow/image-updater-images b52ed79 link true /test image-updater-images

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@miguelsorianod

Copy link
Copy Markdown
Collaborator Author

/hold as it's poc and it's also non refined on details

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a two-stage PoC flow for MSI identity metadata in Cosmos: one controller fetches ClientID/PrincipalID for MSI-based user-assigned identities and writes them to ServiceProviderCluster.Status.MSIManagedIdentities, and IdentityMigration then fills missing identity fields on existing clusters from that SPC status (case-insensitive lookup, preserving original identity key casing).

Changes:

  • Added FetchMSIIdentitiesInfo controller to query the Managed Identities Data Plane and persist resolved identity metadata onto ServiceProviderCluster.Status.MSIManagedIdentities.
  • Updated IdentityMigration to stop reading Cluster Service and instead backfill Identity.UserAssignedIdentities[*].ClientID/PrincipalID from SPC status using lowercased resource ID matching.
  • Extended core API types, deepcopy generation, and docs/cosmos-data-flow.md to reflect the new SPC status field and read/write paths.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
internal/api/coreapi/zz_generated.deepcopy.go Adds deepcopy support for newly introduced SPC MSI identity status types.
internal/api/coreapi/types_serviceprovider_cluster.go Introduces ServiceProviderCluster.Status.MSIManagedIdentities and related structs to store resolved MSI identity metadata.
docs/cosmos-data-flow.md Updates Cosmos read/write documentation for IdentityMigration and documents FetchMSIIdentitiesInfo behavior and field writers/readers.
backend/pkg/controllers/cluster/properties/identity_migration.go Switches IdentityMigration to fill identity fields from SPC status instead of Cluster Service.
backend/pkg/controllers/cluster/properties/identity_migration_test.go Updates unit tests to validate the new SPC-backed migration behavior (but currently contains compilation issues).
backend/pkg/controllers/cluster/identity/fetch_msi_identities_info.go Adds new controller that queries MI Data Plane and writes resolved identity metadata into SPC status.
backend/pkg/app/backend.go Wires in the new FetchMSIIdentitiesInfo controller and removes the Cluster Service client dependency from IdentityMigration.
Files not reviewed (1)
  • internal/api/coreapi/zz_generated.deepcopy.go: Generated file
Suppressed comments (10)

backend/pkg/controllers/cluster/properties/identity_migration_test.go:75

  • The map value type is *coreapi.UserAssignedIdentity, but the test uses a non-pointer composite literal. This won’t compile; use &coreapi.UserAssignedIdentity{...}.
						testIdentityResourceID: {
							ClientID:    stringPtr(testClientID),
							PrincipalID: stringPtr(testPrincipalID),
						},
					},

backend/pkg/controllers/cluster/properties/identity_migration_test.go:90

  • The map value type is *coreapi.UserAssignedIdentity, but the test uses a non-pointer composite literal ({}). This won’t compile; use &coreapi.UserAssignedIdentity{} instead.
						testIdentityResourceID: {},

backend/pkg/controllers/cluster/properties/identity_migration_test.go:102

  • The map value type is *coreapi.UserAssignedIdentity, but the test uses a non-pointer composite literal. This won’t compile; use &coreapi.UserAssignedIdentity{...}.
						testIdentityResourceID: {
							ClientID:    stringPtr(testClientID),
							PrincipalID: stringPtr(testPrincipalID),
						},
					},

backend/pkg/controllers/cluster/properties/identity_migration_test.go:121

  • The map value type is *coreapi.UserAssignedIdentity, but the test uses a non-pointer composite literal. This won’t compile; use &coreapi.UserAssignedIdentity{...}.
						testIdentityResourceID: {
							ClientID:    stringPtr(testClientID),
							PrincipalID: stringPtr(testPrincipalID),
						},
					},

backend/pkg/controllers/cluster/properties/identity_migration_test.go:144

  • The map value type is *coreapi.UserAssignedIdentity, but the test uses a non-pointer composite literal ({}). This won’t compile; use &coreapi.UserAssignedIdentity{} instead.
						testIdentityResourceID: {},

backend/pkg/controllers/cluster/properties/identity_migration_test.go:178

  • The map value type is *coreapi.UserAssignedIdentity, but the test uses a non-pointer composite literal ({}). This won’t compile; use &coreapi.UserAssignedIdentity{} instead.
						mixedCaseIdentityResourceID: {},

backend/pkg/controllers/cluster/properties/identity_migration_test.go:195

  • The map value type is *coreapi.UserAssignedIdentity, but the test uses a non-pointer composite literal ({}). This won’t compile; use &coreapi.UserAssignedIdentity{} instead.
						testIdentityResourceID: {},

backend/pkg/controllers/cluster/properties/identity_migration_test.go:212

  • The map value type is *coreapi.UserAssignedIdentity, but the test uses a non-pointer composite literal ({}). This won’t compile; use &coreapi.UserAssignedIdentity{} instead.
						testIdentityResourceID: {},

backend/pkg/controllers/cluster/identity/fetch_msi_identities_info.go:195

  • Grammar in this comment is a bit unclear (e.g., “independently on what identity is request”). Consider tightening the wording for readability.
	// On environments where the real Managed Identities Data Plane service is not available, a
	// fake implementation of the Managed Identities Data Plane client is used, which always returns the same information and
	// same set of credentials for all requests, independently on what identity is request. The returned information is
	// the information associated to the "MI Mock" identity.

backend/pkg/controllers/cluster/identity/fetch_msi_identities_info.go:217

  • Extra period at the end of this comment (“should not happen..”).
			// If this occurs, we return an error instead of accumulating it as this is unexpected and should not happen..

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 61 to 65
testIdentityResourceID: {
ClientID: stringPtr(testClientID),
PrincipalID: stringPtr(testPrincipalID),
},
},
Comment on lines +343 to +348
lowerResourceIDStr: {
OperatorName: operatorName,
ResourceID: metadataapi.Must(azcorearm.ParseResourceID(lowerResourceIDStr)),
ClientID: stringPtr(clientID),
PrincipalID: stringPtr(principalID),
},
Comment on lines +155 to +157
// TODO do we actually want to implement continuous syncing of the identities as of now? Changing this over time
// would have downstream effects and we do not have the support for those other pieces yet.
func (c *fetchMSIIdentitiesInfoSyncer) SyncOnce(ctx context.Context, key controllerutils.HCPClusterKey) error {
Comment on lines +55 to +60
// It periodically checks each cluster and populates Identity.UserAssignedIdentities
// from ServiceProviderCluster.Status.MSIManagedIdentities when the identity map
// is missing keys, has empty ClientID/PrincipalID, or has unexpected entries.
// Map keys in Identity keep the casing from CustomerProperties; SPC lookups use
// lowercased resource IDs. Keys remain even when SPC does not yet have a matching
// identity entry.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants