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 2 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
26 changes: 26 additions & 0 deletions .chloggen/mx-psi_configretry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
component: configretry

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Validate that time.Duration and multiplier values in configretry are non-negative.

# One or more tracking issues or pull requests related to the change
issues: [9091]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext: |
These values were previously accepted and lead to unspecified behavior.

# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
codeboten marked this conversation as resolved.
Show resolved Hide resolved
change_logs: []
7 changes: 2 additions & 5 deletions config/configretry/backoff.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,8 @@ func (bs *BackOffConfig) Validate() error {
if bs.InitialInterval < 0 {
return errors.New("'initial_interval' must be non-negative")
}
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
10 changes: 4 additions & 6 deletions config/configretry/backoff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,18 @@ func TestInvalidInitialInterval(t *testing.T) {
assert.Error(t, cfg.Validate())
}

func TestInvalidRandomizationFactor(t *testing.T) {
func TestInvalidMultiplier(t *testing.T) {
cfg := NewDefaultBackOffConfig()
assert.NoError(t, cfg.Validate())
cfg.RandomizationFactor = -1
assert.Error(t, cfg.Validate())
cfg.RandomizationFactor = 2
cfg.Multiplier = -1
assert.Error(t, cfg.Validate())
}

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

func TestInvalidMaxInterval(t *testing.T) {
Expand Down
Loading