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

Run IPPool webhook handler when SecondaryNetwork is enabled #6691

Merged
merged 1 commit into from
Sep 30, 2024

Conversation

luolanzone
Copy link
Contributor

@luolanzone luolanzone commented Sep 25, 2024

IPPool is also used when the SecondaryNetwork is enabled, so fix the condition to run IPPool webhook handler as well when SecondaryNetwork feature gate is enabled.

@luolanzone luolanzone added kind/bug Categorizes issue or PR as related to a bug. action/backport Indicates a PR that requires backports. labels Sep 25, 2024
@luolanzone
Copy link
Contributor Author

luolanzone commented Sep 25, 2024

I think this bug fix should be back-ported in case the users are already using IPPools CRs in their environments, the bug will block users to do any CR updates as well.

@@ -299,6 +299,8 @@ func installHandlers(c *ExtraConfig, s *genericapiserver.GenericAPIServer) {
s.Handler.NonGoRestfulMux.HandleFunc("/endpoint", endpoint.HandleFunc(c.endpointQuerier))
// Webhook to mutate Namespace labels and add its metadata.name as a label
s.Handler.NonGoRestfulMux.HandleFunc("/mutate/namespace", webhook.HandleMutationLabels())
s.Handler.NonGoRestfulMux.HandleFunc("/convert/ippool", webhook.HandleCRDConversion(ipam.ConvertIPPool))
Copy link
Member

Choose a reason for hiding this comment

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

I think validatingwebhook and conversionwebhook should enabled/disabled together if the APIs can be called, otherwise it would just fail with another error.

But I think it's intentional to not install the webhooks when the feature that uses the API are disabled, and this is not the only case where handlers are controlled by feature gates.

That being said, there is indeed a problem in the current code that IPPool is now used by not only FlexibleIPAM but also SecondaryNetwork, so the condition should be updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tnqn, so you mean to we should still block the webhook with a feature gate but update the condition with checking both FlexibleIPAM and SecondaryNetwork, and register it as long as one of them is enabled? I can update the commit. But I feel the conversion webhook failure leads confusion, not sure what's the best practice in K8s upstream, if we can't not define the webhook section conditionally, maybe we can reply a no-op conversion response when the feature is not enabled?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Think it a little bit more, no-ops response may also cause issues when the users enable the feature gate later and existing CRs may not be correct. I will update the commit with the right condition first. maybe check later to see if there is any best practice for this scenario.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we also need to back port this with the new condition?

Copy link
Member

Choose a reason for hiding this comment

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

Controlling the webhook handlers under feature gate is to isolate experimental code specific to a feature, as being alpha means they are not ready for production use yet. Running webhook code unconditionally breaks the principle and may risk the whole program.

Besides, in some cases the webhook handlers are stateful, meaning that they involve more code specific to a feature, like the networkpolicy validator. Almost all code for the feature needs to run to support the validator.

Sometimes it may make sense to install webhook handlers unconditionally, like when the code becomes very common and it's considered low risk. But avoiding webhook failure is not a valid exception, because we do need to validate and convert the requests, and the code does need to be feature gated. On the other hand, why would users use an API when none of the corresponding feature gates are enabled? AFAIK, the List API is the only exception as some discovery controllers may call it.

I think it can be backported but I guess IPPool and SecondaryNetwork hasn't really been used, because users would fail at the first step due to the issue.

@luolanzone luolanzone removed the action/backport Indicates a PR that requires backports. label Sep 26, 2024
@luolanzone luolanzone changed the title Avoid conversion webhook failure which blocks any IPPool CR creation Run IPPool webhook handler when SecondaryNetwork is enabled Sep 26, 2024
Copy link
Member

@tnqn tnqn left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@antoninbas antoninbas left a comment

Choose a reason for hiding this comment

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

Probably worth backporting, if the feature was completely broken without it.

@tnqn
Copy link
Member

tnqn commented Sep 30, 2024

/skip-all

@antrea-bot
Copy link
Collaborator

Can one of the admins verify this patch?

3 similar comments
@antrea-bot
Copy link
Collaborator

Can one of the admins verify this patch?

@antrea-bot
Copy link
Collaborator

Can one of the admins verify this patch?

@antrea-bot
Copy link
Collaborator

Can one of the admins verify this patch?

@tnqn tnqn merged commit 7be0f14 into antrea-io:main Sep 30, 2024
53 of 59 checks passed
@tnqn tnqn added the action/backport Indicates a PR that requires backports. label Sep 30, 2024
@luolanzone luolanzone deleted the fix-ippool-conversion-failure branch October 14, 2024 05:31
luolanzone added a commit to luolanzone/antrea that referenced this pull request Oct 14, 2024
luolanzone added a commit to luolanzone/antrea that referenced this pull request Oct 14, 2024
luolanzone added a commit to luolanzone/antrea that referenced this pull request Oct 14, 2024
luolanzone added a commit to luolanzone/antrea that referenced this pull request Oct 17, 2024
hangyan pushed a commit to hangyan/antrea that referenced this pull request Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action/backport Indicates a PR that requires backports. kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants