2023-07-11 23:04:54 |
Chad Smith |
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
#cloud-config
packages: [landscape-client]
EOF
$ 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=http://landscape.canonical.com/ping --url=https://landscape.canonical.com/message-system
Created symlink /etc/systemd/system/multi-user.target.wants/landscape-client.service → /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>
run(sys.argv)can
File "/usr/lib/python3/dist-packages/landscape/client/broker/service.py", line 94, in run
run_landscape_service(BrokerConfiguration, BrokerService, args)
File "/usr/lib/python3/dist-packages/landscape/client/service.py", line 73, in run_landscape_service
init_logging(configuration, service_class.service_name)
File "/usr/lib/python3/dist-packages/landscape/client/deployment.py", line 17, in init_logging
logging.init_app_logging(configuration.log_dir, configuration.log_level,
File "/usr/lib/python3/dist-packages/landscape/lib/logging.py", line 32, in init_app_logging
_init_logging(
File "/usr/lib/python3/dist-packages/landscape/lib/logging.py", line 45, in _init_logging
logger.setLevel(level)
File "/usr/lib/python3.11/logging/__init__.py", line 1464, in setLevel
self.level = _checkLevel(level)
^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/logging/__init__.py", line 207, in _checkLevel
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/client.conf.
I |
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
#cloud-config
packages: [landscape-client]
EOF
$ 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=http://landscape.canonical.com/ping --url=https://landscape.canonical.com/message-system
Created symlink /etc/systemd/system/multi-user.target.wants/landscape-client.service → /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>
run(sys.argv)can
File "/usr/lib/python3/dist-packages/landscape/client/broker/service.py", line 94, in run
run_landscape_service(BrokerConfiguration, BrokerService, args)
File "/usr/lib/python3/dist-packages/landscape/client/service.py", line 73, in run_landscape_service
init_logging(configuration, service_class.service_name)
File "/usr/lib/python3/dist-packages/landscape/client/deployment.py", line 17, in init_logging
logging.init_app_logging(configuration.log_dir, configuration.log_level,
File "/usr/lib/python3/dist-packages/landscape/lib/logging.py", line 32, in init_app_logging
_init_logging(
File "/usr/lib/python3/dist-packages/landscape/lib/logging.py", line 45, in _init_logging
logger.setLevel(level)
File "/usr/lib/python3.11/logging/__init__.py", line 1464, in setLevel
self.level = _checkLevel(level)
^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/logging/__init__.py", line 207, in _checkLevel
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/client.conf. |
|