From 6ccda5a04111680544eadb6fbc916435ea073e69 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 9 Aug 2022 17:11:24 +0200 Subject: [PATCH 1/3] daemon: restore(): remove platform-check (was used for LCOW) This was added in 0cba7740d41369eee33b671f26276325580bc07b, as part of the LCOW implementation. LCOW support has been removed, so we can remove this check. Signed-off-by: Sebastiaan van Stijn --- daemon/daemon.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/daemon/daemon.go b/daemon/daemon.go index e9c3765042..7a77e66e1f 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -239,10 +239,6 @@ func (daemon *Daemon) restore() error { log.WithError(err).Error("failed to load container") return } - if !system.IsOSSupported(c.OS) { - log.Errorf("failed to load container: %s (%q)", system.ErrNotSupportedOperatingSystem, c.OS) - return - } // Ignore the container if it does not support the current driver being used by the graph if (c.Driver == "" && daemon.graphDriver == "aufs") || c.Driver == daemon.graphDriver { rwlayer, err := daemon.imageService.GetLayerByID(c.ID) From 239d9c5eda8f65678b26de26a6763a67772f3151 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 9 Aug 2022 17:13:38 +0200 Subject: [PATCH 2/3] daemon: restore(): remove fallback for legacy containers The check was accounting for old containers that did not have a storage-driver set in their config, and was added in 4908d7f81db91f4a28be152ec0cacb0cf711b403 for docker v0.7.0-rc6 - nearly 9 Years ago, so very likely nobody is still depending on this ;-) Signed-off-by: Sebastiaan van Stijn --- daemon/daemon.go | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/daemon/daemon.go b/daemon/daemon.go index 7a77e66e1f..f82f66204a 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -239,25 +239,25 @@ func (daemon *Daemon) restore() error { log.WithError(err).Error("failed to load container") return } - // Ignore the container if it does not support the current driver being used by the graph - if (c.Driver == "" && daemon.graphDriver == "aufs") || c.Driver == daemon.graphDriver { - rwlayer, err := daemon.imageService.GetLayerByID(c.ID) - if err != nil { - log.WithError(err).Error("failed to load container mount") - return - } - c.RWLayer = rwlayer - log.WithFields(logrus.Fields{ - "running": c.IsRunning(), - "paused": c.IsPaused(), - }).Debug("loaded container") - - mapLock.Lock() - containers[c.ID] = c - mapLock.Unlock() - } else { - log.Debugf("cannot load container because it was created with another storage driver") + if c.Driver != daemon.graphDriver { + // Ignore the container if it wasn't created with the current storage-driver + log.Debugf("not restoring container because it was created with another storage driver (%s)", c.Driver) + return } + rwlayer, err := daemon.imageService.GetLayerByID(c.ID) + if err != nil { + log.WithError(err).Error("failed to load container mount") + return + } + c.RWLayer = rwlayer + log.WithFields(logrus.Fields{ + "running": c.IsRunning(), + "paused": c.IsPaused(), + }).Debug("loaded container") + + mapLock.Lock() + containers[c.ID] = c + mapLock.Unlock() }(v.Name()) } group.Wait() From 9d74c7ab9993719ed5f45e492d393f0ad923b536 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 9 Aug 2022 17:25:48 +0200 Subject: [PATCH 3/3] daemon: Mount(): use container's driver information for error-message Use the information stored as part of the container for the error-message, instead of querying the current storage driver from the daemon. Signed-off-by: Sebastiaan van Stijn --- daemon/containerd/service.go | 1 - daemon/daemon.go | 4 ++-- daemon/images/service.go | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/daemon/containerd/service.go b/daemon/containerd/service.go index 2604daec29..17ca48fdca 100644 --- a/daemon/containerd/service.go +++ b/daemon/containerd/service.go @@ -81,7 +81,6 @@ func (i *ImageService) Cleanup() error { // GraphDriverName returns the name of the graph drvier // moved from Daemon.GraphDriverName, used by: // - newContainer -// - to report an error in Daemon.Mount(container) func (i *ImageService) GraphDriverName() string { return "" } diff --git a/daemon/daemon.go b/daemon/daemon.go index f82f66204a..b73d9e76d2 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -1273,8 +1273,8 @@ func (daemon *Daemon) Mount(container *container.Container) error { // on non-Windows operating systems. if runtime.GOOS != "windows" { daemon.Unmount(container) - return fmt.Errorf("Error: driver %s is returning inconsistent paths for container %s ('%s' then '%s')", - daemon.imageService.GraphDriverName(), container.ID, container.BaseFS, dir) + return fmt.Errorf("driver %s is returning inconsistent paths for container %s ('%s' then '%s')", + container.Driver, container.ID, container.BaseFS, dir) } } container.BaseFS = dir // TODO: combine these fields diff --git a/daemon/images/service.go b/daemon/images/service.go index c23e878cf3..461cb7cb82 100644 --- a/daemon/images/service.go +++ b/daemon/images/service.go @@ -175,7 +175,6 @@ func (i *ImageService) Cleanup() error { // GraphDriverName returns the name of the graph drvier // moved from Daemon.GraphDriverName, used by: // - newContainer -// - to report an error in Daemon.Mount(container) func (i *ImageService) GraphDriverName() string { return i.layerStore.DriverName() }