From c20b4f7e4e843ea8ccdb1db44715a26eeb4acc46 Mon Sep 17 00:00:00 2001 From: Jan Safranek Date: Mon, 10 Jul 2017 14:33:56 +0200 Subject: [PATCH] glusterfs: retry without auto_unmount only when it's not supported GlusterFS volume plugin should not blindly retry all failed mounts without auto_unmount, it should retry them only when we are sure that auto_unmount was the reason the first attempt failed. --- pkg/volume/glusterfs/glusterfs.go | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/pkg/volume/glusterfs/glusterfs.go b/pkg/volume/glusterfs/glusterfs.go index bbeef798713..9bdb6cce03b 100644 --- a/pkg/volume/glusterfs/glusterfs.go +++ b/pkg/volume/glusterfs/glusterfs.go @@ -344,24 +344,23 @@ func (b *glusterfsMounter) setUpAtInternal(dir string) error { return nil } - // Give a try without `auto_unmount mount option, because - // it could be that gluster fuse client is older version and - // mount.glusterfs is unaware of `auto_unmount`. - // Use a mount string without `auto_unmount`` - - autoMountOptions := make([]string, len(mountOptions)) - for _, opt := range mountOptions { - if opt != "auto_unmount" { - autoMountOptions = append(autoMountOptions, opt) + const invalidOption = "Invalid option auto_unmount" + if dstrings.Contains(errs.Error(), invalidOption) { + // Give a try without `auto_unmount` mount option, because + // it could be that gluster fuse client is older version and + // mount.glusterfs is unaware of `auto_unmount`. + noAutoMountOptions := make([]string, len(mountOptions)) + for _, opt := range mountOptions { + if opt != "auto_unmount" { + noAutoMountOptions = append(noAutoMountOptions, opt) + } + } + errs = b.mounter.Mount(ip+":"+b.path, dir, "glusterfs", noAutoMountOptions) + if errs == nil { + glog.Infof("glusterfs: successfully mounted %s", dir) + return nil } } - - autoErr := b.mounter.Mount(ip+":"+b.path, dir, "glusterfs", autoMountOptions) - if autoErr == nil { - glog.Infof("glusterfs: successfully mounted %s", dir) - return nil - } - } // Failed mount scenario.