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

Configure Envoy alpn_protocols based on service protocol #14356

Merged
merged 22 commits into from
Oct 10, 2022
Merged

Configure Envoy alpn_protocols based on service protocol #14356

merged 22 commits into from
Oct 10, 2022

Conversation

oulman
Copy link
Contributor

@oulman oulman commented Aug 26, 2022

Description

This PR is largely based on @blake's work in #12170 but updated to use the TLSContext functions introduced in #13321. I'm not sure what the best path forward for configuring this from the Consul teams perspective but I wanted to raise a PR to start a conversation.

This fixes #11907, resolves #12106, and this internal feature request.

Testing & Reproduction steps

In my testing I verified that gRPC and HTTP2 services can negotiate h2 and http/1.1 and that services configured as HTTP will only negotiate http/1.1.

Links

Include any links here that might be helpful for people reviewing your PR (Tickets, GH issues, API docs, external benchmarks, tools docs, etc). If there are none, feel free to delete this section.

Please be mindful not to leak any customer or confidential information. HashiCorp employees may want to use our internal URL shortener to obfuscate links.

PR Checklist

  • updated test coverage
  • external facing docs updated
  • not a security concern

@github-actions github-actions bot added the theme/envoy/xds Related to Envoy support label Aug 26, 2022
@malizz
Copy link
Contributor

malizz commented Sep 2, 2022

Hi @oulman! Thanks for this PR, it looks good, but we can work on adding more tests and verifying the intended behavior.

@oulman
Copy link
Contributor Author

oulman commented Sep 5, 2022

Hi @malizz - Thanks! I've pushed a couple of changes.

  • The linter was failing because the error handling on ParseProxyConfig was empty. The original PR had a commented out call to a logger but I didn't see one available in the function. In the interim I went ahead and excluded that here
  • I created a test for getAlpnProtocol()
  • I added tests for http2 and grpc public listeners to validate that the Envoy alpn_protocols setting was getting configured correctly.

@oulman oulman changed the title [WIP] Configure Envoy alpn_protocols based on service protocol Configure Envoy alpn_protocols based on service protocol Sep 5, 2022
Copy link
Contributor

@malizz malizz left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for adding tests for grpc and http2 listeners.

@malizz
Copy link
Contributor

malizz commented Sep 8, 2022

@oulman Question: you made the changes to listeners tlsContext only, but I’m wondering if we need to update the TLS contexts for other listeners (ingress listener for example) or pass through clusters too.

@oulman
Copy link
Contributor Author

oulman commented Sep 9, 2022

Hi @malizz! I updated the context for the Ingress Gateway listener and added tests.

Looking at pass-through clusters I'm a little confused on what actually needs to be done to support this. I found some issues (#1, #2) that make it sound like for Envoy <-> Envoy traffic ALPN isn't used in protocol negotiation. If mesh-to-mesh is OK as-is, do we need to enable ALPN negotiation for external upstream HTTP clusters?

Thanks!

Copy link
Contributor

@malizz malizz left a comment

Choose a reason for hiding this comment

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

The PR looks mostly great. I added a question and requested a few changes. Thanks.

// Determine listener protocol type from configured service protocol. Don't hard fail on a config typo,
//The parse func returns default config if there is an error, so it's safe to continue.
cfg, _ := ParseProxyConfig(cfgSnap.Proxy.Config)

Copy link
Contributor

Choose a reason for hiding this comment

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

The default value for protocol in ParseProxyConfig function is tcp which is missing in getAlpnProtocols function. We can either add it to the switch cases or return an error if it's tcp.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤔 Right now calling getAlpnProtocols with tcp is returning an implicit nil because it's not matched. To confirm, we want to add an case statement for tcp but it should still return the empty alpnProtocols slice.

agent/xds/listeners_test.go Show resolved Hide resolved
agent/proxycfg/testing_ingress_gateway.go Show resolved Hide resolved
Copy link
Contributor

@malizz malizz left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

agent/xds/listeners.go Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme/envoy/xds Related to Envoy support
Projects
None yet
3 participants