Skip to content

Commit 15e5305

Browse files
a-wainuclearcat
authored andcommitted
kernelci: config: reduce noise during config parsing
When loading configuration files for the first time, the current job isn't configured yet and we're missing important params such as the target architecture. However, we try to parse and format every single string from the config, leading to numerous errors being printed to the console. As those are `KeyError` exceptions, we should process them separately and only print a message for other types of exceptions. Fixes #2988 Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
1 parent 0cadb3b commit 15e5305

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

kernelci/config/base.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,15 @@ def _format_dict_strings(param, fmap):
7373
if isinstance(param, str):
7474
try:
7575
param = param.format_map(fmap)
76-
except (KeyError, ValueError) as exc:
77-
print(f"Format string error in param '{param}': {exc}")
76+
# Upon loading the config files, we go through lots of fields (e.g. `nfsroot`)
77+
# that contain unresolved params (such as `debarch` or `kver`) as we're not
78+
# processing a job yet. In such cases, format_map() returns a KeyError we can
79+
# just ignore.
80+
except KeyError:
7881
return param # Don't do anything but keep python happy
82+
except ValueError as exc:
83+
print(f"Format string error in param '{param}': {exc}")
84+
return param # Return the unformatted param, this will help spot the error
7985
elif isinstance(param, dict):
8086
for key in param:
8187
param[key] = _format_dict_strings(param[key], fmap)

0 commit comments

Comments
 (0)