Repository navigation
fix(config): strip whitespace around comma-separated config values - #3700
Merged
nicolargo merged 1 commit intoAug 29, 2026
Merged
Conversation
load_limits split a config list on ',' and kept the spaces, so 'list=cpu, mem, load' became ['cpu', ' mem', ' load']. glances.conf writes lists that way in its own comments, so following the shipped documentation produced a config that did not work. The loudest symptom is show/hide: every item is used as a re.fullmatch pattern, and a leading space makes the pattern match nothing. 'hide=sda2, loop.*' hid sda2 and silently kept showing every loop device. Quicklook also answered a bad list by falling back to AVAILABLE_STATS_LIST - more than the user asked for, and its two GPU entries flip the gpu_stats polling flags, so a typo started polling the GPU. It now falls back to the documented DEFAULT_STATS_LIST and names the offending entries in the warning.
Owner
|
Thanks for the PR @ntdatt812 Just merged into develop. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
list=cpu, mem, loaddoes not work, and glances.conf documents it that wayload_limitssplits a config list and keeps the spaces:So
list=cpu, mem, loadbecomes['cpu', ' mem', ' load']. That is how anyone writes a comma-separated value, and it is howconf/glances.confwrites one in its own comment:# Available stats are: cpu,mem,load,swap, gpu_mem, gpu_procA user copying that line gets a list where four of the six items carry a leading space.
The loudest symptom is show/hide
Every item in those lists is used as a
re.fullmatchpattern, so a leading space makes the pattern match nothing at all. Withhide=sda2, loop.*:The rule is accepted, logged, and silently does nothing. Nothing tells the user their filter is dead.
Quicklook: a config mistake showed more than the default
Separately, quicklook answered an unrecognised list by falling back to everything available:
AVAILABLE_STATS_LISTcontainsgpu_memandgpu_proc, and the next three lines use exactly those to flipgpu_stats.get_gpu_mem/get_gpu_proc. So a typo — or, before the first fix, an ordinary space — started polling the GPU on a machine whose owner never asked for it. That is not a neutral default; on the AMD runtime-PM hardware in #3590 it is reads against a suspended card.Measured on
develop:All three now resolve to what the user asked for, or to
DEFAULT_STATS_LIST— the same listget_conf_valuealready uses as itsdefault=. The warning also names which entries were unrecognised, instead of printing the whole list back.Scope
Two changes, kept together because fixing either alone leaves the other reachable: with only the strip, a genuine typo still turns on the GPU; with only the fallback,
list=cpu, mem, loadstill silently degrades.The strip lives in
load_limits, so it is one place rather than one per plugin. It touches only the edges of each item — internal spaces survive, which matters for values likealias=sda1:System Disk, and there is a test pinning that.I looked for anything that could depend on the old behaviour.
ConfigParseralready strips the value as a whole, so a leading or trailing space on a single-item value was never reachable; only interior items were affected, and for those the space was never wanted.bar_charreads[0]of its list and is a single item, so it is unaffected either way.Verification
11 new tests in
tests/test_plugin_quicklook.py. Seven of them are red againstdevelop:(The hide/show test was added after that run and is red too; it is the
loop0case shown above.)Full suite, same invocation both times, only
glances/reverted for the baseline:develop(new test file excluded)652 = 641 + the 11 new tests, and the two failure sets are identical — I diffed the
FAILEDnames, and bothcommdirections are empty. The 40 are pre-existing and environmental on this box:test_restful.pyandtest_xmlrpc.pycannot start their servers here, plustest_perfandtest_memoryleak.test_mcp.pyand the browser/webui suites were excluded from both runs for the same reason.ruff checkandruff format --checkclean on all three files.