feat: add polling jitter to target manager intervals#433
Open
lvlcn-t wants to merge 4 commits into
Open
Conversation
1c41f4d to
e45dd4e
Compare
e59bba7 to
d64283c
Compare
c019974 to
878a529
Compare
d64283c to
2d409cb
Compare
878a529 to
2cf5259
Compare
2d409cb to
1d1af15
Compare
niklastreml
reviewed
May 11, 2026
1d1af15 to
b27be38
Compare
Apply configurable jitter to check, registration, and update timer resets to prevent thundering-herd when many sparrow instances poll the same backend simultaneously. - Add helper.ApplyJitter with bounded minimum [d*(1-f), d] - Add Jitter float64 field to General config with [0.0, 1.0] validation - Wire jitter into manager.Reconcile timer resets - Add jitter tests (helper bounds + validation cases) - Document jitter in chart/values.yaml
Replace the hand-rolled 1000-iteration bounds check with a proper Go fuzz test (FuzzApplyJitter) that generates random duration/factor pairs and asserts invariant properties. Add NaN/Inf guards to ApplyJitter to handle degenerate float inputs defensively. - Add math.IsNaN/IsInf guard in ApplyJitter (treat as identity) - Add FuzzApplyJitter with 8 seed corpus entries - Keep deterministic TestApplyJitter_EdgeCases for NaN/Inf/zero
Signed-off-by: lvlcn-t <75443136+lvlcn-t@users.noreply.github.com>
804409f to
d847c29
Compare
b27be38 to
2f9d8f3
Compare
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.
Motivation
When many sparrow instances share the same polling intervals, they
synchronize into a thundering herd — all hitting the backend at the same
instant. Adding jitter spreads requests over time, reducing peak load on
the S3/GitLab backend and improving resilience.
Stack: PR 4/4 — builds on #432 (OIDC auth).
Changes
helper.ApplyJitter(d, factor)ininternal/helper/jitter.gowithbounded minimum
[d*(1-factor), d]NaNandInffactor inputs (treat as identity)Jitter float64field toGeneralconfig struct with[0.0, 1.0]validation and
ErrInvalidJittersentinelmanager.Reconcile()on all three timer resets(check, registration, update)
FuzzApplyJitterfuzz test (~3.7M executions, no failures) withproperty-based assertions (bounded minimum, never exceeds original,
non-negative result)
TestApplyJitter_EdgeCasesfor NaN/Inf/zerochart/values.yamlFor additional information look at the commits.
Tests done
TODO