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

listener: fixed a bug where the addresses cannot be updated partially #38601

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

wbpcode
Copy link
Member

@wbpcode wbpcode commented Feb 28, 2025

Commit Message: listener: fixed a bug where the addresses cannot be updated partially
Additional Description:

To close #37373. The #37373 was opened for a while and there is some related PR try to fixed it. See #37396 #38530. Thanks for the great contribution from @Shikugawa and @bbassingthwaite.

Their works is great and make sense. But I want a clean patch to fixed all LDS updating problems (not only the #37373). The exist logic and checks are pretty confusing and hard to maintain. So, I think we'd better to do complete refactring/clean up rather than only fix the #37373. So, I created this PR.


If we treat the addresses self and socket options as a whole entity. The rules of LDS updating of same Listener is pretty simple:

  1. If the whole entity is completely same: clone the sockets and no matter reuse port is enabled or not.
  2. If the whole entity is completely different: create new sockets and not matter resue port is enabled or not.
  3. If the whole entity is partially updated: create new sockets and require reuse port to true.

The conditional duplicated addresses checking (of different versions of same listener) could cover 2 and 3 easily. If the reuse port is enabled, we can skip the check because we can create new sockets anyway. If the resue port is disabled, we need this check and partially updating will be rejected or if all addresses are different, the update still could be accpeted.

Risk Level: mid. core code change. It would be better to let two senior maintainers to check this PR.
Testing: unit.
Docs Changes: n/a.
Release Notes: added.
Platform Specific Features: n/a.

Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to (api/envoy/|docs/root/api-docs/).
envoyproxy/api-shepherds assignee is @abeyad
CC @envoyproxy/api-watchers: FYI only for changes made to (api/envoy/|docs/root/api-docs/).

🐱

Caused by: #38601 was opened by wbpcode.

see: more, trace.

@wbpcode wbpcode assigned ggreenway and Shikugawa and unassigned abeyad Feb 28, 2025
@wbpcode
Copy link
Member Author

wbpcode commented Feb 28, 2025

I personally this refactoring will make our future life and maintaining easier. But It would be super appreciated if you can check it to see if I missed something. cc @Shikugawa

Copy link
Contributor

@abeyad abeyad left a comment

Choose a reason for hiding this comment

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

/lgtm api

wangbaiping(wbpcode) added 2 commits February 28, 2025 15:44
Signed-off-by: wangbaiping(wbpcode) <[email protected]>
Signed-off-by: wangbaiping(wbpcode) <[email protected]>
// Check if the listener has duplicated address with existing listeners.

for (const auto& existing_listener : listener_list) {
if (listener.reusePort() && existing_listener->name() == listener.name()) {
Copy link
Member

@Shikugawa Shikugawa Mar 2, 2025

Choose a reason for hiding this comment

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

I prefer to reject reuse_port == false and the listeners with the same name listen with the duplicated address early as my original PR.

if (existing_listener.hasDuplicatedAddress(new_listener) && new_listener.reusePort() == false) {
return absl::InvalidArgumentError(fmt::format("Listener {}: doesn't support update addresses "
"when the reuse port isn't enabled",
new_listener.name()));
}

In this implementation, the user can receive only messages that identify "listening address is duplicated". I guess the users may confused about the message, and can't know why this configuration is rejected.

Copy link
Member

@Shikugawa Shikugawa Mar 2, 2025

Choose a reason for hiding this comment

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

Oh, But I think this message helps users to understand the root cause. So personally current implementation is LGTM.

ENVOY_LOG(warn, "To check if the listener has duplicated addresses with other listeners or "
"'enable_reuse_port' is set to 'false' for the listener");

// Check if the listener has duplicated address with existing listeners.

for (const auto& existing_listener : listener_list) {
if (listener.reusePort() && existing_listener->name() == listener.name()) {
Copy link
Member

@Shikugawa Shikugawa Mar 2, 2025

Choose a reason for hiding this comment

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

Oh, But I think this message helps users to understand the root cause. So personally current implementation is LGTM.

ENVOY_LOG(warn, "To check if the listener has duplicated addresses with other listeners or "
"'enable_reuse_port' is set to 'false' for the listener");

@wbpcode
Copy link
Member Author

wbpcode commented Mar 3, 2025

/retest

Copy link
Contributor

@bbassingthwaite bbassingthwaite left a comment

Choose a reason for hiding this comment

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

Thanks @wbpcode

Copy link
Contributor

@ggreenway ggreenway left a comment

Choose a reason for hiding this comment

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

Makes sense to me. Thanks for cleaning this up!

/wait

@@ -400,6 +400,95 @@ name: bar
addOrUpdateListener(parseListenerFromV3Yaml(yaml2));
}

TEST_P(ListenerManagerImplWithRealFiltersTest, AllowAddressesUpdateParitially) {
const std::string yaml1 = R"EOF(
name: foo
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a comment saying what part of the listener config is changing so the reader doesn't have to manually diff the two configs in their head.

Signed-off-by: wangbaiping(wbpcode) <[email protected]>
@wbpcode wbpcode requested a review from ggreenway March 6, 2025 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error updating listener (via ADS) using additional_addresses
5 participants