Repository navigation
Support mux patterns in VW framework - #4543
Conversation
Signed-off-by: Nelo-T. Wallus <git@ntnn.de> Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
Signed-off-by: Nelo-T. Wallus <git@ntnn.de> Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
Signed-off-by: Nelo-T. Wallus <git@ntnn.de> Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
Signed-off-by: Nelo-T. Wallus <git@ntnn.de> Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
Signed-off-by: Nelo-T. Wallus <git@ntnn.de> Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
Signed-off-by: Nelo-T. Wallus <git@ntnn.de> Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
Signed-off-by: Nelo-T. Wallus <git@ntnn.de> Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
Signed-off-by: Nelo-T. Wallus <git@ntnn.de> Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
Signed-off-by: Nelo-T. Wallus <git@ntnn.de> Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
Signed-off-by: Nelo-T. Wallus <git@ntnn.de> Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
Signed-off-by: Nelo-T. Wallus <git@ntnn.de> Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
…PIExport Signed-off-by: Nelo-T. Wallus <git@ntnn.de> Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
|
@mjudeikis-bot review this, be nitpicky around the vw-framework API for external users |
mjudeikis-bot
left a comment
There was a problem hiding this comment.
Mostly looks good as a cleanup, but there is one regression in the front-proxy and two framework-API concerns.
Not anchored
- Breaking change for external VW implementers:
RootPathResolverFunc/RootPathResolver.ResolveRootPathchanges signature (arguments swapped andPathMatchreplacesurlPath). This is intentional per the PR, but it has no release note (release-note-none), and the staging repo is consumed externally. Please add a release note describing the migration (Patterns+ new resolver signature). Conflicting or duplicate patterns across VWs now panic at startup; worth stating inarchitecture.md. - Behaviour shift worth documenting: previously the first VW (in registration order) that accepted any path won; now the most specific mux pattern wins first and registration order only applies within an identical pattern string.
Checked
- Read beyond the diff:
pkg/server/proxy/lookup.go(WithClusterResolver,newMappingHandler,extractClusterFromPath),pkg/virtual/options/options.go(how VWs are composed), the fullserver.go/config.go/types.goin the framework, and all seven builders' resolvers. - Correctness: resolvers traced for admin, apiexport, replication, apiresourceschema (consumer/cluster mismatch check kept), initializing/terminating (three VWs sharing one pattern keep order), migrating. No other issue found. Findings above: front-proxy regression (verified with a throwaway test on this head), mux path-cleaning redirect (verified with a throwaway test), empty
Patterns(traced). - Concurrency: mux built once at handler-chain build; n/a for races.
- kcp specifics: the cluster is now resolved before the resolver runs; invalid cluster segments fall to the delegate, as before. Wildcard
*handled. - API/storage: no API types/codegen touched. Security: no authorizer changes; the apiresourceschema cluster mismatch check preserved.
- Tests: new unit tests in
server_test.goand the builders cover the mux; the removed proxy tests are what would fail without the revert. - Commands:
go build ./...OK;go vet ./pkg/virtual/... ./pkg/server/proxy/...clean;go test ./pkg/virtual/... ./pkg/server/proxy/...pass;go test ./...in the framework staging module passes. I did not run the e2e tests (they need a full kcp environment, and the proxy regression is already confirmed at unit level).
|
@mjudeikis-bot: changing LGTM is restricted to collaborators DetailsIn response to this:
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. |
Signed-off-by: Nelo-T. Wallus <git@ntnn.de> Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
Signed-off-by: Nelo-T. Wallus <git@ntnn.de> Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
Signed-off-by: Nelo-T. Wallus <git@ntnn.de> Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
|
/test pull-kcp-test-e2e |
| // When it returns `true`, it will also set the VirtualWorkspace name in the request context, | ||
| // as well as the prefix that should be removed from the request URL Path before forwarding | ||
| // the request to the given VirtualWorkspace delegated APIServer. | ||
| type RootPathResolverFunc func(urlPath string, context context.Context) (accepted bool, prefixToStrip string, completedContext context.Context) |
There was a problem hiding this comment.
Could also leave this as is without a breaking change. Would be more wiring probably.
Question is how many people are using the vw-framework to implement VWs and if they shouldn't be migrating to a mux pattern instead of parsing themselves anyway.
There was a problem hiding this comment.
So it's not removed; just signature changes:
func (r RootPathResolverFunc) ResolveRootPath(ctx context.Context, match PathMatch) (accepted bool, prefixToStrip string, completedContext context.Context) {
return r(ctx, match)
}
so we should be ok
| const ( | ||
| sliceClusterWildcard = "sliceCluster" | ||
| sliceNameWildcard = "sliceName" | ||
| ) | ||
|
|
||
| // pathPattern returns the mux pattern of the virtual workspace below rootPathPrefix. | ||
| func pathPattern(rootPathPrefix string) string { | ||
| return path.Join(rootPathPrefix, "{sliceCluster}/{sliceName}/clusters/{cluster}") | ||
| } | ||
|
|
There was a problem hiding this comment.
Can we get bit of godocs on ththese? what these sliceClusterX means?
There was a problem hiding this comment.
Sure, I just followed what the virtualWorkspaceClusterOffsets map did:
// /services/replication/<slice cluster>/<slice name>/clusters/<cluster>/...
| require.Equal(t, tc.expectedLogicalPath, logicalPath, "LogicalPath should match expected value") | ||
| }) | ||
| require.Equal(t, | ||
| "/services/replication/{sliceCluster}/{sliceName}/clusters/{cluster}", |
There was a problem hiding this comment.
same as above. This reads strange sliceCluster and later clusters...
| // PathMatch is a request path matched against a virtual workspace pattern. | ||
| type PathMatch struct { | ||
| // Path is the full request path. | ||
| Path string | ||
| // Trail is the kube-like API path after the pattern, "" if none. | ||
| Trail string | ||
|
|
||
| value func(name string) string | ||
| } |
There was a problem hiding this comment.
As this is breaking change, lets add bit more extensive godocs what is path, how it could looks like (example), and trails itself. Smth user can read and understand how to use this new pathmatcher
| // When it returns `true`, it will also set the VirtualWorkspace name in the request context, | ||
| // as well as the prefix that should be removed from the request URL Path before forwarding | ||
| // the request to the given VirtualWorkspace delegated APIServer. | ||
| type RootPathResolverFunc func(urlPath string, context context.Context) (accepted bool, prefixToStrip string, completedContext context.Context) |
There was a problem hiding this comment.
So it's not removed; just signature changes:
func (r RootPathResolverFunc) ResolveRootPath(ctx context.Context, match PathMatch) (accepted bool, prefixToStrip string, completedContext context.Context) {
return r(ctx, match)
}
so we should be ok
Signed-off-by: Nelo-T. Wallus <git@ntnn.de> Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
Signed-off-by: Nelo-T. Wallus <git@ntnn.de> Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
|
LGTM label has been added. DetailsGit tree hash: 87e39fb54ae0b26b41b67f8c98f7087651f6cc06 |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mjudeikis The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Summary
I saw the
virtualWorkspaceClusterOffsetsand became sad.So I did something to not be sad.
Also adding some e2e tests for this since we only have unit tests to cover the case of a
clustersAPIExport.What Type of PR Is This?
/kind cleanup
Related Issue(s)
Fixes #
Release Notes