From 24f8c9bc49c69dccf1ebe401037ca2449fbbc76a Mon Sep 17 00:00:00 2001 From: Xinfeng Liu Date: Fri, 14 Jun 2024 11:00:21 +0800 Subject: [PATCH] Do not abort image-pull in Extracting phase Signed-off-by: Xinfeng Liu --- libdocker/kube_docker_client.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libdocker/kube_docker_client.go b/libdocker/kube_docker_client.go index 412ee2c54..5abf717c7 100644 --- a/libdocker/kube_docker_client.go +++ b/libdocker/kube_docker_client.go @@ -314,11 +314,11 @@ func (p *progress) set(msg *dockermessage.JSONMessage) { p.timestamp = time.Now() } -func (p *progress) get() (string, time.Time) { +func (p *progress) get() (status, msg string, timestamp time.Time) { p.RLock() defer p.RUnlock() if p.message == nil { - return "No progress", p.timestamp + return "", "No progress", p.timestamp } // The following code is based on JSONMessage.Display var prefix string @@ -326,9 +326,9 @@ func (p *progress) get() (string, time.Time) { prefix = fmt.Sprintf("%s: ", p.message.ID) } if p.message.Progress == nil { - return fmt.Sprintf("%s%s", prefix, p.message.Status), p.timestamp + return p.message.Status, fmt.Sprintf("%s%s", prefix, p.message.Status), p.timestamp } - return fmt.Sprintf( + return p.message.Status, fmt.Sprintf( "%s%s %s", prefix, p.message.Status, @@ -368,9 +368,9 @@ func (p *progressReporter) start() { for { select { case <-ticker.C: - progress, timestamp := p.progress.get() - // If there is no progress for p.imagePullProgressDeadline, cancel the operation. - if time.Since(timestamp) > p.imagePullProgressDeadline { + status, progress, timestamp := p.progress.get() + // If there is no progress for p.imagePullProgressDeadline in 'Downloading' phase, cancel the operation. + if status != "Extracting" && time.Since(timestamp) > p.imagePullProgressDeadline { logrus.Errorf( "Cancel pulling image %s because it exceeded image pull deadline %s. Latest progress %s", p.image, @@ -382,7 +382,7 @@ func (p *progressReporter) start() { } logrus.Infof("Pulling image %s: %s", p.image, progress) case <-p.stopCh: - progress, _ := p.progress.get() + _, progress, _ := p.progress.get() logrus.Infof("Stop pulling image %s: %s", p.image, progress) return }