1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Ignore layer does not exist error from docker images

Fix #31350

As we can see in `daemon.Images()`, there is a gap between
`allImages = daemon.imageStore.Map()` and `l, err :=
daemon.layerStore.Get(layerID)`, so images which still exist when we hit
`allImages = daemon.imageStore.Map()` may have already been deleted when we hit
`l, err := daemon.layerStore.Get(layerID)`.

```
	if danglingOnly {
        	allImages = daemon.imageStore.Heads()
	} else {
        	allImages = daemon.imageStore.Map()
	}

	...

	for id, img := range allImages {
		...

		layerID := img.RootFS.ChainID()
        	var size int64
	        if layerID != "" {
        	        l, err := daemon.layerStore.Get(layerID)
                	if err != nil {
                        	return nil, err
                	}
```

Signed-off-by: Yuanhong Peng <pengyuanhong@huawei.com>
This commit is contained in:
Yuanhong Peng 2017-03-15 22:14:14 +08:00
parent b36ce6f2f6
commit 2b9694c29e

View file

@ -118,6 +118,11 @@ func (daemon *Daemon) Images(imageFilters filters.Args, all bool, withExtraAttrs
if layerID != "" {
l, err := daemon.layerStore.Get(layerID)
if err != nil {
// The layer may have been deleted between the call to `Map()` or
// `Heads()` and the call to `Get()`, so we just ignore this error
if err == layer.ErrLayerDoesNotExist {
continue
}
return nil, err
}