postinst fails when cloud-init is installed but never ran

Bug #1936833 reported by Umar Sharief
62
This bug affects 9 people
Affects Status Importance Assigned to Milestone
ubuntu-advantage-tools (Ubuntu)
Fix Released
Medium
Unassigned
Xenial
Fix Released
Critical
Unassigned
Bionic
Fix Released
Critical
Unassigned
Focal
Fix Released
Critical
Unassigned
Hirsute
Fix Released
Critical
Unassigned

Bug Description

[Impact]

Users are not able to install or upgrade ubuntu-advantage-tools in situations where cloud-init is installed in the system, but did not run - either because of some error, or it was disabled, or it did not finished executing yet.

When cloud-init runs, instance-data.json will be available and cloud-id does not fail. The fix checks for the existence of this file, and does not run the script if the file is not present.

Backporting the fix will enable users to install or upgrade ubuntu-advantage tools without problems.

[Test Plan]

The bug can be reproduced by running:
"schroot -c impish-amd64 -u root -d /",
and then within the chroot, running:
"apt-get update && apt-get install -y ubuntu-advantage-tools cloud-init".

Running the above using the patched version of ubuntu-advantage-tools should succeed without any errors.

[Where problems could occur]

The fix itself just skips a call that adds a warning notice to ua.

If the user is running on a cloud and has some kind of error in cloud-init, the user may miss a warning about having the wrong metapackages for the cloud. However, in the case where cloud-init did not run because of some error, the instance has a problem anyway.

If it happens that cloud init did not run yet - as if this happens at image creation time - then cloud-init will be later executed, and the cloud-id checked in the code so those wrong metapackages are not installed.

[Original Description]

This happens when upgrading to Ubuntu 21.10. This is the full error:

Setting up ubuntu-advantage-tools (27.2.1~21.10.1) ... ERROR: File not found '/run/cloud-init/instance-data.json'. Provide a path to instance data json file using --instance-data dpkg: error processing package ubuntu-advantage-tools (--configure): installed ubuntu-advantage-tools package post-installation script subprocess returned error exit status 1 dpkg: dependency problems prevent configuration of ubuntu-minimal: ubuntu-minimal depends on ubuntu-advantage-tools; however: Package ubuntu-advantage-tools is not configured yet.

ProblemType: Package
DistroRelease: Ubuntu 21.10
Package: ubuntu-advantage-tools 27.2.1~21.10.1
Uname: Linux 5.4.72-microsoft-standard-WSL2 x86_64
ApportVersion: 2.20.11-0ubuntu67
Architecture: amd64
CasperMD5CheckResult: unknown
Date: Mon Jul 19 14:32:11 2021
DuplicateSignature:
 package:ubuntu-advantage-tools:27.2.1~21.10.1
 Installing new version of config file /etc/ubuntu-advantage/uaclient.conf ...
 ERROR: File not found '/run/cloud-init/instance-data.json'. Provide a path to instance data json file using --instance-data
 dpkg: error processing package ubuntu-advantage-tools (--configure):
  installed ubuntu-advantage-tools package post-installation script subprocess returned error exit status 1
ErrorMessage: installed ubuntu-advantage-tools package post-installation script subprocess returned error exit status 1
Python3Details: /usr/bin/python3.9, Python 3.9.6, python3-minimal, 3.9.4-1
PythonDetails: N/A
RebootRequiredPkgs: libc6
RelatedPackageVersions:
 dpkg 1.20.9ubuntu2
 apt 2.3.6
SourcePackage: ubuntu-advantage-tools
Title: package ubuntu-advantage-tools 27.2.1~21.10.1 failed to install/upgrade: installed ubuntu-advantage-tools package post-installation script subprocess returned error exit status 1
UpgradeStatus: Upgraded to impish on 2021-07-19 (0 days ago)

Related branches

Revision history for this message
Umar Sharief (noyb1415252) wrote :
tags: removed: need-duplicate-check
Revision history for this message
Grant Orndorff (orndorffgrant) wrote :

Thanks for the bug report!

