Skip to content

Commit

Permalink
daemon: require storage-driver to be set if the driver is deprecated
Browse files Browse the repository at this point in the history
Previously, we only printed a warning if a storage driver was deprecated. The
intent was to continue supporting these drivers, to allow users to migrate
to a different storage driver.

This patch changes the behavior; if the user has no storage driver specified
in the daemon configuration (so if we try to detect the previous storage
driver based on what's present in /var/lib/docker), we now produce an error,
informing the user that the storage driver is deprecated (and to be removed),
as well as instructing them to change the daemon configuration to explicitly
select the storage driver (to allow them to migrate).

This should make the deprecation more visible; this will be disruptive, but
it's better to have the failure happening *now* (while the drivers are still
there), than for users to discover the storage driver is no longer there
(which would require them to *downgrade* the daemon in order to migrate
to a different driver).

With this change, `docker info` includes a link in the warnings that:

    / # docker info
    Client:
    Context:    default
    Debug Mode: false

    Server:
    ...
    Live Restore Enabled: false

    WARNING: The overlay storage-driver is deprecated, and will be removed in a future release.
    Refer to the documentation for more information: https://docs.docker.com/go/storage-driver/

When starting the daemon without a storage driver configured explicitly, but
previous state was using a deprecated driver, the error is both logged and
printed:

    ...
    ERRO[2022-03-25T14:14:06.032014013Z] [graphdriver] prior storage driver overlay is deprecated and will be removed in a future release; update the the daemon configuration and explicitly choose this storage driver to continue using it; visit https://docs.docker.com/go/storage-driver/ for more information
    ...
    failed to start daemon: error initializing graphdriver: prior storage driver overlay is deprecated and will be removed in a future release; update the the daemon configuration and explicitly choose this storage driver to continue using it; visit https://docs.docker.com/go/storage-driver/ for more information

When starting the daemon and explicitly configuring it with a deprecated storage
driver:

    WARN[2022-03-25T14:15:59.042335412Z] [graphdriver] WARNING: the overlay storage-driver is deprecated and will be removed in a future release; visit https://docs.docker.com/go/storage-driver/ for more information

Signed-off-by: Sebastiaan van Stijn <[email protected]>
  • Loading branch information
thaJeztah committed Mar 25, 2022
1 parent 020fd68 commit 3853eb5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
25 changes: 14 additions & 11 deletions daemon/graphdriver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,9 @@ type Options struct {
func New(name string, pg plugingetter.PluginGetter, config Options) (Driver, error) {
if name != "" {
logrus.Infof("[graphdriver] trying configured driver: %s", name)
logDeprecatedWarning(name)
if isDeprecated(name) {
logrus.Warnf("[graphdriver] WARNING: the %s storage-driver is deprecated and will be removed in a future release; visit https://docs.docker.com/go/storage-driver/ for more information", name)
}
return GetDriver(name, pg, config)
}

Expand All @@ -214,6 +216,11 @@ func New(name string, pg plugingetter.PluginGetter, config Options) (Driver, err
logrus.Errorf("[graphdriver] prior storage driver %s failed: %s", name, err)
return nil, err
}
if isDeprecated(name) {
err = errors.Errorf("prior storage driver %s is deprecated and will be removed in a future release; update the the daemon configuration and explicitly choose this storage driver to continue using it; visit https://docs.docker.com/go/storage-driver/ for more information", name)
logrus.Errorf("[graphdriver] %v", err)
return nil, err
}

// abort starting when there are other prior configured drivers
// to ensure the user explicitly selects the driver to load
Expand All @@ -229,22 +236,25 @@ func New(name string, pg plugingetter.PluginGetter, config Options) (Driver, err
}

logrus.Infof("[graphdriver] using prior storage driver: %s", name)
logDeprecatedWarning(name)
return driver, nil
}
}

// If no prior state was found, continue with automatic selection, and pick
// the first supported storage driver (in order of priorityList).
// the first supported, non-deprecated, storage driver (in order of priorityList).
for _, name := range priorityList {
if isDeprecated(name) {
// Deprecated storage-drivers are skipped in automatic selection, but
// can be selected through configuration.
continue
}
driver, err := getBuiltinDriver(name, config.Root, config.DriverOptions, config.IDMap)
if err != nil {
if IsDriverNotSupported(err) {
continue
}
return nil, err
}
logDeprecatedWarning(name)
return driver, nil
}

Expand Down Expand Up @@ -322,10 +332,3 @@ func isDeprecated(name string) bool {
}
return false
}

// logDeprecatedWarning logs a warning if the given storage-driver is marked "deprecated"
func logDeprecatedWarning(name string) {
if isDeprecated(name) {
logrus.Warnf("[graphdriver] WARNING: the %s storage-driver is deprecated, and will be removed in a future release", name)
}
}
6 changes: 5 additions & 1 deletion daemon/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,13 @@ func (daemon *Daemon) SystemVersion() types.Version {
}

func (daemon *Daemon) fillDriverInfo(v *types.Info) {
const warnMsg = `
WARNING: The %s storage-driver is deprecated, and will be removed in a future release.
Refer to the documentation for more information: https://docs.docker.com/go/storage-driver/`

switch daemon.graphDriver {
case "aufs", "devicemapper", "overlay":
v.Warnings = append(v.Warnings, fmt.Sprintf("WARNING: the %s storage-driver is deprecated, and will be removed in a future release.", daemon.graphDriver))
v.Warnings = append(v.Warnings, fmt.Sprintf(warnMsg, daemon.graphDriver))
}

v.Driver = daemon.graphDriver
Expand Down

0 comments on commit 3853eb5

Please sign in to comment.