Repository navigation
upstream: network: mitigate tcp dns timeouts #12644
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
bbdbc63
network: bound TCP DNS lookups with the cancellation timer
cosmo0920 cca6587
upstream: identify configured endpoints in timeout logs
cosmo0920 2f7ba5a
tests: internal: cover DNS cancellation and timeout ordering
cosmo0920 6e42a54
tests: integration: verify upstream timeout logging
cosmo0920 5c15d2e
network: honor disabled connect timeout during DNS lookup
cosmo0920 dc86905
tests: internal: cover disabled TCP DNS deadlines
cosmo0920 01e24eb
network: declare asynchronous DNS lookup in the public header
cosmo0920 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
80 changes: 80 additions & 0 deletions
80
tests/integration/scenarios/networking/tests/test_upstream_timeout.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| """Exercise upstream timeout logging and retry completion against a silent peer.""" | ||
|
|
||
| from pathlib import Path | ||
| import socketserver | ||
| import threading | ||
|
|
||
| import pytest | ||
| import yaml | ||
|
|
||
| from utils.test_service import FluentBitTestService | ||
|
|
||
|
|
||
| class SilentPeer(socketserver.BaseRequestHandler): | ||
| def handle(self): | ||
| # Accept TCP but never answer the TLS handshake. | ||
| self.server.release.wait(30) | ||
|
|
||
|
|
||
| class SilentServer(socketserver.ThreadingTCPServer): | ||
| daemon_threads = True | ||
| allow_reuse_address = True | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("log_error", [True, False]) | ||
| def test_timeout_logs_configured_host_and_port(tmp_path, log_error): | ||
| server = SilentServer(("127.0.0.1", 0), SilentPeer) | ||
| server.release = threading.Event() | ||
| thread = threading.Thread(target=server.serve_forever, daemon=True) | ||
| thread.start() | ||
| port = server.server_address[1] | ||
| config = { | ||
| "service": { | ||
| "flush": 0.2, | ||
| "grace": 1, | ||
| "log_level": "debug", | ||
| "http_server": "on", | ||
| "http_port": "${FLUENT_BIT_HTTP_MONITORING_PORT}", | ||
| }, | ||
| "pipeline": { | ||
| "inputs": [{"name": "dummy", "samples": 1, "tag": "timeout"}], | ||
| "outputs": [{ | ||
| "name": "http", | ||
| "match": "*", | ||
| "host": "localhost", | ||
| "port": port, | ||
| "tls": "on", | ||
| "tls.verify": "off", | ||
| "net.dns.resolver": "LEGACY", | ||
| "net.connect_timeout": 2, | ||
| "net.connect_timeout_log_error": "on" if log_error else "off", | ||
| "retry_limit": "no_retries", | ||
| }], | ||
| }, | ||
| } | ||
| config_path = tmp_path / "timeout.yaml" | ||
| config_path.write_text(yaml.safe_dump(config), encoding="utf-8") | ||
| service = FluentBitTestService(str(config_path)) | ||
| try: | ||
| service.start() | ||
|
|
||
| def completed(): | ||
| logs = Path(service.flb.log_file).read_text(encoding="utf-8", errors="replace") | ||
| return logs if "is not retried (no retry config)" in logs else None | ||
|
|
||
| logs = service.wait_for_condition(completed, timeout=30, description="timed-out flush") | ||
| timeout_lines = [line for line in logs.splitlines() | ||
| if "[upstream]" in line and "timed out" in line] | ||
| assert timeout_lines, logs | ||
| assert any(f"to localhost:{port} timed out" in line for line in timeout_lines), logs | ||
| assert any(("[error]" if log_error else "[debug]") in line | ||
| for line in timeout_lines), logs | ||
| assert "unavailable:0" not in logs | ||
| finally: | ||
| try: | ||
| service.stop() | ||
| finally: | ||
| server.release.set() | ||
| server.shutdown() | ||
| server.server_close() | ||
| thread.join(timeout=5) |
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.