Skip to content

Conversation

@gman0
Copy link
Contributor

@gman0 gman0 commented Oct 7, 2025

DynamicRESTMapper only watches for bound and regular CRDs, while CRDs from system:system-crds are not included at all. This PR adds the mappings for these too.

The mapper is now split into two controllers:

  • DynamicTypesController: manages dynamic, cluster-local types added through bindings or local CRDs,
  • BuiltinTypesController: manages core k8s and kcp types, common to all clusters.

Additionally, default group-versions are now populated automatically, making resource resolution where version is optional work.

The built-in mappings are now shared, no need to copy them to each cluster as it was before (see DynamicRESTMapper.builtin).

Summary

What Type of PR Is This?

/kind feature

Release Notes

NONE

@kcp-ci-bot kcp-ci-bot added release-note-none Denotes a PR that doesn't merit a release note. kind/feature Categorizes issue or PR as related to a new feature. dco-signoff: yes Indicates the PR's author has signed the DCO. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 7, 2025
@gman0 gman0 force-pushed the drm-builtin-types branch from 20f8e41 to c860a56 Compare October 7, 2025 22:23
@kcp-ci-bot kcp-ci-bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 7, 2025
@gman0 gman0 force-pushed the drm-builtin-types branch 2 times, most recently from c7eac4e to 1b72e35 Compare October 8, 2025 07:59
@gman0 gman0 mentioned this pull request Oct 8, 2025
Copy link
Contributor

@mjudeikis mjudeikis left a comment

Choose a reason for hiding this comment

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

few nits

return
}

key := fmt.Sprintf("%s.%s/%s", crd.Spec.Group, crd.Spec.Names.Plural, crd.Name)
Copy link
Contributor

Choose a reason for hiding this comment

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

This will be in foramt example.corp.com.machines/machine

Can you add comment that first part must be Group.Resource. Basically explain key structure as its custom key

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ohh that's a bug, thanks for spotting this! It indeed should be <Resource>.<Group>/<CRD name>. We don't have a test that covers deletion for built-in types so this went unchecked. I'll try to think of a way to test this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mjudeikis
Copy link
Contributor

/retest

@gman0 gman0 force-pushed the drm-builtin-types branch 2 times, most recently from 82a799a to 85f588b Compare October 8, 2025 12:25
@gman0
Copy link
Contributor Author

gman0 commented Oct 8, 2025

/retest

@gman0
Copy link
Contributor Author

gman0 commented Oct 8, 2025

/retest

@gman0 gman0 force-pushed the drm-builtin-types branch from 85f588b to 9007acc Compare October 8, 2025 22:17
func (c *BuiltinTypesController) process(ctx context.Context, key string) error {
logger := logging.WithQueueKey(klog.FromContext(ctx), key)

parts := strings.Split(key, "/")
Copy link
Contributor

Choose a reason for hiding this comment

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

Still want a comment with example key so reader does not need to read code to understand what type of custom key is this. same in the place where key is consturcted.
Simple:
// Key example <resource.group>/: machines.corp.example.com/machines

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I ended up using the standard kcpcache.MetaClusterNamespaceKeyFunc() because CRD names in system-crds are validated to be <resource>.<group> anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So in BuiltinTypesController.process() we can just extract the GR from the CRD name, and it's fine even if the CRD itself is deleted.

Copy link
Contributor

@mjudeikis mjudeikis left a comment

Choose a reason for hiding this comment

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

Only thin comment i asked, but else ping to tag once added.

The mapper is now split into two controllers:
* DynamicTypesController: manages dynamic, cluster-local types added through bindings or local CRDs
* BuiltinTypesController: manages core k8s and kcp types, common to all clusters

On-behalf-of: @SAP [email protected]
Signed-off-by: Robert Vasek <[email protected]>
@gman0 gman0 force-pushed the drm-builtin-types branch from 9007acc to 9c9b316 Compare October 9, 2025 07:47
Copy link
Contributor

@mjudeikis mjudeikis left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

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

LGTM label has been added.

Git tree hash: 9b55c3fbb62cc1fd4fe6208e9b2d23515adc4566

@kcp-ci-bot
Copy link
Contributor

[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

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 Oct 9, 2025
@gman0
Copy link
Contributor Author

gman0 commented Oct 9, 2025

/retest

@gman0
Copy link
Contributor Author

gman0 commented Oct 9, 2025

/retest

Both pull-kcp-test-e2e-sharded and pull-kcp-test-e2e-multiple-runs failed at

=== Failed
=== FAIL: test/e2e/workspacetype TestWorkspaceTypes/create_a_workspace_without_an_explicit_type,_get_default_type (31.79s)
    controller_test.go:340: Created root:organization workspace root:e2e-workspace-npsrh as /clusters/36qnjtmawxj1u4b7 on shard "shard-1"
    controller_test.go:346: Create a workspace without explicit type
    controller_test.go:346: Saving test artifacts for test "TestWorkspaceTypes/create_a_workspace_without_an_explicit_type,_get_default_type" under "/logs/artifacts/TestWorkspaceTypes/create_a_workspace_without_an_explicit_type,_get_default_type/935858795".
    controller_test.go:346: 
        	Error Trace:	/home/prow/go/src/github.com/kcp-dev/kcp/test/e2e/workspacetype/controller_test.go:74
        	            				/home/prow/go/src/github.com/kcp-dev/kcp/test/e2e/workspacetype/controller_test.go:346
        	Error:      	Condition never satisfied
        	Test:       	TestWorkspaceTypes/create_a_workspace_without_an_explicit_type,_get_default_type
        	Messages:   	workspace should be ready

=== FAIL: test/e2e/workspacetype TestWorkspaceTypes (0.04s)
    controller_test.go:331: Shared kcp server will target configuration "/home/prow/go/src/github.com/kcp-dev/kcp/.kcp/admin.kubeconfig"
    controller_test.go:331: Waiting for readiness for server at https://127.0.0.1:6444

@kcp-ci-bot kcp-ci-bot merged commit 8181da0 into kcp-dev:main Oct 9, 2025
14 checks passed
@gman0 gman0 deleted the drm-builtin-types branch October 9, 2025 10:29
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/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants