Skip to content

Commit

Permalink
Fix missing informations on geo replication tab of GlusterFS volumes.
Browse files Browse the repository at this point in the history
Since the upgrade to oVirt 4.5 and GlusterFS 10, information about
snapshots and geo replication are no more visible on the engine Webui.
After digging VDSM logs, I found that it's caused by the change of some
XML elements name introduced in a new Gluster release
(gluster/glusterfs#1568) and by the addition of
the timezone in output of status command.

This commit fix the parsing process of the output returned by gluster
command, so that data sent to ovirt engine are as expected.

Bug-URL: https://bugzilla.redhat.com/show_bug.cgi?id=2104278
  • Loading branch information
yasalos committed Oct 20, 2022
1 parent 00d2f80 commit 46ba996
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 18 deletions.
28 changes: 20 additions & 8 deletions lib/vdsm/gluster/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1125,7 +1125,7 @@ def _parseGeoRepStatus(tree):
bricks: [{host: 'local node',
hostUuid: 'uuid of brick host',
brickName: 'brick in the local volume',
remoteHost: 'slave',
remoteHost: 'secondary',
status: 'status'
remoteUserName: 'root'
timeZone: 'nodes time zone'
Expand All @@ -1142,24 +1142,36 @@ def _parseGeoRepStatus(tree):
]....
}
"""
gluster_old_format = tree.find('geoRep/volume/sessions/session/session_secondary') is None
status = {}
for volume in tree.findall('geoRep/volume'):
sessions = []
volumeDetail = {}
for session in volume.findall('sessions/session'):
pairs = []
sessionDetail = {}
sessionDetail['sessionKey'] = session.find('session_slave').text
if gluster_old_format:
sessionDetail['sessionKey'] = session.find('session_slave').text
else:
sessionDetail['sessionKey'] = session.find('session_secondary').text
sessionDetail['remoteVolumeName'] = sessionDetail[
'sessionKey'].split("::")[-1].split(":")[0]
for pair in session.findall('pair'):
pairDetail = {}
pairDetail['host'] = pair.find('master_node').text
pairDetail['hostUuid'] = pair.find(
'master_node_uuid').text
pairDetail['brickName'] = pair.find('master_brick').text
pairDetail['remoteHost'] = pair.find('slave_node').text
pairDetail['remoteUserName'] = pair.find('slave_user').text
if gluster_old_format:
pairDetail['host'] = pair.find('master_node').text
pairDetail['hostUuid'] = pair.find('master_node_uuid').text
pairDetail['brickName'] = pair.find('master_brick').text
pairDetail['remoteHost'] = pair.find('slave_node').text
if pairDetail['remoteHost'] is None:
pairDetail['remoteHost'] = pair.find('slave').text.split("::")[0]
pairDetail['remoteUserName'] = pair.find('slave_user').text
else:
pairDetail['host'] = pair.find('primary_node').text
pairDetail['hostUuid'] = pair.find('primary_node_uuid').text
pairDetail['brickName'] = pair.find('primary_brick').text
pairDetail['remoteHost'] = pair.find('secondary').text.split("::")[0]
pairDetail['remoteUserName'] = pair.find('secondary_user').text
pairDetail['status'] = pair.find('status').text
pairDetail['crawlStatus'] = pair.find('crawl_status').text
pairDetail['timeZone'] = _TIME_ZONE
Expand Down
20 changes: 10 additions & 10 deletions tests/glusterGeoRepStatus.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@
<name>vol1</name>
<sessions>
<session>
<session_slave>6a2f7584-05a8-4651-8786-1cd6ae87b896:ssh://192.168.122.145::vol2</session_slave>
<session_secondary>6a2f7584-05a8-4651-8786-1cd6ae87b896:ssh://192.168.122.145::vol2:3e8382d6-f509-49db-b64f-59a8dfb5ee3b</session_secondary>
<pair>
<master_node>localhost.localdomain</master_node>
<master_node_uuid>6a2f7584-05a8-4651-8786-1cd6ae87b896</master_node_uuid>
<master_brick>/root/b1_vol1</master_brick>
<slave_user>root</slave_user>
<slave>192.168.122.145::vol2</slave>
<slave_node>192.168.122.145</slave_node>
<primary_node>localhost.localdomain</primary_node>
<primary_node_uuid>6a2f7584-05a8-4651-8786-1cd6ae87b896</primary_node_uuid>
<primary_brick>/root/b1_vol1</primary_brick>
<secondary_user>root</secondary_user>
<secondary>192.168.122.145::vol2</secondary>
<secondary_node/>
<status>Stopped</status>
<crawl_status>N/A</crawl_status>
<last_synced>2014-12-12 05:18:23</last_synced>
<entry>0</entry>
<data>0</data>
<meta>0</meta>
<failures>0</failures>
<checkpoint_time>2014-12-12 05:17:23</checkpoint_time>
<checkpoint_completion_time>2014-12-12 05:18:20</checkpoint_completion_time>
<checkpoint_completed>Yes</checkpoint_completed>
<checkpoint_time>2014-12-12 05:17:23</checkpoint_time>
<checkpoint_completion_time>2014-12-12 05:18:20</checkpoint_completion_time>
<checkpoint_completed>Yes</checkpoint_completed>
</pair>
</session>
</sessions>
Expand Down
34 changes: 34 additions & 0 deletions tests/glusterGeoRepStatusOld.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<cliOutput>
<opRet>0</opRet>
<opErrno>0</opErrno>
<opErrstr/>
<geoRep>
<volume>
<name>vol1</name>
<sessions>
<session>
<session_slave>6a2f7584-05a8-4651-8786-1cd6ae87b896:ssh://192.168.122.145::vol2</session_slave>
<pair>
<master_node>localhost.localdomain</master_node>
<master_node_uuid>6a2f7584-05a8-4651-8786-1cd6ae87b896</master_node_uuid>
<master_brick>/root/b1_vol1</master_brick>
<slave_user>root</slave_user>
<slave>192.168.122.145::vol2</slave>
<slave_node>192.168.122.145</slave_node>
<status>Stopped</status>
<crawl_status>N/A</crawl_status>
<last_synced>2014-12-12 05:18:23</last_synced>
<entry>0</entry>
<data>0</data>
<meta>0</meta>
<failures>0</failures>
<checkpoint_time>2014-12-12 05:17:23</checkpoint_time>
<checkpoint_completion_time>2014-12-12 05:18:20</checkpoint_completion_time>
<checkpoint_completed>Yes</checkpoint_completed>
</pair>
</session>
</sessions>
</volume>
</geoRep>
</cliOutput>
2 changes: 2 additions & 0 deletions tests/glusterGeoRepStatusOld.xml.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SPDX-FileCopyrightText: Red Hat, Inc.
SPDX-License-Identifier: GPL-2.0-or-later
27 changes: 27 additions & 0 deletions tests/glusterTestData.py
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,33 @@ class TestStorageDev(object):


GLUSTER_GEOREP_STATUS = {
'vol1': {
'sessions': [
{'bricks': [
{'status': 'Stopped',
'brickName': '/root/b1_vol1',
'crawlStatus': 'N/A',
'hostUuid': '6a2f7584-05a8-4651-8786-1cd6ae87b896',
'remoteHost': '192.168.122.145',
'checkpointCompletionTime': 1418361500,
'meta': '0',
'checkpointCompleted': 'Yes',
'host': 'localhost.localdomain',
'checkpointTime': 1418361443,
'lastSynced': 1418361503,
'failures': '0',
'entry': '0',
'remoteUserName': 'root',
'timeZone': 'IST',
'data': '0'}],
'remoteVolumeName': 'vol2',
'sessionKey': '6a2f7584-05a8-4651-8786-1cd6ae87b896:ssh:'
'//192.168.122.145::vol2:3e8382d6-f509-49db-b64f-59a8dfb5ee3b'}
]
}
}

GLUSTER_GEOREP_STATUS_OLD = {
'vol1': {
'sessions': [
{'bricks': [
Expand Down
8 changes: 8 additions & 0 deletions tests/gluster_cli_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1287,6 +1287,14 @@ def test_parseGeoRepStatus(self):
status = gcli._parseGeoRepStatus(tree)
self.assertEqual(status, glusterTestData.GLUSTER_GEOREP_STATUS)

def test_parseGeoRepStatusOld(self):
with open("glusterGeoRepStatusOld.xml") as f:
out = f.read()
tree = etree.fromstring(out)
gcli._TIME_ZONE = 'IST'
status = gcli._parseGeoRepStatus(tree)
self.assertEqual(status, glusterTestData.GLUSTER_GEOREP_STATUS_OLD)

def test_parseVolumeGeoRepConfig(self):
with open("glusterVolumeGeoRepConfigList.xml") as f:
out = f.read()
Expand Down

0 comments on commit 46ba996

Please sign in to comment.