Skip to content

Commit

Permalink
vdsm: get gluster volume info from any gluster peer
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
josgutie committed Apr 24, 2024
1 parent c641c1f commit cb497ae
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
18 changes: 15 additions & 3 deletions lib/vdsm/storage/storageServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,21 @@ def _get_gluster_volinfo(self):
volinfo = superVdsmProxy.glusterVolumeInfo(self._volname,
self._volfileserver)
return volinfo[self._volname]
except ge.GlusterCmdExecFailedException as e:
log.warning("Failed to get volume info: %s", e)
return {}
except ge.GlusterException as e:
# The remote host may be down.
# If we are running on a hyperconverged system the gluster client
# can use one of the other gluster servers.
log.info("Failed to get volume info from remote server %s: %s",
self._volfileserver, e)
try:
log.debug("Trying to get volume info from backup servers: %s",
self._options)
volinfo = superVdsmProxy.glusterVolumeInfo(self._volname)
return volinfo[self._volname]
except ge.GlusterException as e:
log.warning(
"Failed to get volume info from backup servers: %s", e)
return {}


class NFSConnection(Connection):
Expand Down
27 changes: 27 additions & 0 deletions tests/storage/storageserver_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,33 @@ def test_glusterfs_cli_missing(self, monkeypatch):
gluster = GlusterFSConnection(id="id", spec="192.168.122.1:/music")
assert gluster.options == ""

@pytest.mark.parametrize("userMountOptions", [
'',
'backup-volfile-servers=192.168.122.1:192.168.122.2',
])
def test_glusterfs_backup_serv_connection(self, monkeypatch,
userMountOptions):
monkeypatch.setattr(storageServer, 'supervdsm', FakeSupervdsm())
monkeypatch.setattr(gluster_cli, 'exists', lambda: True)

def glusterVolumeInfo(volname=None, volfileServer=None):
assert volname == "music"
if volfileServer is not None:
raise ge.GlusterException()
return {'music': {'brickCount': '2',
'bricks': ['192.168.122.1:/tmp/music',
'192.168.122.2:/tmp/music']
}
}
storageServer.supervdsm.glusterVolumeInfo = glusterVolumeInfo
gluster = GlusterFSConnection(id="id", spec="192.168.122.3:/music",
options=userMountOptions)
expected_volinfo = {'brickCount': '2',
'bricks': ['192.168.122.1:/tmp/music',
'192.168.122.2:/tmp/music']
}
assert gluster.volinfo == expected_volinfo


class TestGlusterFSNotAccessibleConnection:

Expand Down

0 comments on commit cb497ae

Please sign in to comment.