Files
scylladb/dist/common/scripts/scylla_cpuset_setup
Vlad Zolotarov c538cc2372 scylla_prepare + scylla_cpuset_setup: make scylla_cpuset_setup idempotent without introducing regressions
This patch fixes the regression introduced by 3a51e78 which broke
a very important contract: perftune.yaml should not be "touched"
by Scylla scriptology unless explicitly requested.

And a call for scylla_cpuset_setup is such an explicit request.

The issue that the offending patch was intending to fix was that
cpuset.conf was always generated anew for every call of
scylla_cpuset_setup - even if a resulting cpuset.conf would come
out exactly the same as the one present on the disk before tha call.

And since the original code was following the contract mentioned above
it was also deleting perftune.yaml every time too.
However, this was just an unavoidable side-effect of that cpuset.conf
re-generation.

The above also means that if scylla_cpuset_setup doesn't write to cpuset.conf
we should not "touch" perftune.yaml and vise versa.

This patch implements exactly that together with reverting the dangerous
logic introduced by 3a51e78.

Fixes #11385
Fixes #10121
2022-08-25 13:03:02 -04:00

47 lines
1.4 KiB
Python
Executable File

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright 2018-present ScyllaDB
#
#
# SPDX-License-Identifier: AGPL-3.0-or-later
import os
import sys
import argparse
from scylla_util import *
if __name__ == '__main__':
if os.getuid() > 0:
print('Requires root permission.')
sys.exit(1)
parser = argparse.ArgumentParser(description='Configure cpuset configuration for Scylla.')
parser.add_argument('--cpuset',
help='CPUs to use (in cpuset(7) format; default: all))')
parser.add_argument('--smp',
help='number of threads (default: one per CPU)')
args = parser.parse_args()
if not args.cpuset and not args.smp:
parser.print_help()
sys.exit(1)
cpuset = smp = None
try:
cfg = sysconfig_parser('/etc/scylla.d/cpuset.conf')
line = cfg.get('CPUSET')
cpuset_args = parser.parse_args(line.split())
cpuset = cpuset_args.cpuset
smp = cpuset_args.smp
except:
pass
if cpuset != args.cpuset or smp != args.smp:
if os.path.exists('/etc/scylla.d/perftune.yaml'):
os.remove('/etc/scylla.d/perftune.yaml')
cfg.set('CPUSET', '{cpuset}{smp}'.format( \
cpuset='--cpuset {} '.format(args.cpuset) if args.cpuset else '', \
smp='--smp {} '.format(args.smp) if args.smp else '' \
))
cfg.commit()