Don't unmount on Darwin when deleting bundle

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
This commit is contained in:
Maksym Pavlenko 2022-10-14 14:35:24 -07:00
parent f4095a6876
commit fb6a40dc9d

View File

@ -21,6 +21,7 @@ import (
"fmt" "fmt"
"os" "os"
"path/filepath" "path/filepath"
"runtime"
"github.com/containerd/containerd/identifiers" "github.com/containerd/containerd/identifiers"
"github.com/containerd/containerd/mount" "github.com/containerd/containerd/mount"
@ -128,8 +129,10 @@ type Bundle struct {
func (b *Bundle) Delete() error { func (b *Bundle) Delete() error {
work, werr := os.Readlink(filepath.Join(b.Path, "work")) work, werr := os.Readlink(filepath.Join(b.Path, "work"))
rootfs := filepath.Join(b.Path, "rootfs") rootfs := filepath.Join(b.Path, "rootfs")
if err := mount.UnmountAll(rootfs, 0); err != nil { if runtime.GOOS != "darwin" {
return fmt.Errorf("unmount rootfs %s: %w", rootfs, err) if err := mount.UnmountAll(rootfs, 0); err != nil {
return fmt.Errorf("unmount rootfs %s: %w", rootfs, err)
}
} }
if err := os.Remove(rootfs); err != nil && !os.IsNotExist(err) { if err := os.Remove(rootfs); err != nil && !os.IsNotExist(err) {
return fmt.Errorf("failed to remove bundle rootfs: %w", err) return fmt.Errorf("failed to remove bundle rootfs: %w", err)