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

healthcheck: support TCP health check with ProxyProtocol #31691

Merged
merged 13 commits into from May 14, 2024

Conversation

Shikugawa
Copy link
Member

@Shikugawa Shikugawa commented Jan 8, 2024

Commit Message: healthcheck: support TCP health check with ProxyProtocol
Additional Description: This PR aims to support TCP healthcheck with ProxyProtocol. This feature is useful to ensure Proxy Protocol is enabled or not from upstream servers. It works in addition to normal TCP based healthcheck. This feature is the equivalent with check-send-proxy provided by HAProxy. https://cbonte.github.io/haproxy-dconv/2.0/configuration.html#5.2-check-send-proxy
Risk Level: Low
Testing: Unit/Integration
Docs Changes: Required
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional API Considerations:]

Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to (api/envoy/|docs/root/api-docs/).
envoyproxy/api-shepherds assignee is @lizan
CC @envoyproxy/api-watchers: FYI only for changes made to (api/envoy/|docs/root/api-docs/).

🐱

Caused by: #31691 was opened by Shikugawa.

see: more, trace.

@Shikugawa Shikugawa force-pushed the proxy-proto-hc branch 3 times, most recently from 246c869 to 44e9615 Compare January 9, 2024 03:19
@lizan
Copy link
Member

lizan commented Jan 10, 2024

/lgtm api

@zuercher for owner review

@Shikugawa
Copy link
Member Author

@zuercher friendly ping

Comment on lines 183 to 186
// When setting this value, it tries to attempt health check request with ProxyProtocol.
// Payload is sent after preceding ProxyProtocol header.
ProxyProtocolConfig proxy_protocol_config = 3;
Copy link
Member

Choose a reason for hiding this comment

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

For the comment, would prefer: "Use the proxy protocol for health checks. The send payload is sent immediately after the proxy protocol header."

Furthermore, is it valid to have an empty send payload when this flag is enabled? If so we should both document that and guard against configurations that leave send empty.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. Empty send payload is allowed when this flag is enabled. Let me fix.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry I forcefully pushed. The fixed commits are shown here. 495ba97#diff-4ccbbf045baa1ad3abd43bb7534d765e115e50be2ac9d9c3639588a4fd54e8a6R183-R185

bool should_write_data = false;

