Skip to content

Commit

Permalink
promdump: fix crash in error handling
Browse files Browse the repository at this point in the history
The call to promRetryWait to calculate the sleep time was moved before the calls that check whether a particular error is fatal, retryable, etc.. This led to the actual error we're trying to test being masked by the error return from promRetryWait, leading to a nil error being passed into promErrIssFatal and causing a crash.

This commit changes the name of the variable holding the error return from promRetryWait in order to prevent the crash.
  • Loading branch information
ionthegeek committed Sep 9, 2024
1 parent c75ae68 commit 05752ce
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions promdump/promdump.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,9 +483,9 @@ func exportMetric(ctx context.Context, promApi v1.API, metric string, beginTS ti
break batchBackoff
}

sleepTime, err := promRetryWait(retryCount, *promRetryDelay, *promRetryMaxBackoff, *promRetryBackoff)
if err != nil {
logger.Fatalf("exportMetric: failed to calculate retry delay: %v", err)
sleepTime, retryErr := promRetryWait(retryCount, *promRetryDelay, *promRetryMaxBackoff, *promRetryBackoff)
if retryErr != nil {
logger.Fatalf("exportMetric: failed to calculate retry delay: %v", retryErr)
}

if promErrIsFatal(err) {
Expand Down

0 comments on commit 05752ce

Please sign in to comment.