Skip to content

Commit 0a4e793

Browse files
committed
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>
1 parent 0abb8de commit 0a4e793

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

daemon/graphdriver/driver.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,18 @@ func scanPriorDrivers(root string) map[string]bool {
277277
return driversMap
278278
}
279279

280+
// IsInitialized checks if the driver's home-directory exists and is non-empty.
281+
func IsInitialized(driverHome string) bool {
282+
_, err := os.Stat(driverHome)
283+
if os.IsNotExist(err) {
284+
return false
285+
}
286+
if err != nil {
287+
logrus.Warnf("graphdriver.IsInitialized: stat failed: %v", err)
288+
}
289+
return !isEmptyDir(driverHome)
290+
}
291+
280292
// isEmptyDir checks if a directory is empty. It is used to check if prior
281293
// storage-driver directories exist. If an error occurs, it also assumes the
282294
// directory is not empty (which preserves the behavior _before_ this check

daemon/graphdriver/overlay/overlay.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,11 @@ func Init(home string, options []string, uidMaps, gidMaps []idtools.IDMap) (grap
148148
return nil, err
149149
}
150150
if !supportsDType {
151-
return nil, overlayutils.ErrDTypeNotSupported("overlay", backingFs)
151+
if !graphdriver.IsInitialized(home) {
152+
return nil, overlayutils.ErrDTypeNotSupported("overlay", backingFs)
153+
}
154+
// allow running without d_type only for existing setups (#27443)
155+
logrus.Warn(overlayutils.ErrDTypeNotSupported("overlay", backingFs))
152156
}
153157

154158
rootUID, rootGID, err := idtools.GetRootUIDGID(uidMaps, gidMaps)

daemon/graphdriver/overlay2/overlay.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,11 @@ func Init(home string, options []string, uidMaps, gidMaps []idtools.IDMap) (grap
184184
return nil, err
185185
}
186186
if !supportsDType {
187-
return nil, overlayutils.ErrDTypeNotSupported("overlay2", backingFs)
187+
if !graphdriver.IsInitialized(home) {
188+
return nil, overlayutils.ErrDTypeNotSupported("overlay2", backingFs)
189+
}
190+
// allow running without d_type only for existing setups (#27443)
191+
logrus.Warn(overlayutils.ErrDTypeNotSupported("overlay2", backingFs))
188192
}
189193

190194
rootUID, rootGID, err := idtools.GetRootUIDGID(uidMaps, gidMaps)

0 commit comments

Comments
 (0)