Skip to content

Commit d206f0b

Browse files
josgutieaesteve-rh
authored andcommitted
vdsm: get gluster volume info from any gluster peer
The function _get_gluster_volinfo query the glusterfs volume info the the storage server, this is translated to the gluster client adding the parameter --remote-host which limits the query to one server, so we are converting the storage server as a single point of failure, if it is not available, it can led to cluster outtage. The proposed changed let the cluster cli to use any available gluster peer. Signed-off-by: José Enrique Gutiérrez Mazón <[email protected]>
1 parent c641c1f commit d206f0b

File tree

2 files changed

+49
-3
lines changed

2 files changed

+49
-3
lines changed

lib/vdsm/storage/storageServer.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,21 @@ def _get_gluster_volinfo(self):
387387
volinfo = superVdsmProxy.glusterVolumeInfo(self._volname,
388388
self._volfileserver)
389389
return volinfo[self._volname]
390-
except ge.GlusterCmdExecFailedException as e:
391-
log.warning("Failed to get volume info: %s", e)
392-
return {}
390+
except ge.GlusterException as e:
391+
# The remote host may be down.
392+
# If we are running on a hyperconverged system the gluster client
393+
# can use one of the other gluster servers.
394+
log.info("Failed to get volume info from remote server %s: %s",
395+
self._volfileserver, e)
396+
log.debug("Trying to get volume info from backup servers: %s",
397+
self._options)
398+
try:
399+
volinfo = superVdsmProxy.glusterVolumeInfo(self._volname)
400+
return volinfo[self._volname]
401+
except ge.GlusterException as e:
402+
log.warning(
403+
"Failed to get volume info from backup servers: %s", e)
404+
return {}
393405

394406

395407
class NFSConnection(Connection):

tests/storage/storageserver_test.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,40 @@ def test_glusterfs_cli_missing(self, monkeypatch):
250250
gluster = GlusterFSConnection(id="id", spec="192.168.122.1:/music")
251251
assert gluster.options == ""
252252

253+
@pytest.mark.parametrize("userMountOptions", [
254+
'',
255+
'backup-volfile-servers=192.168.122.1:192.168.122.2',
256+
])
257+
def test_glusterfs_retry_withotut_volfile_server(self, monkeypatch,
258+
userMountOptions):
259+
"""
260+
The test will fail if called with volfileserver, simulating the case
261+
when a remote server is down. If the caller try again without
262+
volfileserver the call will succeed, simulating the case when running
263+
on a hyperconverged system when the local glsuter glsuter client can
264+
use one of the connected servers.
265+
"""
266+
monkeypatch.setattr(storageServer, 'supervdsm', FakeSupervdsm())
267+
monkeypatch.setattr(gluster_cli, 'exists', lambda: True)
268+
269+
def glusterVolumeInfo(volname=None, volfileServer=None):
270+
assert volname == "music"
271+
if volfileServer is not None:
272+
raise ge.GlusterException()
273+
return {'music': {'brickCount': '2',
274+
'bricks': ['192.168.122.1:/tmp/music',
275+
'192.168.122.2:/tmp/music']
276+
}
277+
}
278+
storageServer.supervdsm.glusterVolumeInfo = glusterVolumeInfo
279+
gluster = GlusterFSConnection(id="id", spec="192.168.122.3:/music",
280+
options=userMountOptions)
281+
expected_volinfo = {'brickCount': '2',
282+
'bricks': ['192.168.122.1:/tmp/music',
283+
'192.168.122.2:/tmp/music']
284+
}
285+
assert gluster.volinfo == expected_volinfo
286+
253287

254288
class TestGlusterFSNotAccessibleConnection:
255289

0 commit comments

Comments
 (0)