scylla_sysconfig_setup: avoid perse error on perftune.py --get-cpu-mask

Currently, we just passes entire output of perftune.py when getting CPU
mask from the script, but it may cause parse error since the script may
also print warning message.

To avoid that, we need to extract CPU mask from the output.

Fixes #10082

Closes #10107
This commit is contained in:
Takuya ASADA
2022-02-21 10:11:56 +09:00
committed by Avi Kivity
parent 024ecd45a2
commit 59adf05951

View File

@@ -70,7 +70,17 @@ if __name__ == '__main__':
network_mode = args.mode if args.mode else cfg.get('NETWORK_MODE')
if args.setup_nic_and_disks:
rps_cpus = run('{} --tune net --nic {} --get-cpu-mask'.format(perftune_base_command(), ifname), shell=True, check=True, capture_output=True, encoding='utf-8').stdout.strip()
res = run('{} --tune net --nic {} --get-cpu-mask'.format(perftune_base_command(), ifname), shell=True, check=True, capture_output=True, encoding='utf-8').stdout
# we need to extract CPU mask from output, since perftune.py may also print warning messages (#10082)
match = re.match('(.*)(0x[0-9a-f]+)', res, re.DOTALL)
try:
warning = match.group(1)
rps_cpus = match.group(2)
except:
raise Exception(f'Failed to retrive CPU mask: {res}')
# print warning message if available
if warning:
print(warning.strip())
if len(rps_cpus) > 0:
cpuset = hex2list(rps_cpus)
run('/opt/scylladb/scripts/scylla_cpuset_setup --cpuset {}'.format(cpuset), shell=True, check=True)