ubuntu-advantage-tools tries to run `cloud-id` if the command is present during postinst to find a certain edge case and notify the user.

It looks like cloud-id was available, but instance-data.json was missing, so cloud-id failed. I believe this would occur if cloud-init is installed on this system but never ran. If you are able to get cloud-init to run and then try to upgrade ubuntu-advantage-tools again, I suspect it will work.

Regardless, ubuntu-advantage-tools should probably be able to handle this situation without failing.

Changed in ubuntu-advantage-tools (Ubuntu):
status: New → Triaged
importance: Undecided → Medium
Revision history for this message
Chad Smith (chad.smith) wrote :

Since this appears to be a WSL-based solution, it would be helpful to have the following attached to this bug:

Run `cloud-init collect-logs` on the system and attach the cloud-init.tar.gz to this bug
Attach /var/log/ubuntu-advantage.log

We can then try to determine the general state of cloud-init and if this was a race condition on WSL ubuntu images.

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

I'm marking this bug as "Incomplete" status at the moment at the top of the page. When you have a chance to respond with any additional information about the failed instance, please mark this bug status back to 'New' so we get eyes on it quickly. Thanks again!

Changed in ubuntu-advantage-tools (Ubuntu):
status: Triaged → Incomplete
Changed in ubuntu-advantage-tools (Ubuntu):
status: Incomplete → Confirmed
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

You can reproduce this by running "schroot -c impish-amd64 -u root -d /" and then within the chroot, run "apt-get install -y ubuntu-advantage-tools cloud-init".

The problem is this bit of the postinst:

    if command -v "cloud-id" > /dev/null ; then
      cloud_id=$(cloud-id)
    fi

In this situation, cloud-id is present but errors. One option would be to change this to:

    cloud_id=$(cloud-id 2>/dev/null || true)

Or another would be to make the call to cloud-id conditional on the existence of /run/cloud-init/instance-data.json.

Either way this is currently blocking my efforts to work on a minimal layer for the live server ISO so it qualifies as pretty annoying :)

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :
Revision history for this message
Umar Sharief (noyb1415252) wrote :
Revision history for this message
Umar Sharief (noyb1415252) wrote :
Revision history for this message
Lucas Albuquerque Medeiros de Moura (lamoura) wrote :

We have landed #1743 which should fix this issue

Changed in ubuntu-advantage-tools (Ubuntu):
status: Confirmed → Fix Committed
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Could you upload the fix to impish pretty please?

botjaeger (botjaeger)
description: updated
Revision history for this message
Pieter Houwen (pieterhouwen) wrote :

When can we expect this to hit production? I just updated my WSL today and I stumbled across this error but I can see from the PR that it is already merged.

Should I do anything to fix this or do I need to just wait?

Revision history for this message
Robie Basak (racb) wrote :

Which Ubuntu releases are affected by this bug?

summary: - package ubuntu-advantage-tools 27.2.1~21.10.1 failed to install/upgrade:
- installed ubuntu-advantage-tools package post-installation script
- subprocess returned error exit status 1
+ postinst fails when cloud-init is installed but never ran
Revision history for this message
Tobias Koch (tobijk) wrote :

27.2.1 is in bionic, focal and hirsute. According to @raof it was SRU'ed, yesterday. Seems this bug slipped through.

Robie Basak (racb)
tags: added: regression-update
Robie Basak (racb)
Changed in ubuntu-advantage-tools (Ubuntu Xenial):
importance: Undecided → Critical
Changed in ubuntu-advantage-tools (Ubuntu Bionic):
importance: Undecided → Critical
Changed in ubuntu-advantage-tools (Ubuntu Focal):
importance: Undecided → Critical
Changed in ubuntu-advantage-tools (Ubuntu Hirsute):
importance: Undecided → Critical
Revision history for this message
Robie Basak (racb) wrote :

We're pulling this update back to -proposed for now.

Revision history for this message
Richard Harding (rharding) wrote : Re: [Bug 1936833] Re: package ubuntu-advantage-tools 27.2.1~21.10.1 failed to install/upgrade: installed ubuntu-advantage-tools package post-installation script subprocess returned error exit status 1

