Skip to content

Commit

Permalink
[configretry] Allow max_elapsed_time to be set to 0 (#9653)
Browse files Browse the repository at this point in the history
**Description:** [configretry] Allow max_elapsed_time to be set to 0

**Link to tracking Issue:**
#9641
  • Loading branch information
rnishtala-sumo authored Feb 27, 2024
1 parent 62beec3 commit 412ed26
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 6 deletions.
25 changes: 25 additions & 0 deletions .chloggen/configretry-validation-fix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Use this changelog template to create an entry for release notes.

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

# 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: Allow max_elapsed_time to be set to 0 for indefinite retries

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

# (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:

# 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]'
change_logs: []
13 changes: 8 additions & 5 deletions config/configretry/backoff.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,14 @@ func (bs *BackOffConfig) Validate() error {
if bs.MaxElapsedTime < 0 {
return errors.New("'max_elapsed_time' must be non-negative")
}
if bs.MaxElapsedTime < bs.InitialInterval {
return errors.New("'max_elapsed_time' must not be less than 'initial_interval'")
}
if bs.MaxElapsedTime < bs.MaxInterval {
return errors.New("'max_elapsed_time' must not be less than 'max_interval'")
if bs.MaxElapsedTime > 0 {
if bs.MaxElapsedTime < bs.InitialInterval {
return errors.New("'max_elapsed_time' must not be less than 'initial_interval'")
}
if bs.MaxElapsedTime < bs.MaxInterval {
return errors.New("'max_elapsed_time' must not be less than 'max_interval'")
}

}
return nil
}
6 changes: 6 additions & 0 deletions config/configretry/backoff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,17 @@ func TestInvalidMaxElapsedTime(t *testing.T) {
cfg.MaxElapsedTime = -1
assert.Error(t, cfg.Validate())
cfg.MaxElapsedTime = 60
// MaxElapsedTime is 60, InitialInterval is 5s, so it should be invalid
assert.Error(t, cfg.Validate())
cfg.InitialInterval = 0
// MaxElapsedTime is 60, MaxInterval is 30s, so it should be invalid
assert.Error(t, cfg.Validate())
cfg.MaxInterval = 0
assert.NoError(t, cfg.Validate())
cfg.InitialInterval = 50
// MaxElapsedTime is 0, so it should be valid
cfg.MaxElapsedTime = 0
assert.NoError(t, cfg.Validate())
}

func TestDisabledWithInvalidValues(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion exporter/exporterhelper/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The following configuration options can be modified:
- `enabled` (default = true)
- `initial_interval` (default = 5s): Time to wait after the first failure before retrying; ignored if `enabled` is `false`
- `max_interval` (default = 30s): Is the upper bound on backoff; ignored if `enabled` is `false`
- `max_elapsed_time` (default = 300s): Is the maximum amount of time spent trying to send a batch; ignored if `enabled` is `false`
- `max_elapsed_time` (default = 300s): Is the maximum amount of time spent trying to send a batch; ignored if `enabled` is `false`. If set to 0, the retries are never stopped.
- `sending_queue`
- `enabled` (default = true)
- `num_consumers` (default = 10): Number of consumers that dequeue batches; ignored if `enabled` is `false`
Expand Down

0 comments on commit 412ed26

Please sign in to comment.