-
Notifications
You must be signed in to change notification settings - Fork 562
Bug 1826446: (fix) Admission Webhook names must be unique #1489
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
Bug 1826446: (fix) Admission Webhook names must be unique #1489
Conversation
@awgreene: This pull request references Bugzilla bug 1826446, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker. 3 validation(s) were run on this bug
In response to this:
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. |
/retest |
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.
Looks good. I had some review comments for the webhooks test. For ginkgo conversion, you could refer to these slides. There is also a cheatsheet
|
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.
Looking good.
f4e2ea5
to
531372d
Compare
@dinhxuanvu I've addressed your comment, could you please review? |
/retest
|
/retest
|
/hold |
/lgtm |
2b5cc29
to
e396f4a
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.
Thanks Alex, for taking the time to convert the tests to ginkgo. I have some comments. Please ping me if you have any questions.
e396f4a
to
d447c11
Compare
/lgtm for ginkgo tests |
ad4bd9e
to
470403c
Compare
49aad40
to
9a9ba6a
Compare
/test e2e-gcp
|
9a9ba6a
to
5466275
Compare
/retest |
/lgtm |
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.
Thanks for fixing this!
Blocking: I had one primary concern about reusing the Name
field.
Non-blocking: In general I think we should focus on ways to deduplicate our code. For example, the methods for validating and mutating webhooks here are nearly identical; one possible way to simplify might be to use a dynamic client and add an additional prototype layer -- WebhookConfig
-- and pass them to a single function.
pkg/controller/install/webhook.go
Outdated
return err | ||
} | ||
} else { | ||
return err | ||
} | ||
for _, webhook := range existingWebhooks.Items { |
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.
nit: we can avoid the surrounding else
statement by returning at the end of the if
block above.
pkg/controller/install/webhook.go
Outdated
webhookLabels := ownerutil.OwnerLabel(i.owner, i.owner.GetObjectKind().GroupVersionKind().Kind) | ||
webhookLabels[WebhookDescKey] = desc.Name | ||
webhookSelector := labels.SelectorFromSet(webhookLabels).String() |
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.
nit: this might make a nice helper
pkg/controller/install/webhook.go
Outdated
return nil | ||
} | ||
|
||
const WebhookDescKey = "webhookDescriptionName" |
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.
Note: eventually, we should update OLM's use of labels to follow the k8s label conventions.
In this case:
Key names should be all lowercase, with words separated by dashes instead of camelCase
For instance, prefer foo.kubernetes.io/foo-bar over foo.kubernetes.io/fooBar, prefer desired-replicas over DesiredReplicas
pkg/controller/install/webhook.go
Outdated
return err | ||
} | ||
} else { | ||
return err | ||
for _, webhook := range existingWebhooks.Items { |
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.
nit: we can avoid the else
here too.
/hold Awaiting operator-framework/api#34 and a new api version tag. |
5466275
to
d816cb4
Compare
2461433
to
e2b30f9
Compare
e2b30f9
to
61b9d60
Compare
Problem: OLM currently creates all ValidatingWebhookConfigurations and MutatingWebhookConfigurations using the name provided in the WebhookDescription. This causes an issue when an operator that defines an admission webhook in the CSV is installed in multiple namespaces, causes the two operators to fight over the admission webhook. Solution: Generate a unique name for each webhook using the GenerateName field in the Object Metadata.
61b9d60
to
c6819bb
Compare
/retest |
I think this looks good. Note: I think the e2e tests need some style tweaks, but we can follow up later. /hold cancel |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: awgreene, njhale 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 |
/lgtm |
@awgreene: All pull requests linked via external trackers have merged: operator-framework/operator-lifecycle-manager#1489. Bugzilla bug 1826446 has been moved to the MODIFIED state. In response to this:
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. |
Problem:
OLM currently creates all ValidatingWebhookConfigurations and
MutatingWebhookConfigurations using the name provided in the
WebhookDescription. This causes an issue when an operator that defines
an admission webhook in the CSV is installed in multiple namespaces,
causes the two operators to fight over the admission webhook.
Solution:
Generate a unique name for each webhook using the GenerateName field in
the Object Metadata.