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

Webhook marker allows handler path to be changed, but a deterministic handler is always registered #868

Closed
rajathagasthya opened this issue Mar 20, 2020 · 18 comments
Assignees
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/design Categorizes issue or PR as related to design.
Milestone

Comments

@rajathagasthya
Copy link
Contributor

rajathagasthya commented Mar 20, 2020

Webhook marker like the one below lets us change path where webhook is served. This creates the appropriate Mutating|ValidatingWebhookConfiguration manifest referencing this path.

// +kubebuilder:webhook:verbs=create;update,path=/validate-batch-tutorial-kubebuilder-io-v1-cronjob,mutating=false,failurePolicy=fail,groups=batch.tutorial.kubebuilder.io,resources=cronjobs,versions=v1,name=vcronjob.kb.io

But webhook builder always registers the same path based on GVK:

func generateMutatePath(gvk schema.GroupVersionKind) string {
return "/mutate-" + strings.Replace(gvk.Group, ".", "-", -1) + "-" +
gvk.Version + "-" + strings.ToLower(gvk.Kind)
}
func generateValidatePath(gvk schema.GroupVersionKind) string {
return "/validate-" + strings.Replace(gvk.Group, ".", "-", -1) + "-" +
gvk.Version + "-" + strings.ToLower(gvk.Kind)
}

This is confusing when the user thinks they can customize the handler path, but it's actually ignored and worse, the generated webhook manifest doesn't work because path is incorrect.

If we are letting users change the path through the marker, perhaps it's better to add an option to webhook builder to configure handler path as well? Or, if the path is not supposed to be changed in the marker, we should say that in docs.

@rajathagasthya rajathagasthya changed the title Webhook marker allows handler path to be changed, but a deterministic handler is always register Webhook marker allows handler path to be changed, but a deterministic handler is always registered Mar 20, 2020
@alenkacz
Copy link
Contributor

maybe this bug should rather be in kubebuilder project? Since it could be solved on multiple places and might also need update in documentation?

Anyway - I took a look at it. One possible solution would be to allow overriding path inside the builder here

config *rest.Config
and use that instead of generating one if provided. If we go that way, we would also have to update docs here https://book.kubebuilder.io/cronjob-tutorial/webhook-implementation.html

WDYT?

@alenkacz
Copy link
Contributor

/assign

@rajathagasthya
Copy link
Contributor Author

@alenkacz Yeah, we could provide an option in webhook builder to set path and then update docs to say "path in webhook build must match path in webhook marker" or something to that effect.

We probably also need some kind of validation if we let users set their own path.

@ryanzhang-oss
Copy link

maybe this bug should rather be in kubebuilder project

kubernetes-sigs/kubebuilder#1436

@vincepri vincepri added this to the Next milestone Mar 26, 2020
@vincepri
Copy link
Member

/kind design

We need to think more about possible solutions

@k8s-ci-robot k8s-ci-robot added the kind/design Categorizes issue or PR as related to design. label Mar 26, 2020
@vincepri
Copy link
Member

/help

@k8s-ci-robot
Copy link
Contributor

@vincepri:
This request has been marked as needing help from a contributor.

Please ensure the request meets the requirements listed here.

If this request no longer meets these requirements, the label can be removed
by commenting with the /remove-help command.

In response to this:

/help

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 the help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. label Mar 26, 2020
@ryanzhang-oss
Copy link

I am not familiar with the process here, what does "/help" mean? It seems that this is a pretty straightforward bug to fix.

@alexeldeib
Copy link
Contributor

"/help" (adding the help-wanted label) is usually a good signal for issues to pick up 🙂 https://github.com/kubernetes/community/blob/master/contributors/guide/help-wanted.md#overview

However @alenkacz self-assigned, maybe she is still working on this? We did just discuss it recently.

FWIW I think adding to the builder seems reasonable. I think @DirectXMan12 mentioned some caveats with this, but i'm not seeing them on the controller-runtime side? Was it something to do with the kubebuilder side of templating things?

@DirectXMan12
Copy link
Contributor

"path in webhook build must match path in webhook marker"

seems reasonable. Might have to be path prefix.

My concern was mainly that we don't want to tie those two together. Allowing you to customize the path (optionally) seems fine.

@devigned
Copy link

devigned commented May 7, 2020

I was thinking about taking a look at this issue if it's not being actively worked on. Thoughts?

@DirectXMan12
Copy link
Contributor

go ahead :-)

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Aug 31, 2020
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Sep 30, 2020
@fejta-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

@k8s-ci-robot
Copy link
Contributor

@fejta-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

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.

@damsien
Copy link
Contributor

damsien commented Oct 28, 2024

Hello, I want to reopen this issue because the solution has not been implemented. I think that there is some users who wants to have a way to configure their webhooks using a custom path.

/remove-lifecycle rotten

The following PR (#2998) implements this functionality.

@k8s-ci-robot
Copy link
Contributor

@damsien: You can't reopen an issue/PR unless you authored it or you are a collaborator.

In response to this:

Hello, I am reopening this issue because the solution has not been implemented. I think that there is some users who wants to have a way to configure their webhooks using a custom path.

/reopen
/remove-lifecycle rotten

The following PR implements this functionality.

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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot removed the lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. label Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/design Categorizes issue or PR as related to design.
Projects
None yet
Development

No branches or pull requests

10 participants