Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions internal/storage/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ type imageService struct {
ctx context.Context
}

// ImageBeingPulled map[string]bool to keep track of the images haven't done pulling.
var ImageBeingPulled sync.Map

// CgroupPullConfiguration
type CgroupPullConfiguration struct {
UseNewCgroup bool
Expand Down Expand Up @@ -316,6 +319,19 @@ func (svc *imageService) ListImages(systemContext *types.SystemContext, filter s
}
results, err = svc.appendCachedResult(systemContext, ref, image, results, newImageCache)
if err != nil {
// skip reporting errors if the images haven't finished pulling
if os.IsNotExist(errors.Cause(err)) {
donePulling := true
for _, name := range image.Names {
if _, ok := ImageBeingPulled.Load(name); ok {
donePulling = false
break
}
}
if !donePulling {
continue
}
}
return nil, err
}
}
Expand Down
2 changes: 2 additions & 0 deletions server/image_pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func (s *Server) PullImage(ctx context.Context, req *types.PullImageRequest) (*t
if !inProgress {
pullOp = &pullOperation{}
s.pullOperationsInProgress[pullArgs] = pullOp
storage.ImageBeingPulled.Store(pullArgs.image, true)
pullOp.wg.Add(1)
}
return pullOp, inProgress
Expand All @@ -79,6 +80,7 @@ func (s *Server) PullImage(ctx context.Context, req *types.PullImageRequest) (*t
defer func() {
s.pullOperationsLock.Lock()
delete(s.pullOperationsInProgress, pullArgs)
storage.ImageBeingPulled.Delete(pullArgs.image)
pullOp.wg.Done()
s.pullOperationsLock.Unlock()
}()
Expand Down