Adding --debug breaks argument parsing
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
cloud-init (Ubuntu) |
Fix Released
|
Undecided
|
Calvin Mwadime Makokha |
Bug Description
This is on 22.04.3, specifically 23.3.1-
I'm planning to use "cloud-init clean" to prepare golden images. I was hoping to get some insight into what, exactly, the script is doing under the hood (reading cmd/clean.py helps but part of that is hard to follow without already knowing the internals of cloud-init) so I tried running with the '--debug' flag documented as showing "additional pre-action logging".
% cloud-init --debug clean -h
usage: /usr/bin/cloud-init clean [-h]
options:
-h, --help show this help message and exit
Interesting, but removing --debug helps:
% cloud-init clean -h
usage: /usr/bin/cloud-init clean [-h] [-l] [--machine-id] [-r] [-s]
options:
-h, --help show this help message and exit
-l, --logs Remove cloud-init logs.
--machine-id Set /etc/machine-id to [...elided for launchpad brevity...]
-r, --reboot Reboot system after logs are cleaned so cloud-init re-runs.
-s, --seed Remove cloud-init seed directory /var/lib/
Okay, in fairness, most users won't be running --debug at the same time as --help, but I would still have expected it to print *at least* the same help output if not more debugging stuff.
So I try running it for realsies:
# cloud-init --debug clean --logs --machine-id --seed
usage: /usr/bin/cloud-init [-h] [--version] [--file FILES] [--debug] [--force]
/usr/bin/
# cloud-init --debug clean
Traceback (most recent call last):
File "/usr/bin/
sys.
File "/usr/lib/
(name, functor) = args.action
AttributeError: 'Namespace' object has no attribute 'action'
That outcome is less than awesome.
Running without --debug worked:
# cloud-init clean --logs --machine-id --seed
# echo $?
0
#
Although in the absence of --debug output, it's necessary to go look around the filesystem to verify what's been changed vis-a-vis what options were given.
Changed in cloud-init (Ubuntu): | |
assignee: | nobody → Calvin Mwadime Makokha (calvinmwadime) |
status: | New → In Progress |
Hello Tired Sysadmin,
Thank you for making cloud-init better but submitting the bug. I have reproduced the issue on a container and was able to find the problem. We had a bug when parsing the argparse options and subcommands. I will be putting up a PR on Github to solve this bug. I will update the thread with the PR link later.