-
Notifications
You must be signed in to change notification settings - Fork 1.2k
🐛 Fix custom path for webhooks conflict #3102
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
Hi @damsien. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
Hello @alvaroaleman , what do you think about this one? I know that it can potentially be a breaking change because we are renaming a function that already exists. I am not sure about the upgrade process that must be done (is it simply a Also, I wanted to let you know that it is not yet implemented in the |
@@ -95,9 +96,15 @@ func (blder *WebhookBuilder) RecoverPanic(recoverPanic bool) *WebhookBuilder { | |||
return blder | |||
} | |||
|
|||
// WithCustomPath overrides the webhook's default path by the customPath | |||
func (blder *WebhookBuilder) WithCustomPath(customPath string) *WebhookBuilder { |
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.
Renaming this makes this PR a breaking change for everyone, we should not do that. The two main alternatives I can think of are:
- Only one of
WithCustomDefaulter
/WithCustomValidator
may be set when usingWithCustomPath
, otherwise we error out - We use indexing, i.E. when both are set, there must also be two
WithCustomPath
calls and the first gets the first/the second the second
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.
Hello Alvaro,
What about this one:
We keep the WithCustomPath()
, WithDefaultingCustomPath()
and WithValidatingCustomPath()
functions. If the developer uses the WithCustomPath()
function, then only one of the WithCustomDefaulter()
or WithCustomValidator()
should be set, otherwise the developer should use the specific custom path functions.
Maybe it is not a good idea because we have multiple function accomplishing the same purpose. Waiting for you thoughts about it.
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.
What about:
- Enforce only one of WithCustomDefaulter/WithCustomValidator may be set when using WithCustomPath, otherwise we error out
- Deprecate WithCustomPath
- Add new options to WithDefaulter / WithValidator that allows to set the path
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.
@damsien I meant something slightly diferently :)
Instead of having additional WithValidatingCustomPath & WithDefaultingCustomPath funcs I was suggesting to add options to the existing WithDefaulter / WithValidator functions to set the path (similar to the existing option that already exists for the WithDefaulter funct)
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.
Okay nevermind. Just noticed that DefaulterOptions are also passed down to WithCustomDefaulter and there the custom path wouldn't make any sense
Hello @alvaroaleman @sbueringer, Following our conversation, I add some pre-checks:
If at least one of these checks are not good, then we error out when calling Also, I added a What do you think? (I'll squash all my commits when we'll validate the merge) |
/ok-to-test |
Thanks @sbueringer ! |
Signed-off-by: Damien Dassieu <[email protected]>
Thank you! /lgtm |
LGTM label has been added. Git tree hash: b286157ec763827d7020ed7d1dedfcb140f5b958
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: damsien, sbueringer 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 |
Following this PR #2998. I implemented the custom path for webhooks considering that it will be used by either only the
validating
or thedefaulting
. However, the user can actually use the both of them on the same webhook manager.Until now, when the user was using
.WithDefaulter(&TestCustomDefaulter{})
,.WithValidator(&TestCustomValidator{})
and.WithCustomPath(customPath)
at the same time, an endless loop was launched by constantly calling the other webhook. This bug is caused because they are both register at the same path.This is the reason why I made this PR. I split the
.WithCustomPath()
function into two functions.WithDefaultingCustomPath()
and.WithValidatingCustomPath()
in order to be used in this way:Also, I added two tests:
WithDefaulter()
andWithValidator()
at the same time (without the custom path implementation) because there were no test about this specific configuration before.