cloud-init devel net-convert crash when --debug is enabled
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
cloud-init |
Fix Released
|
High
|
Chad Smith |
Bug Description
Since 22.2 enabling "--debug" for "cloud-init devel net-convert" will make cloud-init crash.
Probably linked to 3e5938c6ae22b9f
Stack trace shows:
Traceback (most recent call last):
File "/xyz/git/
sys.
File "/xyz/git/
retval = util.log_time(
File "/xyz/git/
ret = func(*args, **kwargs)
File "/xyz/git/
"\n".join(["", "Internal State", safeyaml.dumps(ns, noalias=True), ""])
File "/xyz/git/
return yaml.dump(
File "/xyz/git/
return dump_all([data], stream, Dumper=Dumper, **kwds)
File "/xyz/git/
dumper.
File "/xyz/git/
node = self.represent_
File "/xyz/git/
node = self.yaml_
File "/xyz/git/
raise RepresenterErro
yaml.represente
i tried to replace to dumper with the unsafe version and it was working again
Thank you for this bug and making cloud-init better and for the additional commit reference as a guess for when regression was introduced.
You are correct that I reintroduced SafeDumper default and that's what broke the cloud-init devel net-convert command.
Because the original commit cf30836645473c6 2599e838ab48b2d 31677fa584 had inadvertently switched to using yaml.Dumper when dropping the direct yaml.safe_dump() call we deemed it reasonable to switch that dumper back to the original SafeDumper as all runtime callsites provide only simple types and not python objects.
Turns out, the command `cloud-init devel net-convert --debug` does attempt to stuff in a python object as you noted NetworkState.
I have reviewed all runtime call-sites to cloudinit. safeyaml. dumps and all of the objects that cloud-init currently provides are dictionaries of simple dicts with the exception of this devel --debug command.
Here is an upstream PR to fix this one callsite and add a unit test so we recognize this type of failure in the future. https:/ /github. com/canonical/ cloud-init/ pull/1484