Merge pull request #2123 from kimminss0/zfs-tolerate-already-removed-layer-deletion

drivers/zfs: Handle missing layers during image deletion in ZFS file system
This commit is contained in:
openshift-merge-bot[bot] 2024-10-08 18:55:03 +00:00 committed by GitHub
commit a397602515
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 5 deletions

View File

@ -392,12 +392,18 @@ func (d *Driver) Remove(id string) error {
name := d.zfsPath(id)
dataset := zfs.Dataset{Name: name}
err := dataset.Destroy(zfs.DestroyRecursive)
if err == nil {
d.Lock()
delete(d.filesystemsCache, name)
d.Unlock()
if err != nil {
// We must be tolerant in case the image has already been removed,
// for example, accidentally by hand.
if _, err1 := zfs.GetDataset(name); err1 == nil {
return err
}
logrus.WithField("storage-driver", "zfs").Debugf("Layer %s has already been removed; ignore it and continue to delete the cache", id)
}
return err
d.Lock()
delete(d.filesystemsCache, name)
d.Unlock()
return nil
}
// Get returns the mountpoint for the given id after creating the target directories if necessary.