AttributeError: 'NoneType' object has no attribute 'partition'

Bug #1997559 reported by Olivier Gayot
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-init (Ubuntu)
Fix Released
High
Alberto Contreras
Bionic
Fix Released
Undecided
Unassigned
Focal
Fix Released
Undecided
Unassigned
Jammy
Fix Released
Undecided
Unassigned
Kinetic
Fix Released
Undecided
Unassigned

Bug Description

[ Impact ]

In very early boot, before cloud-init creates /run/cloud-init/status.json calls to cloud-init status --wait can result in a Traceback due to the the default JSON value of "datasource": null. This fix handles gracefully reporting datasource=None instead of assuming that we will have a non-empty string for the detected datasource type.

[ Test Plan ]

The following test plan reprouced this issue 100% of the time on LXC containers with images containing cloud-init version 22.4.0

 * Create a clean LXC image from <series>-proposed pocket
 * Launch and lxc container and immediately run cloud-init status --wait to ensure no race exists.

cat > setup_proposed.sh <<EOF
#/bin/bash
mirror=http://archive.ubuntu.com/ubuntu
echo deb \$mirror \$(lsb_release -sc)-proposed main | tee /etc/apt/sources.list.d/proposed.list
apt-get update -q
apt-get install -qy cloud-init
EOF

for RELEASE in bionic focal jammy kinetic; do
 echo "### test SRU for $RELEASE"
 lxc launch ubuntu-daily:$RELEASE sru-$RELEASE;
 lxc exec sru-$RELEASE -- cloud-init status --wait;
 echo "### update to -proposed pocket"
 lxc file push setup_proposed.sh sru-$RELEASE/
 lxc exec sru-$RELEASE -- /sru-$RELEASE/setup_proposed.sh
 echo "### boot clean and validate cloud-init status --wait
 lxc exec sru-$RELEASE -- cloud-init clean --logs --reboot
 lxc exec sru-$RELEASE -- cloud-init status --wait
 lxc exec sru-$RELEASE -- grep Traceback /var/log/cloud-init.log
done

[ Where problems could occur ]

 * The fix shores up a gap in the initial/default state of /run/cloud-init/status.json before datasource is initially detected. It only touches logic if very early boot to supplement the value types supported for the 'datasource' key. This fix generally doesn't expose any change in behavior beyond handling the early boot race condition. If this risk were implemented incorrectly. Any subsequent calls to `cloud-init status` or `cloud-init status --wait` would traceback in a similar fashion. Since later invocations for cloud-init status are validated by existing cloud-init integration tests this risk is low.

[ Other Info ]

