-
Couldn't load subscription status.
- Fork 424
DynamicRESTMapper: add mapping for core k8s and kcp types #3630
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
20f8e41 to
c860a56
Compare
c7eac4e to
1b72e35
Compare
There was a problem hiding this 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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I've added a test that checks for adding, updating and deleting CRDs in system:system-crds: https://github.com/gman0/kcp/blob/drm-builtin-types/test/integration/dynamicrestmapper/dynamicrestmapper_test.go#L163-L243
I confirm that without the fix above, this test wouldn't pass.
pkg/reconciler/dynamicrestmapper/dynamicrestmapper_builtin_controller.go
Outdated
Show resolved
Hide resolved
|
/retest |
82a799a to
85f588b
Compare
|
/retest |
|
/retest |
85f588b to
9007acc
Compare
| func (c *BuiltinTypesController) process(ctx context.Context, key string) error { | ||
| logger := logging.WithQueueKey(klog.FromContext(ctx), key) | ||
|
|
||
| parts := strings.Split(key, "/") |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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]>
9007acc to
9c9b316
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve
|
LGTM label has been added. Git tree hash: 9b55c3fbb62cc1fd4fe6208e9b2d23515adc4566
|
|
[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 |
|
/retest |
|
/retest Both pull-kcp-test-e2e-sharded and pull-kcp-test-e2e-multiple-runs failed at |
DynamicRESTMapper only watches for bound and regular CRDs, while CRDs from
system:system-crdsare not included at all. This PR adds the mappings for these too.The mapper is now split into two controllers:
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