Skip to content

xds: remove warming listeners in xDS SOTW updates#12461

Merged
asraa merged 8 commits intoenvoyproxy:masterfrom
samflattery:lds_warm
Aug 10, 2020
Merged

xds: remove warming listeners in xDS SOTW updates#12461
asraa merged 8 commits intoenvoyproxy:masterfrom
samflattery:lds_warm

Conversation

@samflattery
Copy link
Contributor

Signed-off-by: Sam Flattery samflattery@google.com

Commit Message: Remove warming listeners in xDS SOTW updates
Additional Description:

  • my xDS fuzzer timed out on OSS fuzz here because Envoy does not remove warming listeners when they are left out of a SOTW update like it removes active ones
  • changes LdsApiImpl::onConfigUpdate to use a new function in ListenerManagerImpl, allListeners() instead of the old listeners() which just returns active listeners to compute the diff between the update and the current SOTW
  • changed lds_api_test.cc to use this new function

Risk Level: Medium
Testing: passes regression corpus entry, passes lds_api_test.cc
Docs Changes: N/A
Release Notes: N/A
Fixes: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=24600

Signed-off-by: Sam Flattery <samflattery@google.com>
@samflattery
Copy link
Contributor Author

/cc @asraa

@samflattery
Copy link
Contributor Author

/retest

@repokitteh-read-only
Copy link

🔨 rebuilding ci/circleci: docs (failed build)

🐱

Caused by: a #12461 (comment) was created by @samflattery.

see: more, trace.

@dio dio assigned asraa Aug 4, 2020
@samflattery
Copy link
Contributor Author

Pipelines seems to be down https://status.dev.azure.com/

* existing listeners. The references are only valid in the context of the current call stack and
* should not be stored.
*/
virtual std::vector<std::reference_wrapper<Network::ListenerConfig>> allListeners() PURE;
Copy link
Contributor

Choose a reason for hiding this comment

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

When changing the API of a class, think about how the methods look in code that uses the class. Do the names of functions make it clear what is happening?

In this case, the class has two public methods:

listeners() : Returns some of the listeners.
allListeners(): Returns all of the listeners.

If I saw a call to listeners() in some code, I would not expect that it returns some listeners, or know which ones.

Ideas to fix this:

  1. Rename listeners() to loadedListners(), activeListners(), etc.

  2. Make the type of listeners to return an enum:

  enum ListenerState {
     ACTIVE = 1,
     WARMING = 2,
     ALL = 3
  }

Function listeners(ListenerState state) would return the listeners in the given state.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback. I was thinking of changing listeners() to activeListeners() but I didn't want to be too disruptive to the code base since listeners() is used in a lot of different places (mostly in tests). But if you're happy enough with this I can go ahead and do it.

Copy link
Contributor

Choose a reason for hiding this comment

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

@asraa knows this code better than I do, and I would defer to her judgement.

Copy link
Contributor

Choose a reason for hiding this comment

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

(2) Along with draining listeners might be good. It can default to active listeners as currently used. @lambdai What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

I am fine to add draining listener in the query.
Though to fix the fuzzer issue we don't need the names in drain list.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I'll do this and add draining listeners too

@mattklein123
Copy link
Member

cc @lambdai PTAL

Copy link
Contributor

@lambdai lambdai left a comment

Choose a reason for hiding this comment

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

Nice diagnose!!

Could you add a new test case in ListenerManagerImplTest beside
TEST_F(ListenerManagerImplTest, RemoveListener)?

You may want to

  1. start the workers
  2. provide a lds response with an unique name
  3. don't call ready() of the new listener
  4. provide a lds response w/o that unique name
    And see if the listeners are erased from the new allListeners().

* existing listeners. The references are only valid in the context of the current call stack and
* should not be stored.
*/
virtual std::vector<std::reference_wrapper<Network::ListenerConfig>> allListeners() PURE;
Copy link
Contributor

Choose a reason for hiding this comment

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

I am fine to add draining listener in the query.
Though to fix the fuzzer issue we don't need the names in drain list.

Signed-off-by: Sam Flattery <samflattery@google.com>
@samflattery
Copy link
Contributor Author

@lambdai

  1. provide a lds response with an unique name
  2. don't call ready() of the new listener
  3. provide a lds response w/o that unique name
    And see if the listeners are erased from the new allListeners().

I looked into this and I'm not sure if this is possible in ListenerManagerImplTest since it doesn't have access to an LdsApiImpl, just an LdsApi, which only has a versionInfo method and not an onConfigUpdate which is what we need.

class MockLdsApi : public LdsApi {
public:
MOCK_METHOD(std::string, versionInfo, (), (const));
};

I could do it in lds_api_test.cc but I think it would end up being identical to this test

makeListenersAndExpectCall({"listener1", "listener2"});
EXPECT_CALL(listener_manager_, removeListener("listener2")).WillOnce(Return(true));
expectAdd("listener1", "1", false);
expectAdd("listener3", "1", true);
EXPECT_CALL(listener_manager_, endListenerUpdate(_));
const auto decoded_resources_2 =
TestUtility::decodeResources<envoy::config::listener::v3::Listener>(response2);
lds_callbacks_->onConfigUpdate(decoded_resources_2.refvec_, response2.version_info());
since there's no real way to add in warming/active listeners beyond making expectations of the return of listeners() which is what that test does.

Signed-off-by: Sam Flattery <samflattery@google.com>
@samflattery
Copy link
Contributor Author

samflattery commented Aug 5, 2020

Failing //test/integration:protocol_integration_test, might be a flake? Passes locally on --runs_per_test=10 and doesn't seem to touch any LDS code

edit: also failing //test/extensions/transport_sockets/tls/integration:ssl_integration_test which is also passing locally with asan enabled

Signed-off-by: Sam Flattery <samflattery@google.com>
Signed-off-by: Sam Flattery <samflattery@google.com>
sqkerner
sqkerner previously approved these changes Aug 6, 2020
@asraa
Copy link
Contributor

asraa commented Aug 6, 2020

since there's no real way to add in warming/active listeners beyond making expectations of the return of listeners() which is what that test does.

Is it possible to reproduce this in ads_integration_test? Just looking for unit test coverage (since this is a slight functional change)

@samflattery
Copy link
Contributor Author

@asraa that's definitely possible. I'll do that now

Signed-off-by: Sam Flattery <samflattery@google.com>
@samflattery
Copy link
Contributor Author

@asraa added

@asraa
Copy link
Contributor

asraa commented Aug 7, 2020

@lambdai If the test looks good to you, this has my LGTM.

lambdai
lambdai previously approved these changes Aug 8, 2020
Copy link
Contributor

@lambdai lambdai left a comment

Choose a reason for hiding this comment

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

The comment should start with capital letter and end with period.

The code LGTM. Thanks!

Signed-off-by: Sam Flattery <samflattery@google.com>
@samflattery
Copy link
Contributor Author

@lambdai @asraa fixed the comments

Copy link
Contributor

@asraa asraa left a comment

Choose a reason for hiding this comment

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

Thanks!

@asraa asraa merged commit bb3571a into envoyproxy:master Aug 10, 2020
@samflattery samflattery deleted the lds_warm branch August 10, 2020 12:40
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.

5 participants