if (parent_.proxy_protocol_config_ != nullptr) {
Extensions::Common::ProxyProtocol::generateProxyProtoHeader(*parent_.proxy_protocol_config_,
Copy link
Member

Choose a reason for hiding this comment

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

There another proxy protocol command "local" which looks like it's meant for health checks (and that the remote server should use the connection endpoints and causes the endpoints in the protocol to be ignored). I think it's okay to use the command this function generates since we'll set the endpoints to be ourselves the server being health checked, but I thought I'd point it out.

Copy link
Member Author

@Shikugawa Shikugawa Jan 17, 2024

Choose a reason for hiding this comment

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

Actually I think it's enough to use local to check whether servers can accept ProxyProtocol or not. But the capability to fetch downstream info from ProxyProtocol header is the main focus of them. So some backend implementation may check the capability whether it can fetch downstream info or not (AFAIK I don't know the actual usecase. But it might be helpful).
So having generateProxyProtoHeader may help users more than using local directly.

Copy link
Member

@botengyao botengyao Jan 25, 2024

Choose a reason for hiding this comment

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

Could you elaborate more for the meaning of address setting in the Proxy Protocol header? The health check client's local address is the upstream local address, and the remote is the health check address of the remote host. I think this is different from the real upstream request which is using the downstream connection as the input of this generateProxyProtoHeader util.

I'd incline to add some comments for this, and describe the LOCAL as well as the address setting. Also could you add a test to see if the proxy protocol with address is actually sent/received?

Copy link
Member Author

@Shikugawa Shikugawa May 1, 2024

Choose a reason for hiding this comment

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

@botengyao @zuercher Hi. Sorry for late response.
I revisited how to provide this feature and came up with that we should provide this feature with LOCAL command for V2, and present local/remote address for V1 because it doesn't support them. It is because I found that some users faced confusion with this behavior to provide PROXY command for healthcheck in HAProxy community. haproxy/haproxy#511

So, I noticed the previous implementation may make users confused by the difference between Envoy and HAProxy's one. Thus, I cleaned the entire code in this patch to support them.

@Shikugawa Shikugawa force-pushed the proxy-proto-hc branch 4 times, most recently from 1476e57 to 8aca444 Compare January 17, 2024 17:36
Signed-off-by: Rei Shimizu <shimizu.rei@linecorp.com>
Signed-off-by: Rei Shimizu <shimizu.rei@linecorp.com>
zuercher
zuercher previously approved these changes Jan 18, 2024
Copy link
Member

@zuercher zuercher left a comment

Choose a reason for hiding this comment

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

@ilzan sorry, I asked for a comment change in the API and it needs to be re-approved.

Otherwise, lgtm.

@lizan
Copy link
Member

lizan commented Jan 19, 2024

/lgtm api

@lizan
Copy link
Member

lizan commented Jan 19, 2024

@Shikugawa one last thing, can you add a release note for the new field?

Signed-off-by: Rei Shimizu <shimizu.rei@linecorp.com>
Signed-off-by: Rei Shimizu <shimizu.rei@linecorp.com>
Signed-off-by: Rei Shimizu <shimizu.rei@linecorp.com>
Signed-off-by: Rei Shimizu <shimizu.rei@linecorp.com>
@zuercher
Copy link
Member

ping @Shikugawa

Copy link

This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@github-actions github-actions bot added the stale stalebot believes this issue/PR has not been touched recently label Apr 12, 2024
Copy link

This pull request has been automatically closed because it has not had activity in the last 37 days. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@github-actions github-actions bot closed this Apr 19, 2024
@Shikugawa Shikugawa reopened this Apr 20, 2024
@github-actions github-actions bot removed the stale stalebot believes this issue/PR has not been touched recently label Apr 20, 2024
Signed-off-by: Rei Shimizu <shimizu.rei@linecorp.com>
Signed-off-by: Rei Shimizu <shimizu.rei@linecorp.com>
Signed-off-by: Rei Shimizu <shimizu.rei@linecorp.com>
Signed-off-by: Rei Shimizu <shimizu.rei@linecorp.com>
@phlax
Copy link
Member

phlax commented May 6, 2024

@botengyao @zuercher i think this is waiting for final review

Copy link
Member

@zuercher zuercher left a comment

Choose a reason for hiding this comment

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

@lizan this needs API re-approval because a comment was updated

Copy link
Member

@lizan lizan left a comment

Choose a reason for hiding this comment

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

/lgtm api

@repokitteh-read-only repokitteh-read-only bot removed the api label May 9, 2024
Copy link
Member

@botengyao botengyao left a comment

Choose a reason for hiding this comment

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

/assign-from @envoyproxy/senior-maintainers

For a pass and merging.

zuercher
zuercher previously approved these changes May 10, 2024
Signed-off-by: Rei Shimizu <shimizu.rei@linecorp.com>
@Shikugawa
Copy link
Member Author

Shikugawa commented May 11, 2024

@zuercher Fixed conflict. Could you please approve again?

@ravenblackx
Copy link
Contributor

/retest

Copy link
Contributor

@ravenblackx ravenblackx left a comment

Choose a reason for hiding this comment

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

Approving the conflict-merge commit only, and assuming zuercher's review of everything before that still applies.

@ravenblackx ravenblackx enabled auto-merge (squash) May 14, 2024 15:40
@ravenblackx ravenblackx merged commit a3ecbf0 into envoyproxy:main May 14, 2024
52 of 53 checks passed
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.

None yet

6 participants