-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
upstream: log metadata used to create subset lbs #2772
Conversation
Signed-off-by: Stephan Zuercher <stephan@turbinelabs.io>
@dnoe do you mind taking a first pass? |
There was a problem hiding this 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.
source/common/upstream/subset_lb.cc
Outdated
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) || |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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>
There was a problem hiding this 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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice cleanup
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.