Repository navigation
Don't count requests rejected before routing as service hits - #4387
Open
vitostrokov wants to merge 1 commit into
Open
vitostrokov wants to merge 1 commit into
vitostrokov wants to merge 1 commit into
Conversation
Nginx answers some requests, e.g. ones with a malformed request line, with 400 before the server-level `set $dstack_replica_hit 0` runs, so the flag is logged empty. The stats collector read these 4-field lines as pre-0.19.11 logs and counted them as replica hits, so stray internet traffic could scale a service up from zero. Tell the two cases apart by the trailing separator that the current log format leaves when the flag is empty, and treat an empty flag as no hit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Fixes #4384
Nginx rejects some requests, such as ones with a malformed request line, before the
server-level
set $dstack_replica_hit 0runs. The flag is then logged empty, and the line endsin a trailing space.
line.split()turned such lines into 4 cells, which the collector read aspre-0.19.11 log lines and counted as hits. A single stray request could then scale a service up
from zero.
The collector now splits on single spaces after stripping the newline. A current-format line
with an empty flag keeps 5 cells, and an empty flag counts as no hit. Legacy 4-field lines are
parsed as before.
Testing:
uv run pytest src/tests/_internal/proxy/gateway/: 60 passed.test_collect_stats[ignores-requests-rejected-before-routing]case fails without thefix.
uv run ruff checkanduv run ruff format --checkon the changed files: clean.🤖 Generated with Claude Code