@@ -17,8 +17,12 @@ import (
17
17
"github.com/sirupsen/logrus"
18
18
)
19
19
20
- // bodyReaderMinimumProgress is the minimum progress we want to see before we retry
21
- const bodyReaderMinimumProgress = 1 * 1024 * 1024
20
+ const (
21
+ // bodyReaderMinimumProgress is the minimum progress we consider a good reason to retry
22
+ bodyReaderMinimumProgress = 1 * 1024 * 1024
23
+ // bodyReaderMSSinceLastRetry is the minimum time since a last retry we consider a good reason to retry
24
+ bodyReaderMSSinceLastRetry = 60 * 1_000
25
+ )
22
26
23
27
// bodyReader is an io.ReadCloser returned by dockerImageSource.GetBlob,
24
28
// which can transparently resume some (very limited) kinds of aborted connections.
@@ -221,13 +225,21 @@ func (br *bodyReader) errorIfNotReconnecting(originalErr error, redactedURL stri
221
225
logrus .Debugf ("Reading blob body from %s failed (%#v), decision inputs: total %d @%.3f ms, last retry %d @%.3f ms, last progress @%.3f ms" ,
222
226
redactedURL , originalErr , br .offset , msSinceFirstConnection , br .lastRetryOffset , msSinceLastRetry , msSinceLastSuccess )
223
227
progress := br .offset - br .lastRetryOffset
224
- if progress < bodyReaderMinimumProgress {
225
- logrus .Debugf ("Not reconnecting to %s because only %d bytes progress made" , redactedURL , progress )
226
- return fmt .Errorf ("(heuristic tuning data: total %d @%.3f ms, last retry %d @%.3f ms, last progress @ %.3f ms): %w" ,
227
- br .offset , msSinceFirstConnection , br .lastRetryOffset , msSinceLastRetry , msSinceLastSuccess , originalErr )
228
+ if progress >= bodyReaderMinimumProgress {
229
+ logrus .Infof ("Reading blob body from %s failed (%v), reconnecting after %d bytes…" , redactedURL , originalErr , progress )
230
+ return nil
231
+ }
232
+ if br .lastRetryTime == (time.Time {}) || msSinceLastRetry >= bodyReaderMSSinceLastRetry {
233
+ if br .lastRetryTime == (time.Time {}) {
234
+ logrus .Infof ("Reading blob body from %s failed (%v), reconnecting (first reconnection)…" , redactedURL , originalErr )
235
+ } else {
236
+ logrus .Infof ("Reading blob body from %s failed (%v), reconnecting after %.3f ms…" , redactedURL , originalErr , msSinceLastRetry )
237
+ }
238
+ return nil
228
239
}
229
- logrus .Infof ("Reading blob body from %s failed (%v), reconnecting…" , redactedURL , originalErr )
230
- return nil
240
+ logrus .Debugf ("Not reconnecting to %s: insufficient progress %d / time since last retry %.3f ms" , redactedURL , progress , msSinceLastRetry )
241
+ return fmt .Errorf ("(heuristic tuning data: total %d @%.3f ms, last retry %d @%.3f ms, last progress @ %.3f ms): %w" ,
242
+ br .offset , msSinceFirstConnection , br .lastRetryOffset , msSinceLastRetry , msSinceLastSuccess , originalErr )
231
243
}
232
244
233
245
// Close implements io.ReadCloser
0 commit comments