Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vdsm: get gluster volume info from any gluster peer #412

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
log.debug("Trying to get volume info from backup servers: %s",
self._options)
try:
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
34 changes: 34 additions & 0 deletions tests/storage/storageserver_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,40 @@ 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_retry_withotut_volfile_server(self, monkeypatch,
userMountOptions):
"""
The test will fail if called with volfileserver, simulating the case
when a remote server is down. If the caller try again without
volfileserver the call will succeed, simulating the case when running
on a hyperconverged system when the local glsuter glsuter client can
use one of the connected servers.
"""
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()
aesteve-rh marked this conversation as resolved.
Show resolved Hide resolved
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
nirs marked this conversation as resolved.
Show resolved Hide resolved


class TestGlusterFSNotAccessibleConnection:

Expand Down
Loading