Repository navigation
Send the master hostname as the Host header on the ws transport - #70998
Open
cestercian wants to merge 1 commit into
Open
cestercian wants to merge 1 commit into
cestercian wants to merge 1 commit into
Conversation
Websocket clients connect to the resolved master IP, so the HTTP Host header was that IP. A load balancer that routes on Host could not send those minions to the right master. When master is a hostname, pass that name in the Host header and keep the connection on the resolved IP.
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
The ws transport connects to the resolved master IP, so aiohttp sends that IP as the HTTP
Hostheader. A load balancer or proxy that routes onHostcan't send those minions to the right master.When
masteris a hostname and the connection target is the resolvedmaster_ip, the publish client and the request client now passHost: <master>:<port>tows_connect, and still connect to the resolved IP. The header is left alone whenmasteris an IP, unset, or a list, when the target isn'tmaster_ip, and for ipc/unix socket connections. IPv6 literals get bracketed. ZeroMQ and TCP are unchanged.What issues does this PR fix or reference?
Fixes #70988
Previous Behavior
The
Hostheader on ws transport connections was the master's resolved IP.New Behavior
The
Hostheader is the configured master hostname (with port), while the TCP connection still goes to the resolved IP.Merge requirements satisfied?
New tests in
tests/pytests/unit/transport/test_ws_host_header.pycover the hostname case for both clients plus the IP, list, unset, non-master target and ipc cases.pytest tests/pytests/unit/transport/ -k wspasses (20 passed), black 24.2.0 and isort 5.13.2 are clean.Commits signed with GPG?
Yes