Skip to content

grid: Use the alternate protocols cache in the grid - #16347

Merged
alyssawilk merged 9 commits into
envoyproxy:mainfrom
RyanTheOptimist:UseAlternateProtocols
May 6, 2021
Merged

alyssawilk merged 9 commits into
envoyproxy:mainfrom
RyanTheOptimist:UseAlternateProtocols

Conversation

@RyanTheOptimist

Copy link
Copy Markdown
Contributor

Allow the ConnectivityGrid to take an optional AlternateProtocolsCache and use that for deciding if HTTP/3 should be enabled.
Rename AlternateProtocols to AlternateProtocolsCache.
Use uint32_t instead of int for ports in AlternateProtocolsCache to match other code in Envoy.

Follow up PRs will make the AlternateProtocolsCache mandatory and will plumb it in from the ClusterManager, based on the config.

Risk Level: Low
Testing: new unit tests
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

and use that for deciding if HTTP/3 should be enabled.

Signed-off-by: Ryan Hamilton <[email protected]>
Signed-off-by: Ryan Hamilton <[email protected]>
Signed-off-by: Ryan Hamilton <[email protected]>
Signed-off-by: Ryan Hamilton <[email protected]>
Signed-off-by: Ryan Hamilton <[email protected]>
Signed-off-by: Ryan Hamilton <[email protected]>
@RyanTheOptimist

RyanTheOptimist commented May 5, 2021 •

Copy link
Copy Markdown
Contributor Author

/assign @DavidSchinazi
PTAL. The alternate_protocols_cache.cc was moved from alternate_protocols.cc but git doesn't seem to know that :/ I could send you a manual diff if that would be helpful? Oh! Or you can look at the changes in the first commit (6a6efc7).

@RyanTheOptimist

Copy link
Copy Markdown
Contributor Author

/assign @DavidSchinazi

@DavidSchinazi DavidSchinazi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice!

Comment thread source/common/http/conn_pool_grid.cc Resolved
Comment thread source/common/http/conn_pool_grid.cc Outdated
return false;
}
if (!alternate_protocols_.has_value()) {
// TODO(RyanTheOptimist): Make the alternate protocols cache required.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: how about this? // TODO(RyanTheOptimist): Do not attempt HTTP/3 when the alternate protocols cache is missing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Well, I could do that but that's not the goal of this TODO :) The goal of the TODO is that the Grid is always constructed with an AlternateProtocolsCache. I can't easily do that as part of this PR (I'll be doing in 2 PRs down the road) because in order to do this, we need to construct per-config AlternateProtocolCaches which requires a bunch of plumbing. I have that queued up, but it's a lot of unrelated work.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah I see, in that case how about // TODO(RyanTheOptimist): Make the alternate_protocols_ member non-optional. Additionally, maybe move the TODO to the definition of that member variable?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done!

Comment thread source/common/http/conn_pool_grid.cc Resolved
Comment thread source/common/http/conn_pool_grid.cc Resolved
Comment thread test/common/http/conn_pool_grid_test.cc Resolved
Comment thread test/common/http/conn_pool_grid_test.cc Resolved
Comment thread test/common/http/conn_pool_grid_test.cc Resolved
Comment thread test/common/http/conn_pool_grid_test.cc Resolved
Comment thread test/common/http/conn_pool_grid_test.cc Resolved
Signed-off-by: Ryan Hamilton <[email protected]>
Signed-off-by: Ryan Hamilton <[email protected]>

@RyanTheOptimist RyanTheOptimist left a comment

Copy link
Copy Markdown
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 great review!

Comment thread source/common/http/conn_pool_grid.cc Resolved
Comment thread source/common/http/conn_pool_grid.cc Outdated
return false;
}
if (!alternate_protocols_.has_value()) {
// TODO(RyanTheOptimist): Make the alternate protocols cache required.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Well, I could do that but that's not the goal of this TODO :) The goal of the TODO is that the Grid is always constructed with an AlternateProtocolsCache. I can't easily do that as part of this PR (I'll be doing in 2 PRs down the road) because in order to do this, we need to construct per-config AlternateProtocolCaches which requires a bunch of plumbing. I have that queued up, but it's a lot of unrelated work.

Comment thread source/common/http/conn_pool_grid.cc Resolved
// changing dynamically.
for (const quic::ParsedQuicVersion& version : quic::CurrentSupportedVersions()) {
if (quic::AlpnForVersion(version) == protocol.alpn_) {
ENVOY_LOG(trace, "HTTP/3 advertised for host '{}'", host_->hostname());

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Nope, but that's on my queue to address. I suspect it's going to be an "exciting" prospect because the newStream() method doesn't have an obvious way to pass metadata down into the connection pool. I'll definitely get it sorted out, but not yet.

Comment thread test/common/http/conn_pool_grid_test.cc Resolved
Comment thread test/common/http/conn_pool_grid_test.cc Resolved
Comment thread test/common/http/conn_pool_grid_test.cc Resolved
Comment thread source/common/http/conn_pool_grid.cc Resolved
Comment thread source/common/http/conn_pool_grid.cc Resolved
@RyanTheOptimist

Copy link
Copy Markdown
Contributor Author

/assign @alyssawilk

Signed-off-by: Ryan Hamilton <[email protected]>

@DavidSchinazi DavidSchinazi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks!

@alyssawilk alyssawilk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LG modulo nits.
Normally I'd ask these get fixed before merging but given I know you've already got follow-up PRs in this space and it's not used in prod and I'm out tomorrow, if you wan to address them in a follow-up I'm game. LMK

}
uint32_t port = host_->address()->ip()->port();
// TODO(RyanTheOptimist): Figure out how scheme gets plumbed in here.
AlternateProtocolsCache::Origin origin("https", host_->hostname(), port);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: Headers::get().SchemeValues.Https

return false;
}
uint32_t port = host_->address()->ip()->port();
// TODO(RyanTheOptimist): Figure out how scheme gets plumbed in here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think commenting that we only support secure QUIC regardless of url scheme would be fine.

}

ENVOY_LOG(trace, "HTTP/3 is not available to host '{}', skipping.", host_->hostname());
return false;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

seems like a good place to start adding stats, WDYT? Can defer to a follow up but let's make sure we have stats as we wire this all up.

EXPECT_LOG_CONTAINS("trace",
"No alternate protocols available for host 'hostname', skipping HTTP/3.",
EXPECT_NE(grid_.newStream(decoder_, callbacks_), nullptr));
EXPECT_NE(grid_.first(), nullptr);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

To your point about having explicit h2 and h3 pools I think we should be skipping creating the H3 pool if we're not going to attempt H3.

@alyssawilk
alyssawilk merged commit 4c078ed into envoyproxy:main May 6, 2021
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.

3 participants