Skip to content

Commit

Permalink
Do not abort image-pull in Extracting phase
Browse files Browse the repository at this point in the history
Signed-off-by: Xinfeng Liu <[email protected]>
  • Loading branch information
xinfengliu committed Jun 14, 2024
1 parent 3248313 commit 24f8c9b
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions libdocker/kube_docker_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,21 +314,21 @@ 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
if p.message.ID != "" {
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,
Expand Down Expand Up @@ -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,
Expand All @@ -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
}
Expand Down

0 comments on commit 24f8c9b

Please sign in to comment.