Skip to content

Conversation

@Arvindthiru
Copy link
Contributor

@Arvindthiru Arvindthiru commented Jun 21, 2023

Description of your changes

Fixes #

I have:

  • Run make reviewable to ensure this PR is ready for review.

How has this code been tested

UT and E2E tests

Special notes for your reviewer

@Arvindthiru Arvindthiru changed the title Webhook for member cluster feat: Webhook for member cluster Jun 21, 2023
@Arvindthiru Arvindthiru marked this pull request as ready for review June 21, 2023 07:36
}

// ValidateUserForFleetCR checks to see if user is authenticated to make a request to modify Fleet CRs.
func ValidateUserForFleetCR(ctx context.Context, client client.Client, whiteListedUsers []string, userInfo authenticationv1.UserInfo) bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

is this used anywhere?

Copy link
Contributor

Choose a reason for hiding this comment

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

is the whiteList only useful fro FleetCR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using whiteList for CRD check as well

var memberClusterList fleetv1alpha1.MemberClusterList
if err := client.List(ctx, &memberClusterList); err != nil {
klog.V(2).ErrorS(err, "failed to list member clusters")
return false
Copy link
Contributor

Choose a reason for hiding this comment

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

is this list from the cache?

Copy link
Contributor Author

@Arvindthiru Arvindthiru Jun 21, 2023

Choose a reason for hiding this comment

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

This client is from the manager that's constructed in hub agent's main.go where we don't pass a NewClient func, since we are not passing it looks like we get new delegating client which uses the cache on reads https://github.com/kubernetes-sigs/controller-runtime/blob/main/pkg/manager/manager.go#L141

Seems like we are using a different version of controller runtime but this seems to be true for both versions
image

I can see why it would be concern if we read stale data from the cache and reject certain requests from the member agents, but even if the webhook rejects the request once the member agent will retry in the next reconcile and in the meantime I'm assuming the cache will be populated with new data. If that's not the case we may need to use a new client here which doesn't use the cache

Copy link
Contributor

Choose a reason for hiding this comment

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

we probably should upgrade our controller-runtime now.
I looked at the code, I think we are reading it from cache.

@ryanzhang-oss ryanzhang-oss merged commit 0f1039a into Azure:main Jun 22, 2023
britaniar pushed a commit to britaniar/fleet that referenced this pull request Jan 12, 2026
@britaniar britaniar mentioned this pull request Jan 12, 2026
1 task
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.

2 participants