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

Add MutatingWebhookConfiguration type #55282

Merged
merged 4 commits into from Nov 10, 2017

Conversation

mbohlool
Copy link
Contributor

@mbohlool mbohlool commented Nov 8, 2017

As part of Mutating Webhook support, this PR adds the configuration for Mutating webhooks. It also renames existing ReadOnly webhook configurations from ExternalAdmissionHookConfiguration to ValidatingWebhookConfiguration. As part of the process some sub-types are also renamed.

Lastly, the mutating webhook configurations are sorted by name to make the serial executing of them deterministic.

ref: kubernetes/enhancements#492

The dynamic admission webhook is split into two kinds, mutating and validating.

@k8s-ci-robot
Copy link
Contributor

@mbohlool: Adding do-not-merge/release-note-label-needed because the release note process has not been followed.

One of the following labels is required "release-note", "release-note-action-required", or "release-note-none".
Please see: https://github.com/kubernetes/community/blob/master/contributors/devel/pull-requests.md#write-release-notes-if-needed.

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/test-infra repository.

@k8s-ci-robot k8s-ci-robot added do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Nov 8, 2017
@k8s-github-robot k8s-github-robot added kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/new-api labels Nov 8, 2017
for i, hook := range e.ExternalAdmissionHooks {
allErrors = append(allErrors, validateExternalAdmissionHook(&hook, field.NewPath("externalAdmissionHooks").Index(i))...)
for i, hook := range e.Webhooks {
allErrors = append(allErrors, validateWebhook(&hook, field.NewPath("externalAdmissionHooks").Index(i))...)
Copy link
Member

Choose a reason for hiding this comment

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

Do we really need to maintain the old path? I realize the migration may be painful but it would be nice if we could keep the naming consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that is an old code that should not exists anymore, please let me know if you see any more of these.

e.ErrStatus.Reason = "LoadingConfiguration"
e.ErrStatus.Details.Causes = append(e.ErrStatus.Details.Causes, metav1.StatusCause{
Type: "ExternalAdmissionHookConfigurationFailure",
Type: "ValidatingWebhookConfigurationFailure",
Message: "An error has occurred while refreshing the externalAdmissionHook configuration, no resources can be created/updated/deleted/connected until a refresh succeeds.",
Copy link
Member

Choose a reason for hiding this comment

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

Again can we keep the naming consistent?

@mbohlool mbohlool force-pushed the webhooks branch 2 times, most recently from 0070052 to 1bcd0b3 Compare November 8, 2017 08:15
@sttts
Copy link
Contributor

sttts commented Nov 8, 2017

/cc @deads2k

}
return nil, err
}
return mergeMutatingWebhookConfigurations(list), nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this list coming from the lister, i.e. a local cache? Does line 83 mutate that object?

Copy link
Contributor

Choose a reason for hiding this comment

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

Our standard listers create temporary lists at least. But it doesn't look like it's specified that the callee is the owner of the list. In any case, mergeMutatingWebhookConfigurations does not give any hint that it mutates its arguments.

Copy link
Member

Choose a reason for hiding this comment

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

This is copied from the existing one-- if the existing one is broken we should fix it both places.

Copy link
Member

Choose a reason for hiding this comment

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

This modifies the List object but the List object is constructed each time?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the function should not mutate that list. Will fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@lavalamp Even if the list object is constructed each time, the function should either document that it modifies its parameters or not modify them. It is easier not to modify them. Also existing code does not have this issue because we do not sort validating webhooks. They are called in parallel so the order does not matter.

Copy link
Member

Choose a reason for hiding this comment

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

ah, thanks for the explanation.

List(opts metav1.ListOptions) (*v1alpha1.MutatingWebhookConfigurationList, error)
}

type MutatingWebhookConfigurationManager struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

godoc. Is this a controller of some sort?

Copy link
Member

Choose a reason for hiding this comment

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

It collects the mutating webhook objects so that they can be called. Yes, a doc string would be good.

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 is the same as ValidatingWebhookConfigurationManager which was ExternalAdmissionHookConfigurationManager. I would like to not add stuff to this PR and keep it pure renaming and duplicating. Any enhancement should be done in a following PR in my opinion.

Copy link
Contributor

Choose a reason for hiding this comment

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

Noticed that as well after commenting.

@@ -118,35 +118,65 @@ const (
// +genclient:nonNamespaced
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// ExternalAdmissionHookConfiguration describes the configuration of initializers.
type ExternalAdmissionHookConfiguration struct {
// ValidatingWebhookConfiguration describes the configuration of and admission webhook that accept or reject and object without changing it.
Copy link
Member

Choose a reason for hiding this comment

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

s/and/an/g

ExternalAdmissionHooks []ExternalAdmissionHook
// +patchMergeKey=name
// +patchStrategy=merge
Webhooks []Webhook
Copy link
Member

Choose a reason for hiding this comment

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

Webhook or AdmissionHook? I have a very very mild preference for the latter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We remove admission from the type name because it was the duplicate of (part of) the package name. I would argue the same here that I prefer Webhook for that reason.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 for Webhook

@@ -106,7 +106,7 @@ func init() {
if err := announced.NewGroupMetaFactory(
&announced.GroupMetaFactoryArgs{
GroupName: admissionregistrationv1alpha1.GroupName,
RootScopedKinds: sets.NewString("InitializerConfiguration", "ExternalAdmissionHookConfiguration"),
RootScopedKinds: sets.NewString("InitializerConfiguration", "ValidatingWebhookConfiguration"),
Copy link
Member

Choose a reason for hiding this comment

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

needs to list the mutating one, also?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ouch, is this the new scheme of kubectl? Do we really decided to rewrite the group installers here. This hurts.

ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*admissionregistration.ValidatingWebhookConfiguration).Name, nil
},
DefaultQualifiedResource: admissionregistration.Resource("externaladmissionhookconfigurations"),
Copy link
Member

Choose a reason for hiding this comment

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

this string probably needs to be updated?

@@ -153,7 +153,7 @@ func (a *GenericAdmissionWebhook) SetScheme(scheme *runtime.Scheme) {

// WantsExternalKubeClientSet defines a function which sets external ClientSet for admission plugins that need it
func (a *GenericAdmissionWebhook) SetExternalKubeClientSet(client clientset.Interface) {
Copy link
Member

Choose a reason for hiding this comment

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

The name of this plugin needs to be changed too, but maybe that is another PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, another PR is better.

@@ -382,7 +382,7 @@ var etcdStorageData = map[schema.GroupVersionResource]struct {
expectedEtcdPath: "/registry/initializerconfigurations/ic1",
},
gvr("admissionregistration.k8s.io", "v1alpha1", "externaladmissionhookconfigurations"): {
Copy link
Member

Choose a reason for hiding this comment

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

s/externaladmissionhookconfigurations/validatingwebhookconfigurations/?

Copy link
Member

Choose a reason for hiding this comment

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

And also duplicate this entry for the mutating ones?

ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*admissionregistration.ExternalAdmissionHookConfiguration).Name, nil
return obj.(*admissionregistration.ValidatingWebhookConfiguration).Name, nil
},
DefaultQualifiedResource: admissionregistration.Resource("externaladmissionhookconfigurations"),
Copy link
Member

Choose a reason for hiding this comment

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

Update this string?

@lavalamp
Copy link
Member

lavalamp commented Nov 8, 2017

I left a few comments, looks close.

@lavalamp lavalamp closed this Nov 8, 2017
@lavalamp lavalamp reopened this Nov 8, 2017
@lavalamp
Copy link
Member

lavalamp commented Nov 8, 2017

Wrong button :)

@mbohlool mbohlool removed the do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. label Nov 9, 2017
@k8s-ci-robot
Copy link
Contributor

@mbohlool: Adding do-not-merge/release-note-label-needed because the release note process has not been followed.

One of the following labels is required "release-note", "release-note-action-required", or "release-note-none".
Please see: https://github.com/kubernetes/community/blob/master/contributors/devel/pull-requests.md#write-release-notes-if-needed.

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/test-infra repository.

@k8s-ci-robot k8s-ci-robot added do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Nov 9, 2017
@mbohlool mbohlool added the release-note-none Denotes a PR that doesn't merit a release note. label Nov 9, 2017
@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 9, 2017
@k8s-github-robot k8s-github-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 9, 2017
@lavalamp
Copy link
Member

lavalamp commented Nov 9, 2017

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 9, 2017
@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lavalamp, mbohlool

Associated issue: 492

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot k8s-github-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 9, 2017
@mbohlool mbohlool removed the do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. label Nov 9, 2017
@mbohlool
Copy link
Contributor Author

mbohlool commented Nov 9, 2017

The change was only automated doc update. Applying lgtm label again.

@mbohlool mbohlool added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 9, 2017
@mbohlool
Copy link
Contributor Author

/test pull-kubernetes-unit

@mbohlool mbohlool added this to the v1.8 milestone Nov 10, 2017
@mbohlool
Copy link
Contributor Author

I am going on vacation today. Would be nice if we can set higher priority on this PR so that submit queue merge it sooner. @caesarxuchao

@caesarxuchao
Copy link
Member

@mbohlool is going to be away for weeks. I'll add the "queue/blocks-others" to get this one merged soon. We can iterate in future PRs if there are more concerns.

@k8s-github-robot
Copy link

/test all [submit-queue is verifying that this PR is safe to merge]

@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 55268, 55282, 55419, 48340, 54829). If you want to cherry-pick this change to another branch, please follow the instructions here.

@k8s-github-robot k8s-github-robot merged commit 61f2108 into kubernetes:master Nov 10, 2017
func mergeMutatingWebhookConfigurations(
list *v1alpha1.MutatingWebhookConfigurationList,
) *v1alpha1.MutatingWebhookConfiguration {
configurations := append([]v1alpha1.MutatingWebhookConfiguration{}, list.Items...)
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

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. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. 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.

None yet

7 participants