Don't fail when destroyContainerFS is called more than once

This can happen when destroy is called multiple times or when destroy
failed previously and is being called again.

PiperOrigin-RevId: 221882034
Change-Id: I8d069af19cf66c4e2419bdf0d4b789c5def8d19e
This commit is contained in:
Fabricio Voznika
2018-11-20 14:03:42 -08:00
committed by Nicolas Lacasse
parent 845836c578
commit 237f9c7a5e
+3 -2
View File
@@ -673,10 +673,11 @@ func destroyContainerFS(ctx context.Context, cid string, k *kernel.Kernel) error
defer root.DecRef()
// Do a best-effort unmount by flushing the refs and unmount
// with "detach only = true".
// with "detach only = true". Unmount returns EINVAL when the mount point
// doesn't exist, i.e. it has already been unmounted.
log.Debugf("Unmounting container submount %q", root.BaseName())
m.FlushDirentRefs()
if err := mns.Unmount(ctx, root, true /* detach only */); err != nil {
if err := mns.Unmount(ctx, root, true /* detach only */); err != nil && err != syserror.EINVAL {
return fmt.Errorf("error unmounting container submount %q: %v", root.BaseName(), err)
}
}