From b3c767fae0dd2c8a2ee29fc2bcb91ed45ec42e41 Mon Sep 17 00:00:00 2001 From: Nick Ethier Date: Thu, 7 Jun 2018 15:23:31 -0400 Subject: [PATCH] client/driver: drop docker pull progress estimate if its < 0 --- client/driver/docker_progress.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/client/driver/docker_progress.go b/client/driver/docker_progress.go index 912c2d4a8..1bfd1312c 100644 --- a/client/driver/docker_progress.go +++ b/client/driver/docker_progress.go @@ -6,6 +6,7 @@ import ( "encoding/json" "fmt" "io" + "strings" "sync" "time" @@ -114,9 +115,15 @@ func (p *imageProgress) get() (string, time.Time) { est = (elapsed.Nanoseconds() / cur * total) - elapsed.Nanoseconds() } - return fmt.Sprintf("Pulled %d/%d (%s/%s) layers: %d waiting/%d pulling - est %.1fs remaining", + var msg strings.Builder + fmt.Fprintf(&msg, "Pulled %d/%d (%s/%s) layers: %d waiting/%d pulling", pulled, len(p.layers), units.BytesSize(float64(cur)), units.BytesSize(float64(total)), - waiting, pulling, time.Duration(est).Seconds()), p.timestamp + waiting, pulling) + + if est > 0 { + fmt.Fprintf(&msg, " - est %.1fs remaining", time.Duration(est).Seconds()) + } + return msg.String(), p.timestamp } // set takes a status message received from the docker engine api during an image