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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Fix double identities for wildcard requests from APIExport virtual workspace #2306

Merged
merged 4 commits into from
Dec 1, 2022

Conversation

ncdc
Copy link
Member

@ncdc ncdc commented Nov 4, 2022

Summary

Fix a bug where wildcard requests coming from the APIExport virtual workspace for "built-in" kcp types (e.g. ClusterWorkspaceTypes) had the identity set by the virtual workspace, then set a second time by decorateWildcardPathsWithResourceIdentities.

Related issue(s)

Fixes #2184
Fixes #2308
Incorporates & supersedes #2245

@ncdc
Copy link
Member Author

ncdc commented Nov 4, 2022

/hold
need to fix something

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 4, 2022
@ncdc
Copy link
Member Author

ncdc commented Nov 4, 2022

/unhold

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 4, 2022
@sttts
Copy link
Member

sttts commented Nov 4, 2022

Wait.

@sttts
Copy link
Member

sttts commented Nov 4, 2022

No decorateWildcardPathsWithResourceIdentities client should be used to forward requests from a VW.

/hold

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 4, 2022
@ncdc
Copy link
Member Author

ncdc commented Nov 7, 2022

Updated to change the VW server to use a "clean" client that doesn't inject identities. Had to reimplement similar logic in the initializing workspaces vw. PTAL. Happy to adjust as needed.

// It's possible the incoming request already has an identity specified. Make sure we exclude that when
// determining the resource in question.
parts := strings.SplitN(comps[5], ":", 2)
if len(parts) == 0 {
Copy link
Member

Choose a reason for hiding this comment

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

can this ever happen?

Copy link
Member Author

Choose a reason for hiding this comment

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

Probably not, but can't hurt to have the code here?

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 22, 2022
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 29, 2022
1. Look up the root:tenancy.kcp.dev APIExport identity and use that when
   forwarding requests for clusterworkspaces from the
   initializingworkspaces service to kcp.

2. Fix security issue that exposed all workspaces regardless of phase
   and initializer for GET/UPDATE for a single clusterworkspace

Signed-off-by: Andy Goldstein <andy.goldstein@redhat.com>
@ncdc
Copy link
Member Author

ncdc commented Nov 30, 2022

/unhold

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 30, 2022
factory, listFactory, destroyer,
strategy, tableConvertor,
resource, apiExportIdentityHash, categories,
dynamicClusterClient, []string{}, *patchConflictRetryBackoff, ctx.Done(),
)
store := wrapper(resource.GroupResource(), delegate)
if wrapper != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

You have an inherent nil check in the implementation of Decorate() - do we need it here?

func(_ schema.GroupResource, store *forwardingregistry.StoreFuncs) *forwardingregistry.StoreFuncs {
return store
})
forwardingregistry.StorageWrapperFunc(func(_ schema.GroupResource, store *forwardingregistry.StoreFuncs) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You have an inherent nil check - can we just omit this?

Copy link
Member Author

Choose a reason for hiding this comment

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

If we keep the nil check in NewStorage, yes

Copy link
Contributor

@stevekuznetsov stevekuznetsov left a comment

Choose a reason for hiding this comment

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

Some small comments, otherwise LGTM

// We are explicitly setting forceAllowCreate to false in the call to the underlying storage because
// subresources should never allow create on update.
return delegateUpdate(ctx, name, objInfo, createValidation, updateValidation, false, options)
}
statusStore := wrapper(resource.GroupResource(), statusDelegate)
if wrapper != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

You have an inherent nil check in the implementation of Decorate() - do we need it here?

Copy link
Member Author

Choose a reason for hiding this comment

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

I would keep it - you never know if some other implementation omits the nil check.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure thing

ctx,
resource,
"", // ClusterWorkspaces have no identity
Copy link
Contributor

Choose a reason for hiding this comment

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

oops

@stevekuznetsov
Copy link
Contributor

/lgtm
/approve

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Dec 1, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Dec 1, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: stevekuznetsov

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

The pull request process is described here

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 added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 1, 2022
@openshift-merge-robot openshift-merge-robot merged commit f5865fc into kcp-dev:main Dec 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
5 participants