dpkg-reconfigure cloud-init: yaml.load errors during MAAS deloyment of Ubuntu 23.04(Lunar)

Bug #2009746 reported by Chad Smith
18
This bug affects 3 people
Affects Status Importance Assigned to Milestone
MAAS
Invalid
Undecided
Unassigned
cloud-init
Fix Released
High
Chad Smith
maas (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

Affects cloud-init 23.1.1 Lunar

MAAS deployed Ubuntu 23.04 (Lunar) machines invoke `dpkg-reconfigure cloud-init` which results in an exit 1 with the following traceback as seen in curtin logs:

Running command ['unshare', '--fork', '--pid', '--', 'chroot', '/tmp/tmpwr8y_4f8/target', 'dpkg-reconfigure', '--frontend=noninteractive', 'cloud-init'] with allowed return codes [0] (capture=True)
finish: cmd-install/stage-curthooks/builtin/cmd-curthooks/writing-apt-config: FAIL: configuring apt configuring apt
finish: cmd-install/stage-curthooks/builtin/cmd-curthooks: FAIL: curtin command curthooks
Traceback (most recent call last):
  File "/curtin/curtin/commands/main.py", line 202, in main
    ret = args.func(args)
          ^^^^^^^^^^^^^^^
  File "/curtin/curtin/commands/curthooks.py", line 1886, in curthooks
    builtin_curthooks(cfg, target, state)
  File "/curtin/curtin/commands/curthooks.py", line 1692, in builtin_curthooks
    do_apt_config(cfg, target)
  File "/curtin/curtin/commands/curthooks.py", line 97, in do_apt_config
    apt_config.handle_apt(apt_cfg, target)
  File "/curtin/curtin/commands/apt_config.py", line 73, in handle_apt
    apply_debconf_selections(cfg, target)
  File "/curtin/curtin/commands/apt_config.py", line 167, in apply_debconf_selections
    dpkg_reconfigure(need_reconfig, target=target)
  File "/curtin/curtin/commands/apt_config.py", line 133, in dpkg_reconfigure
    util.subp(['dpkg-reconfigure', '--frontend=noninteractive'] +
  File "/curtin/curtin/util.py", line 275, in subp
    return _subp(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/curtin/curtin/util.py", line 139, in _subp
    raise ProcessExecutionError(stdout=out, stderr=err,
curtin.util.ProcessExecutionError: Unexpected error while running command.
Command: ['unshare', '--fork', '--pid', '--', 'chroot', '/tmp/tmpwr8y_4f8/target', 'dpkg-reconfigure', '--frontend=noninteractive', 'cloud-init']
Exit code: 1
Reason: -
Stdout: ''
Stderr: Traceback (most recent call last):
          File "<string>", line 23, in <module>
        TypeError: load() missing 1 required positional argument: 'Loader'

Ubuntu 23.04 Lunar has published PyYAML 6.0.1[1] which finally changed the signature on yaml.load to require a Loader= parameter.

This traceback is due to a stale call to yaml.load() in cloud-init.postinst[2] that should have migrated to yaml.safe_load.

In Jammy and and earlier, PyYAML was still emitting deprecation warning messages to stderr, but those warnings are silenced automatically by any invocation to `dpkg-reconfigure --frontend=noninteractive cloud-init`. So none of the warnings showed up in curtin or MAAS, until we got an explicit non-zero exit code.

References:
[1] Pyyaml 6.0.1 commit sync'd to lunar https://git.launchpad.net/ubuntu/+source/pyyaml/commit/?id=5308dbefbe5dc7ce4a19adbfdb4c4e08a798217d
[2] yaml.load failure on Lunar: https://github.com/canonical/cloud-init/blob/ubuntu/devel/debian/cloud-init.postinst#L41

Chad Smith (chad.smith)
Changed in cloud-init:
importance: Undecided → High
status: New → Triaged
assignee: nobody → Chad Smith (chad.smith)
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in maas (Ubuntu):
status: New → Confirmed
Revision history for this message
Chad Smith (chad.smith) wrote :

Upstream commit merged for this bug. https://github.com/canonical/cloud-init/commit/fa935d4cf7e542d0686d8b1ac55df0229b4adac1

Expect this to be fixed in Ubuntu Lunar cloud-init version 23.1.1-0ubuntu2.

Changed in cloud-init:
status: Triaged → Fix Committed
Changed in maas:
status: New → Triaged
importance: Undecided → High
tags: added: bug-council
Changed in maas:
status: Triaged → Invalid
importance: High → Undecided
tags: removed: bug-council
Changed in maas (Ubuntu):
status: Confirmed → Invalid
Brett Holman (holmanb)
Changed in cloud-init:
status: Fix Committed → Fix Released
Revision history for this message
James Falcon (falcojr) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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