1
0
Fork 0

systemd: do not backup the drop-in configuration

Resolves: RHEL-84365
This commit is contained in:
Fothsid 2026-03-19 16:53:38 +01:00
parent eb86a14dd6
commit 47395d84fb
3 changed files with 6 additions and 16 deletions

View file

@ -1 +1,3 @@
# Please avoid changing this file, as it will
# be overwritten by TuneD!
[Manager] [Manager]

View file

@ -69,7 +69,7 @@ MODULES_FILE = "/etc/modprobe.d/tuned.conf"
# systemd plugin configuration # systemd plugin configuration
SYSTEMD_SYSTEM_CONF_FILE = SYSTEMD_CFG_PATH + "/system.conf.d/00-tuned.conf" SYSTEMD_SYSTEM_CONF_FILE = SYSTEMD_CFG_PATH + "/system.conf.d/00-tuned.conf"
SYSTEMD_SYSTEM_CONF_HEADER = "[Manager]" SYSTEMD_SYSTEM_CONF_HEADER = "# Please avoid changing this file, as it will\n# be overwritten by TuneD!\n[Manager]"
SYSTEMD_CPUAFFINITY_VAR = "CPUAffinity" SYSTEMD_CPUAFFINITY_VAR = "CPUAffinity"
# irqbalance plugin configuration # irqbalance plugin configuration

View file

@ -19,6 +19,8 @@ class SystemdPlugin(base.Plugin):
affinity for the service manager as well as the default CPU affinity affinity for the service manager as well as the default CPU affinity
for all forked off processes. The option takes a comma-separated for all forked off processes. The option takes a comma-separated
list of CPUs with optional CPU ranges specified by the minus sign (`-`). list of CPUs with optional CPU ranges specified by the minus sign (`-`).
Please avoid changing the drop-in configuration file, as it is not
backed up and will be overwritten.
.Set the CPUAffinity for `systemd` to `0 1 2 3` .Set the CPUAffinity for `systemd` to `0 1 2 3`
==== ====
@ -99,19 +101,10 @@ class SystemdPlugin(base.Plugin):
return False return False
return True return True
def _get_storage_filename(self):
return os.path.join(consts.PERSISTENT_STORAGE_DIR, self.name)
def _remove_systemd_tuning(self): def _remove_systemd_tuning(self):
conf = self._read_systemd_system_conf() conf = self._read_systemd_system_conf()
if (conf is not None): if (conf is not None):
fname = self._get_storage_filename() conf = self._del_key(conf, consts.SYSTEMD_CPUAFFINITY_VAR)
cpu_affinity_saved = self._cmd.read_file(fname, err_ret = None, no_error = True)
self._cmd.unlink(fname)
if cpu_affinity_saved is None:
conf = self._del_key(conf, consts.SYSTEMD_CPUAFFINITY_VAR)
else:
conf = self._add_keyval(conf, consts.SYSTEMD_CPUAFFINITY_VAR, cpu_affinity_saved)
self._write_systemd_system_conf(conf) self._write_systemd_system_conf(conf)
def _instance_unapply_static(self, instance, rollback = consts.ROLLBACK_SOFT): def _instance_unapply_static(self, instance, rollback = consts.ROLLBACK_SOFT):
@ -139,11 +132,6 @@ class SystemdPlugin(base.Plugin):
if verify: if verify:
return self._verify_value("cpu_affinity", v_unpacked, conf_affinity_unpacked, ignore_missing) return self._verify_value("cpu_affinity", v_unpacked, conf_affinity_unpacked, ignore_missing)
if enabling: if enabling:
fname = self._get_storage_filename()
cpu_affinity_saved = self._cmd.read_file(fname, err_ret = None, no_error = True)
if conf_affinity is not None and cpu_affinity_saved is None and v_unpacked != conf_affinity_unpacked:
self._cmd.write_to_file(fname, conf_affinity, makedir = True)
log.info("setting '%s' to '%s' in the '%s'" % (consts.SYSTEMD_CPUAFFINITY_VAR, v_unpacked, consts.SYSTEMD_SYSTEM_CONF_FILE)) log.info("setting '%s' to '%s' in the '%s'" % (consts.SYSTEMD_CPUAFFINITY_VAR, v_unpacked, consts.SYSTEMD_SYSTEM_CONF_FILE))
self._write_systemd_system_conf(self._add_keyval(conf, consts.SYSTEMD_CPUAFFINITY_VAR, v_unpacked)) self._write_systemd_system_conf(self._add_keyval(conf, consts.SYSTEMD_CPUAFFINITY_VAR, v_unpacked))
return True return True