landscape-config: --silent fails with unhelpful twisted error file not found when log_level config value is invalid

Bug #2027521 reported by Chad Smith
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Landscape Client
Fix Committed
Mitch Burton

Bug Description

Low-priority, but something that hit me during development of cc_landscape module in cloud-init.

Bad landscape/client.conf values for log_level do not result in helpful errors or logs when using landscape-config --silent.

$ cat > ls2.yaml <<EOF
packages: [landscape-client]

$ lxc launch ubuntu-daily:mantic ls-m -c cloud-init.user-data="$(cat ls2.yaml)"

$ lxc exec ls-m -- cloud-init status --wait --long
$ lxc exec ls-m -- landscape-config --silent --account-name=your-account --computer-title=mytestvm --data-path=/var/lib/landscape/client --log-level="'info'" --ping-url= --url=

Created symlink /etc/systemd/system/ → /lib/systemd/system/landscape-client.service.
Please wait...
Traceback (most recent call last):
Failure: twisted.internet.error.ConnectError: An error occurred while connecting: 2: No such file or directory.

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/landscape-broker

Traceback (most recent call last):
  File "/usr/bin/landscape-broker", line 8, in <module>
  File "/usr/lib/python3/dist-packages/landscape/client/broker/", line 94, in run
    run_landscape_service(BrokerConfiguration, BrokerService, args)
  File "/usr/lib/python3/dist-packages/landscape/client/", line 73, in run_landscape_service
    init_logging(configuration, service_class.service_name)
  File "/usr/lib/python3/dist-packages/landscape/client/", line 17, in init_logging
    logging.init_app_logging(configuration.log_dir, configuration.log_level,
  File "/usr/lib/python3/dist-packages/landscape/lib/", line 32, in init_app_logging
  File "/usr/lib/python3/dist-packages/landscape/lib/", line 45, in _init_logging
  File "/usr/lib/python3.11/logging/", line 1464, in setLevel
    self.level = _checkLevel(level)
  File "/usr/lib/python3.11/logging/", line 207, in _checkLevel
    raise ValueError("Unknown level: %r" % level)
ValueError: Unknown level: "Level 'INFO'"

This can be reproduced outside of calling landscape-config, by introducing the invalid value of log_level: 'info' in /etc/landscape/client.conf.

Chad Smith (chad.smith)
description: updated
Chad Smith (chad.smith)
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
Revision history for this message
Juanmi Taboada (juanmitaboada) wrote :

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:

Changed in landscape-client:
status: Triaged → In Progress
Changed in landscape-client:
status: In Progress → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.