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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Implement Catalog for Runtime SDK #6393

Merged
merged 1 commit into from
Apr 27, 2022

Conversation

ykakarap
Copy link
Contributor

@ykakarap ykakarap commented Apr 8, 2022

What this PR does / why we need it:

Implement the Catalog useful for the Runtime SDK implementation.

Catalog is in many ways similar to schema but it extends to become the store for Runtime Hooks.

Catalog will be used to store the hooks, their mapping to the request and response objects, the open api generators, util functions, etc.

Part of #6330

/kind feature
/area runtime-sdk

@sbueringer @fabriziopandini @vincepri @CecileRobertMichon @enxebre

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. area/runtime-sdk Issues or PRs related to Runtime SDK cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Apr 8, 2022
@ykakarap ykakarap force-pushed the runtime-sdk-catalog branch 4 times, most recently from 1e6e292 to 66bd9fd Compare April 11, 2022 19:27
@ykakarap ykakarap changed the title ✨ [WIP] Implement Catalog for Runtime SDK ✨ Implement Catalog for Runtime SDK Apr 11, 2022
Copy link
Contributor

@killianmuldoon killianmuldoon left a comment

Choose a reason for hiding this comment

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

Looks good on first review - just a couple of nits

panic("Group must not be empty")
}
if gv.Version == "" {
panic("Version must not be empty")
Copy link
Contributor

Choose a reason for hiding this comment

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

Errors should start with a lower case letter.

Copy link
Member

Choose a reason for hiding this comment

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

Let's keep it as is now, but just fyi. Those are not errors. Those are strings which are handed over to panics. I used upper case because the upstream scheme package was using uppercase consistently.

The reason why errors are lower case is because they are concatenated like this <error-message>: <error-message>: <error-message>. Uppercase would look awkward there.

This does not apply to panics.

internal/runtime/catalog/catalog.go Outdated Show resolved Hide resolved
internal/runtime/catalog/catalog.go Outdated Show resolved Hide resolved
Copy link
Member

@fabriziopandini fabriziopandini left a comment

Choose a reason for hiding this comment

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

That's a great start!
A couple of comment about hardening some input validation, but nothing really blocking


// Singleton signals if the hook can only be implemented once on a
// Runtime Extension, e.g. like the DiscoveryHook.
Singleton bool
Copy link
Member

Choose a reason for hiding this comment

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

Q: do we really need this given that the DiscoveryHook is already treated as a special case during the registration process?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This field becomes important when we are going to do OpenAPI spec generation. This can be used to distinguish between endpoints that are name specific vs endpoints that are not (singletons).
Example:
The Before Cluster Create hook is not a singleton and the end point will be name specific. Endpoint: /hooks.runtime.cluster.x-k8s.io/v1alpha1/beforeclusterupgrade/{name}.
The discovery endpoint is a singleton and the endpoint will be something like: /hooks.runtime.cluster.x-k8s.io/v1alpha1/discovery

Copy link
Member

Choose a reason for hiding this comment

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

kk,
I'm not super happy to expose a knob for a what is a single, well-known special case now, but we can eventually re-iterate later (it could be also a simple rename to something that makes it more clear what are the implications of a singleton in this context).
Feel free to resolve the comment

Copy link
Member

Choose a reason for hiding this comment

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

I would also try to avoid it, but I wasn't sure how. I didn't want to hard-code if hook == "Discovery" but maybe we should just do that. Let's reconsider on the runtime openapi gen PR.

internal/runtime/catalog/catalog.go Show resolved Hide resolved
internal/runtime/catalog/catalog.go Show resolved Hide resolved
internal/runtime/catalog/catalog.go Show resolved Hide resolved
internal/runtime/catalog/test/catalog_test.go Show resolved Hide resolved
Co-authored-by: sbueringer <sburingerst@vmware.com>
@fabriziopandini
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 26, 2022
@sbueringer
Copy link
Member

I'll take another closer look first thing tomorrow. But I don't expect major findings.

@sbueringer
Copy link
Member

sbueringer commented Apr 27, 2022

Added 2 comments to the conversations above (informational for future PRs), but let's move on :)

/lgtm

@fabriziopandini
Copy link
Member

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fabriziopandini

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 27, 2022
@sbueringer sbueringer mentioned this pull request Apr 27, 2022
30 tasks
@k8s-ci-robot k8s-ci-robot merged commit 3bff7da into kubernetes-sigs:main Apr 27, 2022
@k8s-ci-robot k8s-ci-robot added this to the v1.2 milestone Apr 27, 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. area/runtime-sdk Issues or PRs related to Runtime SDK cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. 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.

5 participants