From 0105959c3d1515f47690809910d9dee15d8956bc Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Fri, 13 Jul 2018 13:32:25 -0400 Subject: [PATCH] Don't prevent boot on temp cleanup Fixes #2462 Fixes #2455 Signed-off-by: Michael Crosby --- cmd/containerd/command/main.go | 8 ++++++-- mount/temp_unix.go | 11 ++++++----- mount/temp_unsupported.go | 4 ++-- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/cmd/containerd/command/main.go b/cmd/containerd/command/main.go index 31a21f6c6..80ef3761f 100644 --- a/cmd/containerd/command/main.go +++ b/cmd/containerd/command/main.go @@ -116,8 +116,12 @@ func App() *cli.App { return errors.Wrap(err, "creating temp mount location") } // unmount all temp mounts on boot for the server - if err := mount.CleanupTempMounts(0); err != nil { - return errors.Wrap(err, "unmounting temp mounts") + warnings, err := mount.CleanupTempMounts(0) + if err != nil { + log.G(ctx).WithError(err).Error("unmounting temp mounts") + } + for _, w := range warnings { + log.G(ctx).WithError(w).Warn("cleanup temp mount") } address := config.GRPC.Address if address == "" { diff --git a/mount/temp_unix.go b/mount/temp_unix.go index fcf90d6fb..3d490e8a7 100644 --- a/mount/temp_unix.go +++ b/mount/temp_unix.go @@ -39,10 +39,10 @@ func SetTempMountLocation(root string) error { } // CleanupTempMounts all temp mounts and remove the directories -func CleanupTempMounts(flags int) error { +func CleanupTempMounts(flags int) (warnings []error, err error) { mounts, err := Self() if err != nil { - return err + return nil, err } var toUnmount []string for _, m := range mounts { @@ -53,11 +53,12 @@ func CleanupTempMounts(flags int) error { sort.Sort(sort.Reverse(sort.StringSlice(toUnmount))) for _, path := range toUnmount { if err := UnmountAll(path, flags); err != nil { - return err + warnings = append(warnings, err) + continue } if err := os.Remove(path); err != nil { - return err + warnings = append(warnings, err) } } - return nil + return warnings, nil } diff --git a/mount/temp_unsupported.go b/mount/temp_unsupported.go index de3f4163a..942be4128 100644 --- a/mount/temp_unsupported.go +++ b/mount/temp_unsupported.go @@ -24,6 +24,6 @@ func SetTempMountLocation(root string) error { } // CleanupTempMounts all temp mounts and remove the directories -func CleanupTempMounts(flags int) error { - return nil +func CleanupTempMounts(flags int) ([]error, error) { + return nil, nil }