client/driver: add waiting layer status count to pull progress status msg

This commit is contained in:
Nick Ethier 2018-05-03 15:14:53 -04:00
parent 77af17efbc
commit d8de354dbf
No known key found for this signature in database
GPG key ID: 07C1A3ECED90D24A

View file

@ -21,6 +21,10 @@ const (
// dockerImageProgressReportInterval is the default value set in the // dockerImageProgressReportInterval is the default value set in the
// imageProgressManager when newImageProgressManager is called // imageProgressManager when newImageProgressManager is called
dockerImageProgressReportInterval = 10 * time.Second dockerImageProgressReportInterval = 10 * time.Second
// dockerImageSlowProgressReportInterval is the default value set in the
// imageProgressManager when newImageProgressManager is called
dockerImageSlowProgressReportInterval = 2 * time.Minute
) )
// layerProgress tracks the state and downloaded bytes of a single layer within // layerProgress tracks the state and downloaded bytes of a single layer within
@ -88,11 +92,16 @@ func (p *imageProgress) get() (string, time.Time) {
return "No progress", p.timestamp return "No progress", p.timestamp
} }
var pulled, pulling int var pulled, pulling, waiting int
for _, l := range p.layers { for _, l := range p.layers {
if l.status == layerProgressStatusDownloading { switch {
case l.status == layerProgressStatusStarting ||
l.status == layerProgressStatusWaiting:
waiting++
case l.status == layerProgressStatusDownloading ||
l.status == layerProgressStatusVerifying:
pulling++ pulling++
} else if l.status > layerProgressStatusVerifying { case l.status >= layerProgressStatusDownloaded:
pulled++ pulled++
} }
} }
@ -105,9 +114,9 @@ func (p *imageProgress) get() (string, time.Time) {
est = (elapsed.Nanoseconds() / cur * total) - elapsed.Nanoseconds() est = (elapsed.Nanoseconds() / cur * total) - elapsed.Nanoseconds()
} }
return fmt.Sprintf("Pulled %d/%d (%s/%s) pulling %d layers - est %.1fs remaining", return fmt.Sprintf("Pulled %d/%d (%s/%s) layers: %d waiting/%d pulling - est %.1fs remaining",
pulled, len(p.layers), units.BytesSize(float64(cur)), units.BytesSize(float64(total)), pulling, pulled, len(p.layers), units.BytesSize(float64(cur)), units.BytesSize(float64(total)),
time.Duration(est).Seconds()), p.timestamp waiting, pulling, time.Duration(est).Seconds()), p.timestamp
} }
// set takes a status message received from the docker engine api during an image // set takes a status message received from the docker engine api during an image
@ -160,7 +169,7 @@ func (p *imageProgress) totalBytes() int64 {
return b return b
} }
// progressReporterFunc defines the method for handeling inactivity and report // progressReporterFunc defines the method for handling inactivity and report
// events from the imageProgressManager. The image name, current status message // events from the imageProgressManager. The image name, current status message
// and timestamp of last received status update are passed in. // and timestamp of last received status update are passed in.
type progressReporterFunc func(image string, msg string, timestamp time.Time) type progressReporterFunc func(image string, msg string, timestamp time.Time)
@ -195,6 +204,7 @@ func newImageProgressManager(
inactivityFunc: inactivityFunc, inactivityFunc: inactivityFunc,
reportInterval: dockerImageProgressReportInterval, reportInterval: dockerImageProgressReportInterval,
reporter: reporter, reporter: reporter,
slowReportInterval: dockerImageSlowProgressReportInterval,
slowReporter: slowReporter, slowReporter: slowReporter,
imageProgress: &imageProgress{ imageProgress: &imageProgress{
timestamp: time.Now(), timestamp: time.Now(),