Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

[18.09 backport] Skip deprecated storage-drivers in auto-selection #90

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions daemon/graphdriver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ type Options struct {
func New(name string, pg plugingetter.PluginGetter, config Options) (Driver, error) {
if name != "" {
logrus.Debugf("[graphdriver] trying provided driver: %s", name) // so the logs show specified driver
logDeprecatedWarning(name)
return GetDriver(name, pg, config)
}

Expand Down Expand Up @@ -232,6 +233,7 @@ 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
}
}
Expand All @@ -245,18 +247,25 @@ func New(name string, pg plugingetter.PluginGetter, config Options) (Driver, err
}
return nil, err
}
logDeprecatedWarning(name)
return driver, nil
}

// Check all registered drivers if no priority driver is found
for name, initFunc := range drivers {
if isDeprecated(name) {
// Deprecated storage-drivers are skipped in automatic selection, but
// can be selected through configuration.
continue
}
driver, err := initFunc(filepath.Join(config.Root, name), config.DriverOptions, config.UIDMaps, config.GIDMaps)
if err != nil {
if IsDriverNotSupported(err) {
continue
}
return nil, err
}
logDeprecatedWarning(name)
return driver, nil
}
return nil, fmt.Errorf("No supported storage backend found")
Expand Down Expand Up @@ -305,3 +314,20 @@ func isEmptyDir(name string) bool {
}
return false
}

// isDeprecated checks if a storage-driver is marked "deprecated"
func isDeprecated(name string) bool {
switch name {
// NOTE: when deprecating a driver, update daemon.fillDriverInfo() accordingly
case "devicemapper", "overlay":
return true
}
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)
}
}
4 changes: 4 additions & 0 deletions daemon/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ func (daemon *Daemon) fillDriverInfo(v *types.Info) {
if len(daemon.graphDrivers) > 1 {
drivers += fmt.Sprintf(" (%s) ", os)
}
switch gd {
case "devicemapper", "overlay":
v.Warnings = append(v.Warnings, fmt.Sprintf("WARNING: the %s storage-driver is deprecated, and will be removed in a future release.", gd))
}
}
drivers = strings.TrimSpace(drivers)

Expand Down