canonical / charm-sysconfig

A subordinate charm to apply system settings like grub configurations or systemd configurations.
Apache License 2.0
0 stars 5 forks source link

cpu_range with reservation takes precedence #37

Closed dashmage closed 9 months ago

dashmage commented 9 months ago

When specifying cpu_range, reservation, and migrating to the new options. Some people may forget to reset the cpu_range/reservaton value, this will take precedence over the new value

juju config cpu_range=1,2,3,4 reservation=affinity cpu-affinity-range=1,2

If the above command it run, the CPUAffinity will be set to 1,2,3,4 and not 1,2


--- lib_sysconfig.py.orig   2022-10-20 11:19:13.203798104 +0000
+++ lib_sysconfig.py    2022-10-20 11:20:13.752422277 +0000
**@** -192,7 +192,7 **@**
     **property**
     def cpu_affinity_range(self):
         """Return cpu-affinity-range config."""
-        if self.reservation == "affinity" and self.cpu_range:
+        if self.charm_config["cpu-affinity-range"] == "" and self.reservation == "affinity" and self.cpu_range:
             return self.cpu_range
         return self.charm_config["cpu-affinity-range"]

**@** -218,7 +218,7 **@**
     **property**
     def isolcpus(self):
         """Return isolcpus config."""
-        if self.reservation == "isolcpus" and self.cpu_range:
+        if self.charm_config["isolcpus"] == "" and self.reservation == "isolcpus" and self.cpu_range:
             return self.cpu_range
         return self.charm_config["isolcpus"]

~~

I suspect a change like above should do the trick, or something similar

The workaround, and ought to unset the cpu_range/reservation values

------------------------------------
Imported from Launchpad using lp2gh.

 * date created: 2022-10-20T11:22:27Z
 * owner: [arif-ali](https://launchpad.net/~arif-ali)
 * assignee: [arif-ali](https://launchpad.net/~arif-ali)

 * the launchpad [url](https://bugs.launchpad.net/bugs/1993648)