1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Allow existing setups to continue using d_type

Even though it's highly discouraged, there are existing
installs that are running overlay/overlay2 on filesystems
without d_type support.

This patch allows the daemon to start in such cases, instead of
refusing to start without an option to override.

For fresh installs, backing filesystems without d_type support
will still cause the overlay/overlay2 drivers to be marked as
"unsupported", and skipped during the automatic selection.

This feature is only to keep backward compatibility, but
will be removed at some point.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2017-12-04 17:02:52 -08:00
parent 0abb8dec3f
commit 0a4e793a3d
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C
3 changed files with 22 additions and 2 deletions

View file

@ -277,6 +277,18 @@ func scanPriorDrivers(root string) map[string]bool {
return driversMap return driversMap
} }
// IsInitialized checks if the driver's home-directory exists and is non-empty.
func IsInitialized(driverHome string) bool {
_, err := os.Stat(driverHome)
if os.IsNotExist(err) {
return false
}
if err != nil {
logrus.Warnf("graphdriver.IsInitialized: stat failed: %v", err)
}
return !isEmptyDir(driverHome)
}
// isEmptyDir checks if a directory is empty. It is used to check if prior // isEmptyDir checks if a directory is empty. It is used to check if prior
// storage-driver directories exist. If an error occurs, it also assumes the // storage-driver directories exist. If an error occurs, it also assumes the
// directory is not empty (which preserves the behavior _before_ this check // directory is not empty (which preserves the behavior _before_ this check

View file

@ -148,8 +148,12 @@ func Init(home string, options []string, uidMaps, gidMaps []idtools.IDMap) (grap
return nil, err return nil, err
} }
if !supportsDType { if !supportsDType {
if !graphdriver.IsInitialized(home) {
return nil, overlayutils.ErrDTypeNotSupported("overlay", backingFs) return nil, overlayutils.ErrDTypeNotSupported("overlay", backingFs)
} }
// allow running without d_type only for existing setups (#27443)
logrus.Warn(overlayutils.ErrDTypeNotSupported("overlay", backingFs))
}
rootUID, rootGID, err := idtools.GetRootUIDGID(uidMaps, gidMaps) rootUID, rootGID, err := idtools.GetRootUIDGID(uidMaps, gidMaps)
if err != nil { if err != nil {

View file

@ -184,8 +184,12 @@ func Init(home string, options []string, uidMaps, gidMaps []idtools.IDMap) (grap
return nil, err return nil, err
} }
if !supportsDType { if !supportsDType {
if !graphdriver.IsInitialized(home) {
return nil, overlayutils.ErrDTypeNotSupported("overlay2", backingFs) return nil, overlayutils.ErrDTypeNotSupported("overlay2", backingFs)
} }
// allow running without d_type only for existing setups (#27443)
logrus.Warn(overlayutils.ErrDTypeNotSupported("overlay2", backingFs))
}
rootUID, rootGID, err := idtools.GetRootUIDGID(uidMaps, gidMaps) rootUID, rootGID, err := idtools.GetRootUIDGID(uidMaps, gidMaps)
if err != nil { if err != nil {