Skip to content

fix: skip access provider population in cluster profiles if no endpoint/CA data exists - #849

Merged
Chen Yu (michaelawyu) merged 5 commits into
kubefleet-dev:mainfrom
michaelawyu:fix/cluster-profile-access-provider
Aug 26, 2026
Merged

fix: skip access provider population in cluster profiles if no endpoint/CA data exists#849
Chen Yu (michaelawyu) merged 5 commits into
kubefleet-dev:mainfrom
michaelawyu:fix/cluster-profile-access-provider

Conversation

@michaelawyu

Copy link
Copy Markdown
Member

Description of your changes

This pull request primarily refactors import statements for consistency and improves the logic for populating the AccessProviders field in the ClusterProfile controller. It ensures that the cluster access provider is only set when both the cluster entry point and CA data are available, and updates related tests accordingly.

Fixes #761

I have:

  • Associated this change with a known KubeFleet Issue (Bug, Feature, etc).
  • Run make reviewable to ensure this PR is ready for review.

How has this code been tested

  • UTs
  • ITs

Special notes for your reviewer

N/A

Signed-off-by: michaelawyu <chenyu1@microsoft.com>

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 addresses issue #761 by changing the ClusterProfile controller’s status population so it only publishes a status.accessProviders entry when required cluster access properties are available, preventing consumers from receiving an AccessProvider with an empty cluster.server. It also updates unit/integration tests to reflect the new behavior and includes minor generated-file import formatting changes.

Changes:

  • Update ClusterProfile status population to conditionally set Status.AccessProviders only when both the cluster entrypoint and CA data properties exist.
  • Adjust unit/integration tests to stop expecting an AccessProvider when required properties are missing, and to supply the entrypoint in integration tests.
  • Normalize import aliases in several controller-gen generated deepcopy files.

Reviewed changes

Copilot reviewed 3 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/controllers/clusterinventory/clusterprofile/controller.go Changes AccessProvider population logic to be conditional on entrypoint + CA data existence.
pkg/controllers/clusterinventory/clusterprofile/controller_test.go Updates unit tests to align with new conditional AccessProvider behavior.
pkg/controllers/clusterinventory/clusterprofile/controller_integration_test.go Updates integration test fixtures to include the cluster entrypoint property so AccessProvider population occurs.
apis/cluster/v1beta1/zz_generated.deepcopy.go Generated import alias formatting change.
apis/placement/v1beta1/zz_generated.deepcopy.go Generated import alias formatting change.
apis/placement/v1alpha1/zz_generated.deepcopy.go Generated import alias formatting change.
apis/kubefleet.dev/placement/v1alpha1/zz_generated.deepcopy.go Generated import alias formatting change.
test/apis/v1alpha1/zz_generated.deepcopy.go Generated import alias formatting change.
Files not reviewed (5)
  • apis/cluster/v1beta1/zz_generated.deepcopy.go: Generated file
  • apis/kubefleet.dev/placement/v1alpha1/zz_generated.deepcopy.go: Generated file
  • apis/placement/v1alpha1/zz_generated.deepcopy.go: Generated file
  • apis/placement/v1beta1/zz_generated.deepcopy.go: Generated file
  • test/apis/v1alpha1/zz_generated.deepcopy.go: Generated file

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

Comment thread pkg/controllers/clusterinventory/clusterprofile/controller.go Outdated
@codecov

codecov Bot commented Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Signed-off-by: michaelawyu <chenyu1@microsoft.com>

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

Copilot reviewed 3 out of 8 changed files in this pull request and generated 2 comments.

Files not reviewed (5)
  • apis/cluster/v1beta1/zz_generated.deepcopy.go: Generated file
  • apis/kubefleet.dev/placement/v1alpha1/zz_generated.deepcopy.go: Generated file
  • apis/placement/v1alpha1/zz_generated.deepcopy.go: Generated file
  • apis/placement/v1beta1/zz_generated.deepcopy.go: Generated file
  • test/apis/v1alpha1/zz_generated.deepcopy.go: Generated file

Comment thread pkg/controllers/clusterinventory/clusterprofile/controller.go
Comment thread pkg/controllers/clusterinventory/clusterprofile/controller.go
Signed-off-by: michaelawyu <chenyu1@microsoft.com>

@sjwaight Simon Waight (sjwaight) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Assuming E2Es pass, LGTM.

Signed-off-by: michaelawyu <chenyu1@microsoft.com>

// Add cluster access provider, if and only if a cluster entry point and the CA data exist as part of the
// cluster properties.
clusterEntrypoint, entryPtExists := mc.Status.Properties[propertyprovider.ClusterEntryPointProperty]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can mc.Status.Properties[propertyprovider.ClusterEntryPointProperty] ever throw nil pointer exception?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hi Yetkin! mc.Status is a struct (empty if not written yet, but never nil), and nil maps (.status.properties) can be read as empty maps with no panic errors, so we should be good.

// Add cluster access provider, if and only if a cluster entry point and the CA data exist as part of the
// cluster properties.
clusterEntrypoint, entryPtExists := mc.Status.Properties[propertyprovider.ClusterEntryPointProperty]
caData, caDataExists := mc.Status.Properties[propertyprovider.ClusterCertificateAuthorityProperty]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same question for this one too.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hi Yetkin! mc.Status is a struct (empty if not written yet, but never nil), and nil maps (.status.properties) can be read as empty maps with no panic errors, so we should be good.

Comment on lines +465 to +466
// Note: at this moment the Azure property provider does not expose cluster FQDNs, and
// as a result no access provider will be populated.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If case checks if AccessProviders array has items, right? The comment sounds a bit off to me. Am I missing something?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hi Yetkin! Yeah, about this one: the access provider, as the issuer contributor mentioned, needs to have a valid cluster entrypoint (API server URL) set. However, at this moment, even though we do have the cluster entrypoint property listed, it is never written/used; as a result, all the cluster profiles we produce have invalid access providers with no entrypoints.

With this PR we have added the check as requested, i.e., if there is no cluster entrypoint, we do not populate access providers; until we add support for the cluster entrypoint property, the expected behavior onwards is that all the cluster profiles hub agent produces will have no access providers, hence the updated check.

@michaelawyu

Copy link
Copy Markdown
Member Author

Hi all! I am merging this to unblock progress; if there is any question/concern, please let me know. Will address them in separate PRs.

@michaelawyu
Chen Yu (michaelawyu) merged commit 898e0bb into kubefleet-dev:main Aug 26, 2026
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] ClusterProfile publishes an AccessProvider with an empty cluster.server

5 participants