Skip to content

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

Conversation

awgreene
Copy link
Member

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.

@awgreene awgreene changed the title (fix) Admission Webhook names must be unique Bug 1826446: (fix) Admission Webhook names must be unique Apr 28, 2020
@openshift-ci-robot openshift-ci-robot added the bugzilla/severity-unspecified Referenced Bugzilla bug's severity is unspecified for the PR. label Apr 28, 2020
@openshift-ci-robot
Copy link
Collaborator

@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
  • bug is open, matching expected state (open)
  • bug target release (4.5.0) matches configured target release for branch (4.5.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1826446: (fix) Admission Webhook names must be unique

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.

@openshift-ci-robot openshift-ci-robot added the bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. label Apr 28, 2020
@awgreene
Copy link
Member Author

/retest

Copy link
Contributor

@harishsurf harishsurf 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. I had some review comments for the webhooks test. For ginkgo conversion, you could refer to these slides. There is also a cheatsheet

@awgreene
Copy link
Member Author

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
@harishsurf I knew this was coming! Already working on it!

Copy link
Member

@dinhxuanvu dinhxuanvu left a comment

Choose a reason for hiding this comment

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

Looking good.

@awgreene awgreene force-pushed the webhook-unique-names branch 2 times, most recently from f4e2ea5 to 531372d Compare April 30, 2020 13:43
@awgreene
Copy link
Member Author

@dinhxuanvu I've addressed your comment, could you please review?

@awgreene
Copy link
Member Author

/retest

could not wait for build: the build root failed after 2m11s with reason FetchSourceFailed: Failed to fetch the input source.

@awgreene
Copy link
Member Author

/retest

release "release-latest" failed: the pod ci-op-7482wfws/release-latest failed after 18s (failed containers: release): ContainerFailed one or more containers exited
Container release exited with code 1, reason Error

@awgreene
Copy link
Member Author

awgreene commented May 1, 2020

/hold
Working on Ginkgo e2e tests.

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 1, 2020
@exdx
Copy link
Member

exdx commented May 1, 2020

/lgtm
/retest

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label May 1, 2020
@awgreene awgreene force-pushed the webhook-unique-names branch 2 times, most recently from 2b5cc29 to e396f4a Compare May 4, 2020 17:47
@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label May 4, 2020
Copy link
Contributor

@harishsurf harishsurf left a 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.

@awgreene awgreene force-pushed the webhook-unique-names branch from e396f4a to d447c11 Compare May 4, 2020 19:05
@harishsurf
Copy link
Contributor

/lgtm for ginkgo tests

@awgreene awgreene force-pushed the webhook-unique-names branch 2 times, most recently from ad4bd9e to 470403c Compare May 5, 2020 01:51
@awgreene awgreene force-pushed the webhook-unique-names branch from 49aad40 to 9a9ba6a Compare May 5, 2020 14:38
@awgreene
Copy link
Member Author

awgreene commented May 5, 2020

/test e2e-gcp

ERROR: (gcloud.compute.instance-groups.list-instances) could not parse resource []

@awgreene awgreene force-pushed the webhook-unique-names branch from 9a9ba6a to 5466275 Compare May 5, 2020 16:56
@awgreene
Copy link
Member Author

awgreene commented May 5, 2020

/retest

@ecordell
Copy link
Member

ecordell commented May 5, 2020

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label May 5, 2020
Copy link
Member

@njhale njhale left a 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.

return err
}
} else {
return err
}
for _, webhook := range existingWebhooks.Items {
Copy link
Member

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.

Comment on lines 117 to 122
webhookLabels := ownerutil.OwnerLabel(i.owner, i.owner.GetObjectKind().GroupVersionKind().Kind)
webhookLabels[WebhookDescKey] = desc.Name
webhookSelector := labels.SelectorFromSet(webhookLabels).String()
Copy link
Member

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

return nil
}

const WebhookDescKey = "webhookDescriptionName"
Copy link
Member

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

return err
}
} else {
return err
for _, webhook := range existingWebhooks.Items {
Copy link
Member

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.

@njhale
Copy link
Member

njhale commented May 6, 2020

/hold

Awaiting operator-framework/api#34 and a new api version tag.

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 6, 2020
@awgreene awgreene force-pushed the webhook-unique-names branch from 5466275 to d816cb4 Compare May 6, 2020 22:38
@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label May 6, 2020
@awgreene awgreene force-pushed the webhook-unique-names branch 2 times, most recently from 2461433 to e2b30f9 Compare May 6, 2020 22:49
@awgreene awgreene mentioned this pull request May 6, 2020
5 tasks
@awgreene awgreene force-pushed the webhook-unique-names branch from e2b30f9 to 61b9d60 Compare May 6, 2020 23:12
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.
@awgreene awgreene force-pushed the webhook-unique-names branch from 61b9d60 to c6819bb Compare May 6, 2020 23:30
@njhale
Copy link
Member

njhale commented May 7, 2020

/retest

@njhale
Copy link
Member

njhale commented May 7, 2020

I think this looks good.

Note: I think the e2e tests need some style tweaks, but we can follow up later.

/hold cancel
/approve

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 7, 2020
@openshift-ci-robot
Copy link
Collaborator

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 7, 2020
@dinhxuanvu
Copy link
Member

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label May 7, 2020
@openshift-merge-robot openshift-merge-robot merged commit 6544650 into operator-framework:master May 7, 2020
@openshift-ci-robot
Copy link
Collaborator

@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:

Bug 1826446: (fix) Admission Webhook names must be unique

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.

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. bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants