Merge pull request #3325 from crosbymichael/unmount

Unmount rootfs with separate Remove() in bundle
This commit is contained in:
Wei Fu 2019-06-06 11:50:03 +08:00 committed by GitHub
commit 02ed02eca5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,6 +24,7 @@ import (
"path/filepath"
"github.com/containerd/containerd/identifiers"
"github.com/containerd/containerd/mount"
"github.com/containerd/containerd/namespaces"
"github.com/pkg/errors"
)
@ -116,6 +117,13 @@ type Bundle struct {
// Delete a bundle atomically
func (b *Bundle) Delete() error {
work, werr := os.Readlink(filepath.Join(b.Path, "work"))
rootfs := filepath.Join(b.Path, "rootfs")
if err := mount.UnmountAll(rootfs, 0); err != nil {
return errors.Wrapf(err, "unmount rootfs %s", rootfs)
}
if err := os.Remove(rootfs); err != nil && os.IsNotExist(err) {
return errors.Wrap(err, "failed to remove bundle rootfs")
}
err := atomicDelete(b.Path)
if err == nil {
if werr == nil {