Skip to content

Commit

Permalink
Rename some variables
Browse files Browse the repository at this point in the history
Consistently use ms... for milliseconds (durations), and ...Time for timestamps.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
  • Loading branch information
mtrmac committed Feb 20, 2023
1 parent ad29e5d commit f14b391
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docker/body_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,15 @@ func millisecondsSinceOptional(currentTime time.Time, tm time.Time) float64 {
// otherwise it returns an appropriate error to return to the caller (possibly augmented with data about the heuristic)
func (br *bodyReader) errorIfNotReconnecting(originalErr error, redactedURL string) error {
currentTime := time.Now()
totalTime := millisecondsSinceOptional(currentTime, br.firstConnectionTime)
failureTime := millisecondsSinceOptional(currentTime, br.lastSuccessTime)
msSinceFirstConnection := millisecondsSinceOptional(currentTime, br.firstConnectionTime)
msSinceLastSuccess := millisecondsSinceOptional(currentTime, br.lastSuccessTime)
logrus.Debugf("Reading blob body from %s failed (%#v), decision inputs: lastRetryOffset %d, offset %d, %.3f ms since first connection, %.3f ms since last progress",
redactedURL, originalErr, br.lastRetryOffset, br.offset, totalTime, failureTime)
redactedURL, originalErr, br.lastRetryOffset, br.offset, msSinceFirstConnection, msSinceLastSuccess)
progress := br.offset - br.lastRetryOffset
if progress < bodyReaderMinimumProgress {
logrus.Debugf("Not reconnecting to %s because only %d bytes progress made", redactedURL, progress)
return fmt.Errorf("(heuristic tuning data: last retry %d, current offset %d; %.3f ms total, %.3f ms since progress): %w",
br.lastRetryOffset, br.offset, totalTime, failureTime, originalErr)
br.lastRetryOffset, br.offset, msSinceFirstConnection, msSinceLastSuccess, originalErr)
}
logrus.Infof("Reading blob body from %s failed (%v), reconnecting…", redactedURL, originalErr)
return nil
Expand Down

0 comments on commit f14b391

Please sign in to comment.