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

upstream: log metadata used to create subset lbs #2772

Merged

Conversation

zuercher
Copy link
Member

@zuercher zuercher commented Mar 9, 2018

Per a slack conversation, it would be useful is the subset load balancer logged the metadata it used to create it's underlying loadbalancers. This modifies the subset load balancer to track the default subset using the same data type used for non-default subsets (thereby eliminating the hostMatchesDefaultSubset function). Logging occurs at the debug level.

Signed-off-by: Stephan Zuercher stephan@turbinelabs.io

Risk Level: Low

Testing: existing unit tests cover the aded code and prove that no functional changes occurred.

Signed-off-by: Stephan Zuercher <stephan@turbinelabs.io>
@junr03
Copy link
Member

junr03 commented Mar 12, 2018

@dnoe do you mind taking a first pass?

Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

I think this change will conflict with our other change, but a couple of comments for after that one merges tomorrow.

return;
}

HostPredicate predicate;

if (fallback_policy_ == envoy::api::v2::Cluster::LbSubsetConfig::ANY_ENDPOINT) {
bool fallback_any = (fallback_policy_ == envoy::api::v2::Cluster::LbSubsetConfig::ANY_ENDPOINT) ||
Copy link
Member

Choose a reason for hiding this comment

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

nit: const

@@ -273,6 +274,26 @@ SubsetLoadBalancer::extractSubsetMetadata(const std::set<std::string>& subset_ke
return kvs;
}

std::string SubsetLoadBalancer::describeMetadata(const SubsetLoadBalancer::SubsetMetadata& kvs) {
Copy link
Member

Choose a reason for hiding this comment

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

Can we test this somehow? I think especially with #2751 this won't even get run in most normal cases.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added a test case for this.

Signed-off-by: Stephan Zuercher <stephan@turbinelabs.io>
{"tcp://127.0.0.1:81", {{"version", "default"}}},
});

upstream_logger->setLevel(spdlog::level::err);
Copy link
Member

Choose a reason for hiding this comment

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

If someone configured a different log level for testing on the CLI with --test_arg, won't this overwrite it after the test runs? I wish there was a better way of doing a test like this, but at minimum should we capture the previous log level so we can reset it?

Copy link
Member

Choose a reason for hiding this comment

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

One option would be to just test the print function directly and not the logging. Up to you.

Signed-off-by: Stephan Zuercher <stephan@turbinelabs.io>
Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

nice!

@@ -232,21 +244,6 @@ void SubsetLoadBalancer::update(uint32_t priority, const HostVector& hosts_added
});
}

bool SubsetLoadBalancer::hostMatchesDefaultSubset(const Host& host) {
Copy link
Member

Choose a reason for hiding this comment

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

Nice cleanup

@zuercher zuercher merged commit 12434be into envoyproxy:master Mar 22, 2018
@zuercher zuercher deleted the stephan/log-subset-lb-criteria branch March 22, 2018 22:12
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.

4 participants