landscape-config: --silent fails with unhelpful twisted error file not found when log_level config value is invalid
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Landscape Client |
Fix Committed
|
Medium
|
Mitch Burton |
Bug Description
Low-priority, but something that hit me during development of cc_landscape module in cloud-init.
Bad landscape/
$ cat > ls2.yaml <<EOF
#cloud-config
packages: [landscape-client]
EOF
$ lxc launch ubuntu-daily:mantic ls-m -c cloud-init.
$ lxc exec ls-m -- cloud-init status --wait --long
$ lxc exec ls-m -- landscape-config --silent --account-
Created symlink /etc/systemd/
Please wait...
Traceback (most recent call last):
Failure: twisted.
No longs in /var/log/landscape appear to be emitted as a result of the landscape-config CLI command. So debugging is unhelpful.
To confirm the failure issue one can try to invoke the broker directly which gives a helpful traceback as to what my problem was:
$ sudo -u landscape /usr/bin/python3 /usr/bin/
Traceback (most recent call last):
File "/usr/bin/
run(
File "/usr/lib/
run_
File "/usr/lib/
init_
File "/usr/lib/
logging.
File "/usr/lib/
_init_logging(
File "/usr/lib/
logger.
File "/usr/lib/
self.level = _checkLevel(level)
File "/usr/lib/
raise ValueError("Unknown level: %r" % level)
ValueError: Unknown level: "Level 'INFO'"
inv
This can be reproduced outside of calling landscape-config, by introducing the invalid value of log_level: 'info' in /etc/landscape/
description: | updated |
summary: |
- landscape-config: --silent fails with unhelpful socket error when - log_level config value in invalid + landscape-config: --silent fails with unhelpful twisted error file not + found when log_level config value is invalid |
Changed in landscape-client: | |
assignee: | nobody → Mitch Burton (mitchburton) |
status: | New → Confirmed |
importance: | Undecided → Medium |
Changed in landscape-client: | |
status: | Confirmed → Triaged |
Changed in landscape-client: | |
status: | Triaged → In Progress |
Changed in landscape-client: | |
status: | In Progress → Fix Committed |
The logging library should provide a better error using "!r" to avoid confusing messages.
I have added a little check to provide a better error from our side, now the error would look like this:
AttributeError: Unknown level "'info'", conversion to logging code was "Level 'INFO'"
The solution has been provided in: /github. com/canonical/ landscape- client/ pull/166
https:/