Skip to content

Conversation

@ntnn
Copy link
Member

@ntnn ntnn commented Aug 15, 2025

Summary

See #2811 and #3517

The KCPRequestInfo handler didn't have any actual use and its existence had been questioned before (I'll post the link to the comment if I find it again) and it was the major contributor for the multiple /cluster/... issue.

What Type of PR Is This?

/kind bug
/kind cleanup

Related Issue(s)

Fixes #2811
Fixes #3517

Release Notes

Fix CRDs with kind `Cluster` leading to errors
Fix URLs with multiple `/cluster/...` segments being silently ignored

@kcp-ci-bot kcp-ci-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. kind/bug Categorizes issue or PR as related to a bug. dco-signoff: yes Indicates the PR's author has signed the DCO. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 15, 2025
@ntnn ntnn force-pushed the kcp2811 branch 2 times, most recently from 68aefe0 to 1d1637b Compare August 20, 2025 07:58
ntnn added 6 commits August 21, 2025 14:48
The regex is only used within the tests and not the filter.

Signed-off-by: Nelo-T. Wallus <[email protected]>
…lready present in context

Signed-off-by: Nelo-T. Wallus <[email protected]>
Signed-off-by: Nelo-T. Wallus <[email protected]>
Signed-off-by: Nelo-T. Wallus <[email protected]>
Signed-off-by: Nelo-T. Wallus <[email protected]>
Signed-off-by: Nelo-T. Wallus <[email protected]>
Signed-off-by: Nelo-T. Wallus <[email protected]>
@kcp-ci-bot kcp-ci-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 21, 2025
@ntnn ntnn changed the title [WIP] Handle Cluster Kind Fix Cluster kind and multiple /clusters/ in URLs Aug 21, 2025
@kcp-ci-bot kcp-ci-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. labels Aug 21, 2025
Comment on lines -409 to -410
// Make sure to set our RequestInfoResolver that is capable of populating a RequestInfo even for /services/... URLs.
c.GenericConfig.RequestInfoResolver = requestinfo.NewKCPRequestInfoResolver()
Copy link
Member Author

Choose a reason for hiding this comment

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

One places where this was used was in the cache server, where it would prune the cluster anyhow:

func(rq *http.Request) (string, string, error) {
if serverConfig.Config.RequestInfoResolver == nil {
return "", "", errors.New("no RequestInfoResolver provided")
}
// the k8s request info resolver expects a cluster-less path, but the client we're using knows how to
// add the cluster we are targeting to the path before this round-tripper fires, so we need to strip it
// to use the k8s library
parts := strings.Split(rq.URL.Path, "/")
if len(parts) < 4 {
return "", "", fmt.Errorf("RequestInfoResolver: got invalid path: %v", rq.URL.Path)
}
if parts[1] != "clusters" {
return "", "", fmt.Errorf("RequestInfoResolver: got path without cluster prefix: %v", rq.URL.Path)
}
// we clone the request here to safely mutate the URL path, but this cloned request is never realized
// into anything on the network, just inspected by the k8s request info libraries
clone := rq.Clone(rq.Context())
clone.URL.Path = strings.Join(parts[3:], "/")
requestInfo, err := serverConfig.Config.RequestInfoResolver.NewRequestInfo(clone)
if err != nil {
return "", "", err
}
return requestInfo.Resource, requestInfo.Verb, nil
},
"customresourcedefinitions")
rt = rest.AddUserAgent(rt, "kcp-cache-server")

@ntnn
Copy link
Member Author

ntnn commented Aug 21, 2025

/cherry-pick release-0.28

@kcp-ci-bot
Copy link
Contributor

@ntnn: once the present PR merges, I will cherry-pick it on top of release-0.28 in a new PR and assign it to you.

In response to this:

/cherry-pick release-0.28

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/test-infra repository.

Comment on lines +85 to +87
// TODO(ntnn): Replace with t.Context in go1.24
ctx, cancel := context.WithCancel(context.Background())
t.Cleanup(cancel)
Copy link
Member Author

Choose a reason for hiding this comment

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

Using this instead of t.Context for the cherry-pick to 0.28

limitations under the License.
*/

package server
Copy link
Member Author

Choose a reason for hiding this comment

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

This would be a new e2e package but I didn't see any other that would be fitting.

ntnn added 2 commits August 21, 2025 16:12
Signed-off-by: Nelo-T. Wallus <[email protected]>
Signed-off-by: Nelo-T. Wallus <[email protected]>
Signed-off-by: Nelo-T. Wallus <[email protected]>
Signed-off-by: Nelo-T. Wallus <[email protected]>
Signed-off-by: Nelo-T. Wallus <[email protected]>
Signed-off-by: Nelo-T. Wallus <[email protected]>
@ntnn
Copy link
Member Author

ntnn commented Aug 21, 2025

/retest

Copy link
Member

@embik embik left a comment

Choose a reason for hiding this comment

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

/approve

@kcp-ci-bot kcp-ci-bot added the lgtm Indicates that a PR is ready to be merged. label Aug 22, 2025
@kcp-ci-bot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 7b6987a5fd53bc34da241b3f07fbb748b03eb985

@kcp-ci-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: embik

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

@kcp-ci-bot kcp-ci-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 22, 2025
@ntnn
Copy link
Member Author

ntnn commented Aug 22, 2025

/retest

Known flake #3522

@ntnn
Copy link
Member Author

ntnn commented Aug 22, 2025

/retest

Known flake #3522

@kcp-ci-bot kcp-ci-bot merged commit e734ff2 into kcp-dev:main Aug 22, 2025
14 checks passed
@ntnn ntnn deleted the kcp2811 branch August 22, 2025 11:13
@kcp-ci-bot
Copy link
Contributor

@ntnn: #3537 failed to apply on top of branch "release-0.28":

Applying: Move regex into test file
Applying: Return an error if attempts are made to parse a cluster when one is already present in context
Applying: Don't build longer and longer chains with each call
Applying: Remove KCPRequestInfoResolver
Using index info to reconstruct a base tree...
M	pkg/server/config.go
Falling back to patching base and 3-way merge...
Auto-merging pkg/server/config.go
CONFLICT (content): Merge conflict in pkg/server/config.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0004 Remove KCPRequestInfoResolver
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

In response to this:

/cherry-pick release-0.28

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/test-infra repository.

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. dco-signoff: yes Indicates the PR's author has signed the DCO. kind/bug Categorizes issue or PR as related to a bug. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: silent redirect of invalid URLs that contain multiple /clusters/ bug: Status subresource returns 404 for any CR with Kind: Cluster

3 participants