From 413380e5575f2211b2eb8aaa85e8e8dd2e17f507 Mon Sep 17 00:00:00 2001 From: Humble Chirammal Date: Tue, 18 Jul 2017 22:26:21 +0530 Subject: [PATCH] The `backup-volfile-servers` mount option allows to specify more than one server to be contacted in single mount command. With this option in place, it is not required to iterate over all the servers in the addrlist. A mount attempt with this option will fetch all the servers mentioned in the list, Reference # https://access.redhat.com/documentation/en-US/Red_Hat_Storage/3/html/Administration_Guide/sect-Native_Client.html Signed-off-by: Humble Chirammal --- pkg/volume/glusterfs/glusterfs.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pkg/volume/glusterfs/glusterfs.go b/pkg/volume/glusterfs/glusterfs.go index 1853a00a4de..20d4446fa19 100644 --- a/pkg/volume/glusterfs/glusterfs.go +++ b/pkg/volume/glusterfs/glusterfs.go @@ -335,9 +335,13 @@ func (b *glusterfsMounter) setUpAtInternal(dir string) error { options = append(options, "backup-volfile-servers="+dstrings.Join(addrlist[:], ":")) mountOptions := volume.JoinMountOptions(b.mountOptions, options) - // Avoid mount storm, pick a host randomly. - // Iterate all hosts until mount succeeds. - for _, ip := range addrlist { + // with `backup-volfile-servers` mount option in place, it is not required to + // iterate over all the servers in the addrlist. A mount attempt with this option + // will fetch all the servers mentioned in the backup-volfile-servers list. + // Refer backup-volfile-servers @ https://access.redhat.com/documentation/en-US/Red_Hat_Storage/3/html/Administration_Guide/sect-Native_Client.html + + if (len(addrlist) > 0) && (addrlist[0] != "") { + ip := addrlist[0] errs = b.mounter.Mount(ip+":"+b.path, dir, "glusterfs", mountOptions) if errs == nil { glog.Infof("glusterfs: successfully mounted %s", dir) @@ -361,6 +365,8 @@ func (b *glusterfsMounter) setUpAtInternal(dir string) error { return nil } } + } else { + return fmt.Errorf("glusterfs: failed to execute mount command:[no valid ipaddress found in endpoint address list]") } // Failed mount scenario.