We'll work to release a hotfix with the landed PR asap.

On Tue, Jul 27, 2021 at 4:15 AM Pieter Houwen
<email address hidden> wrote:
>
> When can we expect this to hit production? I just updated my WSL today
> and I stumbled across this error but I can see from the PR that it is
> already merged.
>
> Should I do anything to fix this or do I need to just wait?
>
> --
> You received this bug notification because you are subscribed to ubuntu-
> advantage-tools in Ubuntu.
> https://bugs.launchpad.net/bugs/1936833
>
> Title:
> package ubuntu-advantage-tools 27.2.1~21.10.1 failed to
> install/upgrade: installed ubuntu-advantage-tools package post-
> installation script subprocess returned error exit status 1
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/ubuntu/+source/ubuntu-advantage-tools/+bug/1936833/+subscriptions
>

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

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

Changed in ubuntu-advantage-tools (Ubuntu Bionic):
status: New → Confirmed
Changed in ubuntu-advantage-tools (Ubuntu Focal):
status: New → Confirmed
Changed in ubuntu-advantage-tools (Ubuntu Hirsute):
status: New → Confirmed
Changed in ubuntu-advantage-tools (Ubuntu Xenial):
status: New → Confirmed
Revision history for this message
Robie Basak (racb) wrote : Please test proposed package

Hello Umar, or anyone else affected,

Accepted ubuntu-advantage-tools into hirsute-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/ubuntu-advantage-tools/27.2.2~21.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-hirsute to verification-done-hirsute. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-hirsute. 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 ubuntu-advantage-tools (Ubuntu Hirsute):
status: Confirmed → Fix Committed
tags: added: verification-needed verification-needed-hirsute
Changed in ubuntu-advantage-tools (Ubuntu Focal):
status: Confirmed → Fix Committed
tags: added: verification-needed-focal
Revision history for this message
Robie Basak (racb) wrote :

Hello Umar, or anyone else affected,

Accepted ubuntu-advantage-tools into focal-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/ubuntu-advantage-tools/27.2.2~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 ubuntu-advantage-tools (Ubuntu Bionic):
status: Confirmed → Fix Committed
tags: added: verification-needed-bionic
Revision history for this message
Robie Basak (racb) wrote :

Hello Umar, or anyone else affected,

Accepted ubuntu-advantage-tools into bionic-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/ubuntu-advantage-tools/27.2.2~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.

Changed in ubuntu-advantage-tools (Ubuntu Xenial):
status: Confirmed → Fix Committed
tags: added: verification-needed-xenial
Revision history for this message
Robie Basak (racb) wrote :

Hello Umar, or anyone else affected,

Accepted ubuntu-advantage-tools into xenial-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/ubuntu-advantage-tools/27.2.2~16.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-xenial to verification-done-xenial. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-xenial. 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
Mathieu Marquer (slasher-fun) wrote :

