diff --git a/.chloggen/addretrysetvalidation.yaml b/.chloggen/addretrysetvalidation.yaml index db6b49d0309..e6ace8b2555 100755 --- a/.chloggen/addretrysetvalidation.yaml +++ b/.chloggen/addretrysetvalidation.yaml @@ -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] diff --git a/config/configretry/backoff.go b/config/configretry/backoff.go index c3ffc68fe8d..f872600846d 100644 --- a/config/configretry/backoff.go +++ b/config/configretry/backoff.go @@ -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") diff --git a/config/configretry/backoff_test.go b/config/configretry/backoff_test.go index 8c9bf7f41c3..417ebe86161 100644 --- a/config/configretry/backoff_test.go +++ b/config/configretry/backoff_test.go @@ -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())