Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError comparing float to string: load_threshold #648

Open
panlinux opened this issue Jun 22, 2024 · 0 comments
Open

TypeError comparing float to string: load_threshold #648

panlinux opened this issue Jun 22, 2024 · 0 comments

Comments

@panlinux
Copy link

panlinux commented Jun 22, 2024

2024-06-22 13:25:31,304 ERROR    tuned.units.manager: Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/tuned/units/manager.py", line 119, in _try_call
    return f(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/tuned/plugins/instance/instance.py", line 80, in apply_tuning
    self._plugin.instance_apply_tuning(self)
  File "/usr/lib/python3/dist-packages/tuned/plugins/base.py", line 266, in instance_apply_tuning
    self._run_for_each_device(instance, self._instance_apply_dynamic, instance.assigned_devices)
  File "/usr/lib/python3/dist-packages/tuned/plugins/base.py", line 207, in _run_for_each_device
    callback(instance, device)
  File "/usr/lib/python3/dist-packages/tuned/plugins/plugin_cpu.py", line 391, in _instance_apply_dynamic
    self._instance_update_dynamic(instance, device)
  File "/usr/lib/python3/dist-packages/tuned/plugins/plugin_cpu.py", line 399, in _instance_update_dynamic
    if load < instance.options["load_threshold"]:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: '<' not supported between instances of 'float' and 'str'

I have a custom profile with the following, used in a test case:

[main]

[cpu]
load_threshold=0.5
latency_low=10
latency_high=10000

The load_threshold value is being read as a string, instead of a number/float. Am I using the wrong syntax?

It was patched like this in Ubuntu (patch by @lucaskanashiro):

--- a/tuned/plugins/plugin_cpu.py
+++ b/tuned/plugins/plugin_cpu.py
@@ -394,7 +394,7 @@ class CPULatencyPlugin(hotplug.Plugin):
            return

        load = instance._load_monitor.get_load()["system"]
-       if load < instance.options["load_threshold"]:
+       if load < float(instance.options["load_threshold"]):
            self._set_latency(instance.options["latency_high"])
        else:
            self._set_latency(instance.options["latency_low"])

But I was wondering if this shouldn't instead be fixed in whatever is reading the config file and populating instance.options. I'm poking around a bit, but thought I would open this bug too.

Reading up on ConfigParser, looks like there is no magic conversion going on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant