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

Don't Merge: Example of simpler interface for Webhooks #292

Closed
wants to merge 4 commits into from

Conversation

pwittrock
Copy link
Contributor

@pwittrock pwittrock commented Jan 14, 2019

This code isn't polished enough to be merged.

Sending to show folks the vision.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jan 14, 2019
@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Jan 14, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: pwittrock

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 Jan 14, 2019
type Validator interface {
runtime.Object
ValidateCreate() error
ValidateUpdate(old runtime.Object) error
Copy link
Member

Choose a reason for hiding this comment

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

How are we going to handle Delele and Connect?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we need to initially?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe not.
Create and Update are most common and should be must-have;
Delete is less common and should be good-to-have;
I haven't heard a real use case of Connect.

Copy link
Member

Choose a reason for hiding this comment

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

ValidateUpdate(old runtime.Object) error

IIRC if the webhook is registered as ValidatingWebhookConfiguration, old object will not be included in the AdmissionReview request.
But a nil object may not be a problem here.

@@ -125,10 +126,11 @@ type Server struct {
// They can be nil, if there is no webhook registered under it.
webhookConfigurations []runtime.Object

// manager is the manager that this webhook server will be registered.
manager manager.Manager
Copy link
Member

Choose a reason for hiding this comment

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

Happy to see we will drop manager and instead to use scheme and restMapper explictly.

Copy link
Contributor

@droot droot left a comment

Choose a reason for hiding this comment

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

I am excited about this approach. Would like to explore how easy it will be to extend it to add conversion support.

}

return types.Response{}, false
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is fantastic. I like the way it hides all the webhook machinery from the end-users. Resource author just need to define the validate and default methods on their types and rest is taken care by the machinery (exactly the way it should be).

This is a huge step in making defaulting and validation accessible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

+1

copy.Default()

// Create the patch
return admission.PatchResponse(obj, copy), true
Copy link
Contributor

Choose a reason for hiding this comment

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

This causes roundtripping issue, we are moving away from this #256 .

@DirectXMan12 DirectXMan12 added this to the 0.2.0 milestone Jan 16, 2019
@droot
Copy link
Contributor

droot commented Jan 17, 2019

@mengqiy is working on extracting manifest generation out of controller-runtime that has an overlap with this, so has volunteered to tackle this PR.

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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants