Merge pull request #22630 from thaJeztah/refactor-overlay-compatibility

refactor overlay storage driver compatibility check
This commit is contained in:
Alexander Morozov 2016-05-12 12:00:57 -07:00
commit 150009e9d8
2 changed files with 9 additions and 24 deletions

View File

@ -53,12 +53,8 @@ var (
// ErrAufsNotSupported is returned if aufs is not supported by the host. // ErrAufsNotSupported is returned if aufs is not supported by the host.
ErrAufsNotSupported = fmt.Errorf("AUFS was not found in /proc/filesystems") ErrAufsNotSupported = fmt.Errorf("AUFS was not found in /proc/filesystems")
// ErrAufsNested means aufs cannot be used bc we are in a user namespace // ErrAufsNested means aufs cannot be used bc we are in a user namespace
ErrAufsNested = fmt.Errorf("AUFS cannot be used in non-init user namespace") ErrAufsNested = fmt.Errorf("AUFS cannot be used in non-init user namespace")
incompatibleFsMagic = []graphdriver.FsMagic{ backingFs = "<unknown>"
graphdriver.FsMagicBtrfs,
graphdriver.FsMagicAufs,
}
backingFs = "<unknown>"
enableDirpermLock sync.Once enableDirpermLock sync.Once
enableDirperm bool enableDirperm bool
@ -95,10 +91,10 @@ func Init(root string, options []string, uidMaps, gidMaps []idtools.IDMap) (grap
backingFs = fsName backingFs = fsName
} }
for _, magic := range incompatibleFsMagic { switch fsMagic {
if fsMagic == magic { case graphdriver.FsMagicAufs, graphdriver.FsMagicBtrfs:
return nil, graphdriver.ErrIncompatibleFS logrus.Errorf("AUFS is not supported over %s", backingFs)
} return nil, graphdriver.ErrIncompatibleFS
} }
paths := []string{ paths := []string{

View File

@ -29,6 +29,7 @@ import (
var ( var (
// ErrApplyDiffFallback is returned to indicate that a normal ApplyDiff is applied as a fallback from Naive diff writer. // ErrApplyDiffFallback is returned to indicate that a normal ApplyDiff is applied as a fallback from Naive diff writer.
ErrApplyDiffFallback = fmt.Errorf("Fall back to normal ApplyDiff") ErrApplyDiffFallback = fmt.Errorf("Fall back to normal ApplyDiff")
backingFs = "<unknown>"
) )
// ApplyDiffProtoDriver wraps the ProtoDriver by extending the interface with ApplyDiff method. // ApplyDiffProtoDriver wraps the ProtoDriver by extending the interface with ApplyDiff method.
@ -99,8 +100,6 @@ type Driver struct {
ctr *graphdriver.RefCounter ctr *graphdriver.RefCounter
} }
var backingFs = "<unknown>"
func init() { func init() {
graphdriver.Register("overlay", Init) graphdriver.Register("overlay", Init)
} }
@ -122,19 +121,9 @@ func Init(home string, options []string, uidMaps, gidMaps []idtools.IDMap) (grap
backingFs = fsName backingFs = fsName
} }
// check if they are running over btrfs, aufs, zfs or overlay
switch fsMagic { switch fsMagic {
case graphdriver.FsMagicBtrfs: case graphdriver.FsMagicAufs, graphdriver.FsMagicBtrfs, graphdriver.FsMagicOverlay, graphdriver.FsMagicZfs:
logrus.Error("'overlay' is not supported over btrfs.") logrus.Errorf("'overlay' is not supported over %s", backingFs)
return nil, graphdriver.ErrIncompatibleFS
case graphdriver.FsMagicAufs:
logrus.Error("'overlay' is not supported over aufs.")
return nil, graphdriver.ErrIncompatibleFS
case graphdriver.FsMagicZfs:
logrus.Error("'overlay' is not supported over zfs.")
return nil, graphdriver.ErrIncompatibleFS
case graphdriver.FsMagicOverlay:
logrus.Error("'overlay' is not supported over overlay.")
return nil, graphdriver.ErrIncompatibleFS return nil, graphdriver.ErrIncompatibleFS
} }