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

[config/configretry] Allow zero multiplier and arbitrary randomization factor #9235

Merged
merged 4 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .chloggen/addretrysetvalidation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@ component: "exporterhelper"
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "Add RetrySettings validation function"

subtext: |
Validate that time.Duration, multiplier values in configretry are non-negative, and randomization_factor is between 0 and 1

# One or more tracking issues or pull requests related to the change
issues: [9089]
4 changes: 2 additions & 2 deletions config/configretry/backoff.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ func (bs *BackOffConfig) Validate() error {
if bs.RandomizationFactor < 0 || bs.RandomizationFactor > 1 {
return errors.New("'randomization_factor' must be within [0, 1]")
}
if bs.Multiplier <= 0 {
return errors.New("'multiplier' must be positive")
if bs.Multiplier < 0 {
return errors.New("'multiplier' must be non-negative")
}
if bs.MaxInterval < 0 {
return errors.New("'max_interval' must be non-negative")
Expand Down
9 changes: 8 additions & 1 deletion config/configretry/backoff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,17 @@ func TestInvalidRandomizationFactor(t *testing.T) {
func TestInvalidMultiplier(t *testing.T) {
cfg := NewDefaultBackOffConfig()
assert.NoError(t, cfg.Validate())
cfg.Multiplier = 0
cfg.Multiplier = -1
assert.Error(t, cfg.Validate())
}

func TestZeroMultiplierIsValid(t *testing.T) {
cfg := NewDefaultBackOffConfig()
assert.NoError(t, cfg.Validate())
cfg.Multiplier = 0
assert.NoError(t, cfg.Validate())
}

func TestInvalidMaxInterval(t *testing.T) {
cfg := NewDefaultBackOffConfig()
assert.NoError(t, cfg.Validate())
Expand Down
Loading