Installation is working (wasn't working with the previous version) with ubuntu-advantage-tools_27.2.2~21.10.1_amd64.deb package from -proposed on Impish.

Pr�paration du d�paquetage de ubuntu-advantage-tools_27.2.2~21.10.1_amd64.deb ...
D�paquetage de ubuntu-advantage-tools (27.2.2~21.10.1) sur (27.2.1~21.10.1) ...
Param�trage de ubuntu-advantage-tools (27.2.2~21.10.1) ...
Traitement des actions diff�r�es (��triggers��) pour man-db (2.9.4-2)�...
mathieu@FRLAPP253:~$

tags: added: verification-done-impish
Revision history for this message
Pieter Houwen (pieterhouwen) wrote :
Download full text (3.6 KiB)

I just tried the focal version. It failed to build with the following output:

root@supersecretstation:/mnt/d/Downloads/ubuntu-advantage-tools/ubuntu-advantage-tools-27.2.2~20.04.1# cp ../ubuntu-advantage-tools_27.2.2~20.04.1.tar.xz .
root@supersecretstation:/mnt/d/Downloads/ubuntu-advantage-tools/ubuntu-advantage-tools-27.2.2~20.04.1# dpkg-buildpackage -us -uc
dpkg-buildpackage: info: source package ubuntu-advantage-tools
dpkg-buildpackage: info: source version 27.2.2~20.04.1
dpkg-buildpackage: info: source distribution focal
dpkg-buildpackage: info: source changed by Lucas Moura <email address hidden>
dpkg-buildpackage: info: host architecture amd64
 dpkg-source --before-build .
 debian/rules clean
dh clean --with python3,bash-completion,systemd --buildsystem=pybuild
   debian/rules override_dh_auto_clean
make[1]: Entering directory '/mnt/d/Downloads/ubuntu-advantage-tools/ubuntu-advantage-tools-27.2.2~20.04.1'
dh_auto_clean
        pybuild --clean --test-pytest -i python{version} -p 3.8
I: pybuild base:217: python3.8 setup.py clean
running clean
removing '/mnt/d/Downloads/ubuntu-advantage-tools/ubuntu-advantage-tools-27.2.2~20.04.1/.pybuild/cpython3_3.8/build' (and everything under it)
'build/bdist.linux-x86_64' does not exist -- can't clean it
'build/scripts-3.8' does not exist -- can't clean it
        rm -rf .pybuild/
        find . -name \*.pyc -exec rm {} \;
make clean
make[2]: Entering directory '/mnt/d/Downloads/ubuntu-advantage-tools/ubuntu-advantage-tools-27.2.2~20.04.1'
rm -f *.build *.buildinfo *.changes .coverage *.deb *.dsc *.tar.gz *.tar.xz
rm -rf *.egg-info/ .tox/ .cache/ .mypy_cache/
find . -type f -name '*.pyc' -delete
find . -type d -name '*__pycache__' -delete
make -C apt-hook clean
make[3]: Entering directory '/mnt/d/Downloads/ubuntu-advantage-tools/ubuntu-advantage-tools-27.2.2~20.04.1/apt-hook'
rm -f hook ubuntu-advantage.pot json-hook-src/json-hook
make[3]: Leaving directory '/mnt/d/Downloads/ubuntu-advantage-tools/ubuntu-advantage-tools-27.2.2~20.04.1/apt-hook'
make[2]: Leaving directory '/mnt/d/Downloads/ubuntu-advantage-tools/ubuntu-advantage-tools-27.2.2~20.04.1'
make[1]: Leaving directory '/mnt/d/Downloads/ubuntu-advantage-tools/ubuntu-advantage-tools-27.2.2~20.04.1'
   dh_clean -O--buildsystem=pybuild
        rm -f debian/debhelper-build-stamp
        rm -rf debian/.debhelper/
        rm -f debian/ubuntu-advantage-pro.debhelper.log debian/ubuntu-advantage-tools.debhelper.log
        rm -f -- debian/ubuntu-advantage-tools.substvars debian/ubuntu-advantage-pro.substvars debian/files
        rm -fr -- debian/ubuntu-advantage-tools/ debian/tmp/ debian/ubuntu-advantage-pro/
        find . \( \( \
                \( -path .\*/.git -o -path .\*/.svn -o -path .\*/.bzr -o -path .\*/.hg -o -path .\*/CVS -o -path .\*/.pc -o -path .\*/_darcs \) -prune -o -type f -a \
                \( -name '#*#' -o -name '.*~' -o -name '*~' -o -name DEADJOE \
                 -o -name '*.orig' -o -name '*.rej' -o -name '*.bak' \
                 -o -name '.*.orig' -o -name .*.rej -o -name '.SUMS' \
                 -o -name TAGS -o \( -path '*/.deps/*' -a -name '*.P' \) \
                \) -exec rm -f {} + \) -o \
                ...

Read more...

Revision history for this message
Renan Rodrigo (renanrodrigo) wrote :

Tested for Xenial, Bionic, Focal and Hirsute, using the attached script.

All packages could be installed despite the cloud-id error.

Revision history for this message
Renan Rodrigo (renanrodrigo) wrote :

Execution results for the script from previous comment can be seen attached here.

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

This bug was fixed in the package ubuntu-advantage-tools - 27.2.2~21.10.1

---------------
ubuntu-advantage-tools (27.2.2~21.10.1) impish; urgency=medium

  * d/tools.postinst:
    - Do not fail in postinst if cloud-init did not run.
      This fixes the regression introduced in 27.2.1. (LP: #1936833)

 -- Lucas Moura <email address hidden> Tue, 27 Jul 2021 10:09:18 -0300

Changed in ubuntu-advantage-tools (Ubuntu):
status: Fix Committed → Fix Released
tags: added: verification-done verification-done-bionic verification-done-focal verification-done-hirsute verification-done-xenial
removed: verification-needed verification-needed-bionic verification-needed-focal verification-needed-hirsute verification-needed-xenial
Revision history for this message
Chris Halse Rogers (raof) wrote : Update Released

The verification of the Stable Release Update for ubuntu-advantage-tools 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 ubuntu-advantage-tools - 27.2.2~16.04.1

---------------
ubuntu-advantage-tools (27.2.2~16.04.1) xenial; urgency=medium

  * Backport new upstream fix: (LP: #1936833) to xenial
    - Fix regression introduced on 27.2.1 (LP: #1934902)

ubuntu-advantage-tools (27.2.2~21.10.1) impish; urgency=medium

  * d/tools.postinst:
    - Do not fail in postinst if cloud-init did not run.
      This fixes the regression introduced in 27.2.1. (LP: #1936833)

 -- Lucas Moura <email address hidden> Tue, 27 Jul 2021 10:50:52 -0300

Changed in ubuntu-advantage-tools (Ubuntu Xenial):
status: Fix Committed → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package ubuntu-advantage-tools - 27.2.2~20.04.1

---------------
ubuntu-advantage-tools (27.2.2~20.04.1) focal; urgency=medium

  * Backport new upstream fix: (LP: #1936833) to focal
    - Fix regression introduced on 27.2.1 (LP: #1934902)

ubuntu-advantage-tools (27.2.2~21.10.1) impish; urgency=medium

  * d/tools.postinst:
    - Do not fail in postinst if cloud-init did not run.
      This fixes the regression introduced in 27.2.1. (LP: #1936833)

 -- Lucas Moura <email address hidden> Tue, 27 Jul 2021 10:54:59 -0300

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

This bug was fixed in the package ubuntu-advantage-tools - 27.2.2~18.04.1

---------------
ubuntu-advantage-tools (27.2.2~18.04.1) bionic; urgency=medium

  * Backport new upstream fix: (LP: #1936833) to bionic
    - Fix regression introduced on 27.2.1 (LP: #1934902)

ubuntu-advantage-tools (27.2.2~21.10.1) impish; urgency=medium

  * d/tools.postinst:
    - Do not fail in postinst if cloud-init did not run.
      This fixes the regression introduced in 27.2.1. (LP: #1936833)

 -- Lucas Moura <email address hidden> Tue, 27 Jul 2021 10:53:16 -0300

Changed in ubuntu-advantage-tools (Ubuntu Bionic):
status: Fix Committed → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package ubuntu-advantage-tools - 27.2.2~21.04.1

---------------
ubuntu-advantage-tools (27.2.2~21.04.1) hirsute; urgency=medium

  * Backport new upstream fix: (LP: #1936833) to hirsute
    - Fix regression introduced on 27.2.1 (LP: #1934902)

ubuntu-advantage-tools (27.2.2~21.10.1) impish; urgency=medium

  * d/tools.postinst:
    - Do not fail in postinst if cloud-init did not run.
      This fixes the regression introduced in 27.2.1. (LP: #1936833)

 -- Lucas Moura <email address hidden> Tue, 27 Jul 2021 10:57:27 -0300

Changed in ubuntu-advantage-tools (Ubuntu Hirsute):
status: Fix Committed → Fix Released
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.