Skip to content

Commit

Permalink
Also log, for heuristics tuning only, the elapsed time
Browse files Browse the repository at this point in the history
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
  • Loading branch information
mtrmac committed Jan 30, 2023
1 parent a93a0c8 commit 296b352
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion docker/body_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type bodyReader struct {
body io.ReadCloser // The currently open connection we use to read data, or nil if there is nothing to read from / close.
lastRetryOffset int64
offset int64 // Current offset within the blob
lastSuccessTime time.Time

sysLog *syslog.Writer
}
Expand Down Expand Up @@ -151,12 +152,17 @@ func (br *bodyReader) Read(p []byte) (int, error) {
br.offset += int64(n)
switch {
case err == nil || err == io.EOF:
br.lastSuccessTime = time.Now()
return n, err // Unlike the default: case, don’t log anything.

case errors.Is(err, io.ErrUnexpectedEOF) || errors.Is(err, syscall.ECONNRESET):
originalErr := err
// FIXME: Turn this into a Debugf
br.Logf("BODYREADER DEBUG: Reading blob body, decision inputs: lastRetryOffset %d, offset %d, error %#v", br.lastRetryOffset, br.offset, originalErr)
failureTime := int64(-1)
if (br.lastSuccessTime != time.Time{}) {
failureTime = time.Since(br.lastSuccessTime).Milliseconds()
}
br.Logf("BODYREADER DEBUG: Reading blob body, decision inputs: lastRetryOffset %d, offset %d, time diff %d ms, error %#v", br.lastRetryOffset, br.offset, failureTime, originalErr)
progress := br.offset - br.lastRetryOffset
if progress < bodyReaderMinimumProgress {
// FIXME: Warnf
Expand Down

0 comments on commit 296b352

Please sign in to comment.