Skip to content

Commit a42c24d

Browse files
committed
mantle/util/retry: add more debug statements to retry function
- Print a little more information about the errors that are encountered on each try. - Print out the amount of time remaining until the timeout occurs.
1 parent 30480db commit a42c24d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

mantle/util/retry.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ func RetryConditional(attempts int, delay time.Duration, shouldRetry func(err er
5353
// between each try based on the given delay.
5454
func RetryUntilTimeout(timeout, delay time.Duration, f func() error) error {
5555
after := time.After(timeout)
56+
deadline := time.Now().Add(timeout)
5657
for {
5758
select {
5859
case <-after:
@@ -63,9 +64,11 @@ func RetryUntilTimeout(timeout, delay time.Duration, f func() error) error {
6364
// how long it takes remote network requests to finish.
6465
start := time.Now()
6566
err := f()
66-
plog.Debugf("RetryUntilTimeout: f() took %v", time.Since(start))
67+
plog.Debugf("RetryUntilTimeout: f() took %v. %v until timeout.", time.Since(start), time.Until(deadline).Round(time.Second))
6768
if err == nil {
6869
break
70+
} else {
71+
plog.Debugf("RetryUntilTimeout: f() returned error: %s", err)
6972
}
7073
time.Sleep(delay)
7174
}

0 commit comments

Comments
 (0)