-
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: fix subset_lb crash when host configured with no metadata #15171
Changes from 2 commits
d4be14d
c5401fc
b46d0da
7d4f55e
01c5a75
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -216,4 +216,35 @@ TEST_P(HttpSubsetLbIntegrationTest, SubsetLoadBalancer) { | |||
runTest(type_b_request_headers_, "b"); | ||||
} | ||||
|
||||
// Tests subset-compatible load balancer policy without metadata does not crash on initialization. | ||||
TEST_P(HttpSubsetLbIntegrationTest, SubsetLoadBalancerNoMetadata) { | ||||
config_helper_.addConfigModifier([&](envoy::config::bootstrap::v3::Bootstrap& bootstrap) { | ||||
auto* static_resources = bootstrap.mutable_static_resources(); | ||||
auto* cluster = static_resources->mutable_clusters(0); | ||||
|
||||
// Set single_host_per_subset to be true | ||||
auto* subset_selector = cluster->mutable_lb_subset_config()->mutable_subset_selectors(0); | ||||
subset_selector->set_single_host_per_subset(true); | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like this crash is limited to when this option is enabled, could we be more explicit about this in the comments or test name? Maybe even add a test case where this is disabled for completeness sake. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this crash only happens when single_host_per_subset is set to be true. Without it subset_lb.cc:rebuildSingle() will bailout early hence no crash. I will add some comments here to cover this. |
||||
|
||||
// Clear the metadata for each host | ||||
auto* load_assignment = cluster->mutable_load_assignment(); | ||||
auto* endpoints = load_assignment->mutable_endpoints(0); | ||||
for (uint32_t i = 0; i < num_hosts_; i++) { | ||||
auto* lb_endpoint = endpoints->mutable_lb_endpoints(i); | ||||
lb_endpoint->clear_metadata(); | ||||
} | ||||
}); | ||||
|
||||
initialize(); | ||||
codec_client_ = makeHttpConnection(lookupPort("http")); | ||||
auto response = codec_client_->makeHeaderOnlyRequest( | ||||
Http::TestRequestHeaderMapImpl{{":method", "GET"}, | ||||
{":path", "/test/long/url"}, | ||||
{":scheme", "http"}, | ||||
{":authority", "host"}}); | ||||
response->waitForEndStream(); | ||||
EXPECT_TRUE(response->complete()); | ||||
EXPECT_THAT(response->headers(), Http::HttpStatusIs("404")); | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you know why this is giving a 404 instead of 503?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The configuration for this test is below: cluster and endpoints are configured. My understand is that with this configuration service is available, but page is not found, hence 404 is returned. static_resources: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually now that I think about it I think we're probably hitting a NR here and not actually hitting the bad code. I think the test file sets up a requirement for the header There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! Let me take a look. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
initialize(), which eventually call SubsetLoadBalancer::rebuildSingle() can trigger crash. We reproduced with this, also verified the fix with it.
... However, the newly added test function doesn't have type a/b metadata config, neither call runTest with the two different request types, it probably won't route via the subset lb.
Please let me know whether this addressed your question. Thanks! |
||||
} | ||||
asraa marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
|
||||
} // namespace Envoy |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
Maybe do
to reduce the nesting?
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.
sure, will do.