This regression discovery was during SRU validation timeframe for 22.4.0 and is subsequently been included in cloud-init upstream version 22.4.2. (Already published to Ubuntu Lunar (23.04).

[ Original Description ]

Hello,

Cloud-init version 2.4-0ubuntu4 (currently in lunar), fails in certain conditions when running cloud-init status --wait:

Traceback (most recent call last):
  File "/usr/bin/cloud-init", line 33, in <module>
    sys.exit(load_entry_point('cloud-init==22.4', 'console_scripts', 'cloud-init')())
  File "/usr/lib/python3/dist-packages/cloudinit/cmd/main.py", line 1086, in main
    retval = util.log_time(
  File "/usr/lib/python3/dist-packages/cloudinit/util.py", line 2680, in log_time
    ret = func(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/cloudinit/cmd/status.py", line 119, in handle_status_args
    details = get_status_details(paths)
  File "/usr/lib/python3/dist-packages/cloudinit/cmd/status.py", line 232, in get_status_details
    datasource, _, _ = value.partition(" ")
AttributeError: 'NoneType' object has no attribute 'partition'

We noticed that it broke our subiquity pipeline, see https://github.com/canonical/subiquity/actions/runs/3493835896/jobs/5922374078

This seems to fail when invoking cloud-init status --wait (very) early.

Reproducer:

#!/bin/bash
lxc launch --ephemeral ubuntu-daily:lunar test
lxc exec test -- cloud-init status --wait

I believe it might also affect the versions being SRUed (https://bugs.launchpad.net/ubuntu/+source/cloud-init/+bug/1996645) but I don't have a good way to test it myself.

Olivier Gayot (ogayot)
description: updated
description: updated
Olivier Gayot (ogayot)
description: updated
Revision history for this message
Alberto Contreras (aciba) wrote :

After doing a quick bisect, I think the regression was introduced in https://github.com/canonical/cloud-init/commit/274b23ec18bebc4c77357e4a5db08c0bc5627e5a, which is part of the current SRU of cloud-init 22.4 .

Changed in cloud-init (Ubuntu):
status: New → Triaged
Changed in cloud-init (Ubuntu):
importance: Undecided → High
Changed in cloud-init (Ubuntu):
assignee: nobody → Alberto Contreras (aciba)
status: Triaged → In Progress
Revision history for this message
Alberto Contreras (aciba) wrote :
Changed in cloud-init (Ubuntu):
status: In Progress → Fix Committed
Chad Smith (chad.smith)
Changed in cloud-init (Ubuntu):
status: Fix Committed → Fix Released
James Falcon (falcojr)
tags: added: regression-proposed
Chad Smith (chad.smith)
description: updated
Chad Smith (chad.smith)
description: updated
description: updated
Revision history for this message
Chad Smith (chad.smith) wrote :

Targeting this bug to Ubuntu Bionic, Focal, Jammy and Kinetic because cloud-init version 22.4.0 was present in the '-proposed' pocket during SRU validation before this bug was discovered.

It did not affect published release images, but for tracking purposes we are targeting it to those series as well. Expected fix is is cloud-init version 22.4.2 which will be released shortly to the -updates pocket for each series.

Revision history for this message
Brian Murray (brian-murray) wrote : Please test proposed package

Hello Olivier, or anyone else affected,

Accepted cloud-init into kinetic-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/cloud-init/22.4.2-0ubuntu0~22.10.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-kinetic to verification-done-kinetic. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-kinetic. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

description: updated
Changed in cloud-init (Ubuntu Kinetic):
status: New → Fix Committed
tags: added: verification-needed verification-needed-kinetic
Revision history for this message
Brian Murray (brian-murray) wrote :

Hello Olivier, or anyone else affected,

Accepted cloud-init into jammy-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/cloud-init/22.4.2-0ubuntu0~22.04.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-jammy to verification-done-jammy. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-jammy. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in cloud-init (Ubuntu Jammy):
status: New → Fix Committed
tags: added: verification-needed-jammy
Changed in cloud-init (Ubuntu Focal):
status: New → Fix Committed
tags: added: verification-needed-focal
Revision history for this message
Brian Murray (brian-murray) wrote :

Hello Olivier, or anyone else affected,

Accepted cloud-init into focal-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/cloud-init/22.4.2-0ubuntu0~20.04.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-focal to verification-done-focal. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-focal. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in cloud-init (Ubuntu Bionic):
status: New → Fix Committed
tags: added: verification-needed-bionic
Revision history for this message
Brian Murray (brian-murray) wrote :

Hello Olivier, or anyone else affected,

Accepted cloud-init into bionic-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/cloud-init/22.4.2-0ubuntu0~18.04.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-bionic to verification-done-bionic. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-bionic. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Revision history for this message
James Falcon (falcojr) wrote :

Using a modified version of the script mentioned in the test plan:

#!/bin/bash

for RELEASE in bionic focal jammy kinetic; do
 echo "### test SRU for $RELEASE"
 lxc launch ubuntu-daily:$RELEASE sru-$RELEASE;
 lxc exec sru-$RELEASE -- cloud-init status --wait
 echo "### update to -proposed pocket"
 lxc file push setup_proposed.sh sru-$RELEASE/
 lxc exec sru-$RELEASE -- chmod 777 /setup_proposed.sh
 lxc exec sru-$RELEASE -- /setup_proposed.sh &>/dev/null
 lxc exec sru-$RELEASE -- cloud-init --version
 echo "### boot clean and validate cloud-init status --wait"
 lxc exec sru-$RELEASE -- cloud-init clean --logs --reboot &> /dev/null
 while lxc exec sru-$RELEASE -- test ! -f /var/log/cloud-init.log ; do
     lxc exec sru-$RELEASE -- cloud-init status --wait &> /dev/null
 done
 lxc exec sru-$RELEASE -- grep Traceback /var/log/cloud-init.log
done

I do not see the bug in the proposed version:

newt:script $ ./test_stuff.sh | tee log.txt
### test SRU for bionic
Creating sru-bionic
Starting sru-bionic
....................
status: done
### update to -proposed pocket
/usr/bin/cloud-init 22.4.2-0ubuntu0~18.04.1
### boot clean and validate cloud-init status --wait
Error: Instance is not running
Error: Instance is not running
### test SRU for focal
Creating sru-focal
Starting sru-focal
.............................
status: done
### update to -proposed pocket
/usr/bin/cloud-init 22.4.2-0ubuntu0~20.04.1
### boot clean and validate cloud-init status --wait
Error: Instance is not running
Error: Instance is not running
### test SRU for jammy
Creating sru-jammy
Starting sru-jammy
..........................
status: done
### update to -proposed pocket
/usr/bin/cloud-init 22.4.2-0ubuntu0~22.04.1
### boot clean and validate cloud-init status --wait
Error: Instance is not running
Error: Instance is not running
### test SRU for kinetic
Creating sru-kinetic
Starting sru-kinetic
.......................................
status: done
### update to -proposed pocket
/usr/bin/cloud-init 22.4.2-0ubuntu0~22.10.1
### boot clean and validate cloud-init status --wait
Error: Instance is not running
Error: Instance is not running

Revision history for this message
Chad Smith (chad.smith) wrote (last edit ):

Confirmation/validation from Olivier Gayot related to testing 22.4.2:
"""
It's not there yet in the ubuntu-daily LXD image but the pipeline succeeds if we update the container and reboot it before proceeding with the rest of instructions, so to me this is enough to confirm the regression is gone
"""

tags: added: verification-done verification-done-bionic verification-done-focal verification-done-jammy verification-done-kinetic
removed: verification-needed verification-needed-bionic verification-needed-focal verification-needed-jammy verification-needed-kinetic
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package cloud-init - 22.4.2-0ubuntu0~22.10.1

---------------
cloud-init (22.4.2-0ubuntu0~22.10.1) kinetic; urgency=medium

  * Upstream snapshot based on 22.4.2 upstream release. (LP: #1996645)
    - List of changes from upstream can be found at
      https://raw.githubusercontent.com/canonical/cloud-init/22.4.2/ChangeLog
    - Includes (LP: #1997559, #1844191) not present in 22.4.0.

cloud-init (22.4-0ubuntu0~22.10.1) kinetic; urgency=medium

  * d/control: drop python3-httpretty from Build-Depends
  * d/cloud-init.templates: Add NWCS to datasource list
  * Upstream snapshot based on 22.4 upstream release. (LP: #1996645)
    List of changes from upstream can be found at
    https://raw.githubusercontent.com/canonical/cloud-init/22.4/ChangeLog

 -- James Falcon <email address hidden> Mon, 28 Nov 2022 10:45:45 -0600

Changed in cloud-init (Ubuntu Kinetic):
status: Fix Committed → Fix Released
Revision history for this message
Brian Murray (brian-murray) wrote : Update Released

The verification of the Stable Release Update for cloud-init has completed successfully and the package is now being released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package cloud-init - 22.4.2-0ubuntu0~22.04.1

---------------
cloud-init (22.4.2-0ubuntu0~22.04.1) jammy; urgency=medium

  * Upstream snapshot based on 22.4.2 upstream release. (LP: #1996645)
    - List of changes from upstream can be found at
      https://raw.githubusercontent.com/canonical/cloud-init/22.4.2/ChangeLog
    - Includes (LP: #1997559, #1844191) not present in 22.4.0.

cloud-init (22.4-0ubuntu0~22.04.1) jammy; urgency=medium

  * d/control: drop python3-httpretty from Build-Depends
  * d/cloud-init.templates: Add NWCS to datasource list
  * refresh patches:
    + debian/patches/expire-on-hashed-users.patch
  * Upstream snapshot based on 22.4 upstream release. (LP: #1996645)
    List of changes from upstream can be found at
    https://raw.githubusercontent.com/canonical/cloud-init/22.4/ChangeLog

 -- James Falcon <email address hidden> Mon, 28 Nov 2022 10:32:24 -0600

Changed in cloud-init (Ubuntu Jammy):
status: Fix Committed → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package cloud-init - 22.4.2-0ubuntu0~20.04.1

---------------
cloud-init (22.4.2-0ubuntu0~20.04.1) focal; urgency=medium

  * Upstream snapshot based on 22.4.2 upstream release. (LP: #1996645)
    - List of changes from upstream can be found at
      https://raw.githubusercontent.com/canonical/cloud-init/22.4.2/ChangeLog
    - Includes (LP: #1997559, #1844191) not present in 22.4.0.

cloud-init (22.4-0ubuntu0~20.04.1) focal; urgency=medium

  * d/control: drop python3-httpretty from Build-Depends
  * d/cloud-init.templates: Add NWCS to datasource list
  * refresh patches:
    + debian/patches/expire-on-hashed-users.patch
  * Upstream snapshot based on 22.4 upstream release. (LP: #1996645)
    List of changes from upstream can be found at
    https://raw.githubusercontent.com/canonical/cloud-init/22.4/ChangeLog

 -- James Falcon <email address hidden> Mon, 28 Nov 2022 10:48:49 -0600

Changed in cloud-init (Ubuntu Focal):
status: Fix Committed → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package cloud-init - 22.4.2-0ubuntu0~18.04.1

---------------
cloud-init (22.4.2-0ubuntu0~18.04.1) bionic; urgency=medium

  * Upstream snapshot based on 22.4.2 upstream release. (LP: #1996645)
    - List of changes from upstream can be found at
      https://raw.githubusercontent.com/canonical/cloud-init/22.4.2/ChangeLog
    - Includes (LP: #1997559, #1844191) not present in 22.4.0.

cloud-init (22.4-0ubuntu0~18.04.1) bionic; urgency=medium

  * d/control: drop python3-httpretty from Build-Depends
  * d/cloud-init.templates: Add NWCS to datasource list
  * refresh patches:
    + debian/patches/expire-on-hashed-users.patch
  * Upstream snapshot based on 22.4 upstream release. (LP: #1996645)
    List of changes from upstream can be found at
    https://raw.githubusercontent.com/canonical/cloud-init/22.4/ChangeLog

 -- James Falcon <email address hidden> Mon, 28 Nov 2022 10:50:30 -0600

Changed in cloud-init (Ubuntu Bionic):
status: Fix Committed → Fix Released
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.