mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #40268 from olljanat/garbage-collector-remove-layerdb-values
Make sure that layers are removed from layerdb after succefull layer …
This commit is contained in:
commit
f9c8717d87
3 changed files with 9 additions and 3 deletions
|
@ -110,4 +110,10 @@ func TestRemoveImageGarbageCollector(t *testing.T) {
|
|||
i.Cleanup()
|
||||
_, err = os.Stat(data["UpperDir"])
|
||||
assert.Assert(t, os.IsNotExist(err))
|
||||
|
||||
// Make sure that removal pending layers does not exist on layerdb either
|
||||
layerdbItems, _ := ioutil.ReadDir(filepath.Join(d.RootDir(), "/image/overlay2/layerdb/sha256"))
|
||||
for _, folder := range layerdbItems {
|
||||
assert.Equal(t, false, strings.HasSuffix(folder.Name(), "-removing"))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -403,7 +403,7 @@ func (fms *fileMetadataStore) Remove(layer ChainID, cache string) error {
|
|||
return err
|
||||
}
|
||||
for _, f := range files {
|
||||
if !strings.HasSuffix(f.Name(), "-removing") || !strings.HasPrefix(f.Name(), dgst.String()) {
|
||||
if !strings.HasSuffix(f.Name(), "-removing") || !strings.HasPrefix(f.Name(), dgst.Encoded()) {
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
|
@ -419,11 +419,11 @@ func (ls *layerStore) Map() map[ChainID]Layer {
|
|||
func (ls *layerStore) deleteLayer(layer *roLayer, metadata *Metadata) error {
|
||||
// Rename layer digest folder first so we detect orphan layer(s)
|
||||
// if ls.driver.Remove fails
|
||||
dir := ls.store.getLayerDirectory(layer.chainID)
|
||||
var dir string
|
||||
for {
|
||||
dgst := digest.Digest(layer.chainID)
|
||||
tmpID := fmt.Sprintf("%s-%s-removing", dgst.Hex(), stringid.GenerateRandomID())
|
||||
dir := filepath.Join(ls.store.root, string(dgst.Algorithm()), tmpID)
|
||||
dir = filepath.Join(ls.store.root, string(dgst.Algorithm()), tmpID)
|
||||
err := os.Rename(ls.store.getLayerDirectory(layer.chainID), dir)
|
||||
if os.IsExist(err) {
|
||||
continue
|
||||
|
|
Loading…
Reference in a new issue