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

config dump, listeners are added to warming list if workers are not started yet #7511

Merged
merged 2 commits into from
Jul 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions source/server/listener_manager_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -441,13 +441,22 @@ ProtobufTypes::MessagePtr ListenerManagerImpl::dumpListenerConfigs() {
static_listener.mutable_listener()->MergeFrom(listener->config());
TimestampUtil::systemClockToTimestamp(listener->last_updated_,
*(static_listener.mutable_last_updated()));
continue;
}
envoy::admin::v2alpha::ListenersConfigDump_DynamicListener* dump_listener;
// Listeners are always added to active_listeners_ list before workers are started.
// This applies even when the listeners are still waiting for initialization.
// To avoid confusion in config dump, in that case, we add these listeners to warming
// listeners config dump rather than active ones.
if (workers_started_) {
dump_listener = config_dump->mutable_dynamic_active_listeners()->Add();
} else {
auto& dynamic_listener = *config_dump->mutable_dynamic_active_listeners()->Add();
dynamic_listener.set_version_info(listener->versionInfo());
dynamic_listener.mutable_listener()->MergeFrom(listener->config());
TimestampUtil::systemClockToTimestamp(listener->last_updated_,
*(dynamic_listener.mutable_last_updated()));
dump_listener = config_dump->mutable_dynamic_warming_listeners()->Add();
}
dump_listener->set_version_info(listener->versionInfo());
dump_listener->mutable_listener()->MergeFrom(listener->config());
TimestampUtil::systemClockToTimestamp(listener->last_updated_,
*(dump_listener->mutable_last_updated()));
}

for (const auto& listener : warming_listeners_) {
Expand Down
3 changes: 3 additions & 0 deletions test/integration/ads_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,9 @@ TEST_P(AdsIntegrationTest, ListenerDrainBeforeServerStart) {
Config::TypeUrl::get().Listener, {buildListener("listener_0", "route_config_0")},
{buildListener("listener_0", "route_config_0")}, {}, "1");
test_server_->waitForGaugeGe("listener_manager.total_listeners_active", 1);
// Before server is started, even though listeners are added to active list
// we mark them as "warming" in config dump since they're not initialized yet.
EXPECT_EQ(getListenersConfigDump().dynamic_warming_listeners().size(), 1);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@asraa Done.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you!


// Remove listener.
sendDiscoveryResponse<envoy::api::v2::Listener>(Config::TypeUrl::get().Listener, {}, {}, {}, "1");
Expand Down
4 changes: 2 additions & 2 deletions test/server/listener_manager_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,7 @@ filter_chains: {}
version_info: version1
static_listeners:
dynamic_active_listeners:
dynamic_warming_listeners:
version_info: "version1"
listener:
name: "foo"
Expand All @@ -777,7 +778,6 @@ version_info: version1
last_updated:
seconds: 1001001001
nanos: 1000000
dynamic_warming_listeners:
dynamic_draining_listeners:
)EOF");

Expand Down Expand Up @@ -808,6 +808,7 @@ per_connection_buffer_limit_bytes: 10
version_info: version2
static_listeners:
dynamic_active_listeners:
dynamic_warming_listeners:
version_info: "version2"
listener:
name: "foo"
Expand All @@ -820,7 +821,6 @@ version_info: version2
last_updated:
seconds: 2002002002
nanos: 2000000
dynamic_warming_listeners:
dynamic_draining_listeners:
)EOF");

Expand Down