Skip to content

Commit

Permalink
fix(get_scylla_versions): handle offline installer case
Browse files Browse the repository at this point in the history
this function is broken when offline installer test are run
and we don't have the version in Argus,
with this change, skip getting the version from RPMs/DEBs
and use the scylla commandline only

Fixes: #6388
  • Loading branch information
fruch committed Nov 22, 2023
1 parent ec8aaa7 commit f6e1627
Showing 1 changed file with 26 additions and 16 deletions.
42 changes: 26 additions & 16 deletions sdcm/db_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,31 +559,41 @@ def _init_stats(self):

def get_scylla_versions(self):
versions = {}
node = self.db_cluster.nodes[0]
try:
node = self.db_cluster.nodes[0]
if node.scylla_version_detailed and 'build-id' in node.scylla_version_detailed:
build_id = node.scylla_version_detailed.split('with build-id ')[-1].strip()
else:
build_id = node.get_scylla_build_id()
if node.distro.is_rhel_like:
version_cmd = 'rpm -qa |grep scylla'

# handle offline installer case
if self.params.get('unified_package'):
match = re.search(r'(([\w.~]+)-(0.)?([0-9]{8,8}).(\w+).)', node.scylla_version_detailed)
if match:
versions['scylla-server'] = versions.get('scylla-server', {}) | {'version': match.group(2),
'date': match.group(4),
'commit_id': match.group(5),
'build_id': build_id if build_id else ''}
else:
version_cmd = "dpkg -l |grep scylla|awk '{print $2 \"-\" $3}'"
versions_output = node.remoter.run(version_cmd).stdout.splitlines()
for line in versions_output:
for package in ['scylla-jmx', 'scylla-server', 'scylla-tools', 'scylla-enterprise-jmx',
'scylla-enterprise-server', 'scylla-enterprise-tools']:
match = re.search(r'(%s-([\w.~]+)-(0.)?([0-9]{8,8}).(\w+).)' % package, line)
if match:
versions[package.replace('-enterprise', '')] = {'version': match.group(2),
'date': match.group(4),
'commit_id': match.group(5),
'build_id': build_id if build_id else ''}
if node.distro.is_rhel_like:
version_cmd = 'rpm -qa |grep scylla'
else:
version_cmd = "dpkg -l |grep scylla|awk '{print $2 \"-\" $3}'"
versions_output = node.remoter.run(version_cmd).stdout.splitlines()
for line in versions_output:
for package in ['scylla-jmx', 'scylla-server', 'scylla-tools', 'scylla-enterprise-jmx',
'scylla-enterprise-server', 'scylla-enterprise-tools']:
match = re.search(r'(%s-([\w.~]+)-(0.)?([0-9]{8,8}).(\w+).)' % package, line)
if match:
versions[package.replace('-enterprise', '')] = {'version': match.group(2),
'date': match.group(4),
'commit_id': match.group(5),
'build_id': build_id if build_id else ''}
except Exception as ex: # pylint: disable=broad-except
LOGGER.error('Failed getting scylla versions: %s', ex)
LOGGER.exception('Failed getting scylla versions: %s', ex)

# append Scylla build mode in scylla_versions
versions['scylla-server']['build_mode'] = node.scylla_build_mode
versions['scylla-server'] = versions.get('scylla-server', {}) | {'build_mode': node.scylla_build_mode}

return versions

Expand Down

0 comments on commit f6e1627

Please sign in to comment.