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

ZFS driver: raise better errors during init

The ZFS driver should raise proper errors when the ZFS utility is
missing or when there's no zfs partition active on the system. Raising the
proper errors make possible to silently ignore the ZFS storage
driver when no default storage driver is specified.

Previous to this commit it was no longer possible to start the
docker daemon in that way:

  docker -d --storage-opt dm.loopdatasize=2GB

The above command resulted in an exit error because the ZFS driver
tried to use the storage options.

Signed-off-by: Flavio Castelli <fcastelli@suse.com>
This commit is contained in:
Flavio Castelli 2015-07-20 13:50:53 +02:00
parent 008d57bf7f
commit f95b3a6b6a

View file

@ -38,6 +38,19 @@ func (*Logger) Log(cmd []string) {
func Init(base string, opt []string) (graphdriver.Driver, error) {
var err error
if _, err := exec.LookPath("zfs"); err != nil {
log.Debugf("[zfs] zfs command is not available: %v", err)
return nil, graphdriver.ErrPrerequisites
}
file, err := os.OpenFile("/dev/zfs", os.O_RDWR, 600)
if err != nil {
log.Debugf("[zfs] cannot open /dev/zfs: %v", err)
return nil, graphdriver.ErrPrerequisites
}
defer file.Close()
options, err := parseOptions(opt)
if err != nil {
return nil, err
@ -53,16 +66,6 @@ func Init(base string, opt []string) (graphdriver.Driver, error) {
}
}
if _, err := exec.LookPath("zfs"); err != nil {
return nil, fmt.Errorf("zfs command is not available: %v", err)
}
file, err := os.OpenFile("/dev/zfs", os.O_RDWR, 600)
if err != nil {
return nil, fmt.Errorf("cannot open /dev/zfs: %v", err)
}
defer file.Close()
if options.fsName == "" {
options.fsName, err = lookupZfsDataset(rootdir)
if err != nil {