traceback from postinst on upgrade

Bug #1951705 reported by Steve Langasek
20
This bug affects 2 people
Affects Status Importance Assigned to Milestone
ubuntu-advantage-tools (Ubuntu)
Fix Released
Undecided
Unassigned
Xenial
Fix Released
Undecided
Unassigned
Bionic
Fix Released
Undecided
Unassigned
Focal
Fix Released
Undecided
Unassigned
Hirsute
Fix Released
Undecided
Unassigned
Impish
Fix Released
Undecided
Unassigned

Bug Description

[Original bug description]
I noticed this on an upgrade in focal:

Setting up ubuntu-advantage-tools (27.4.1~20.04.1) ...
Installing new version of config file /etc/ubuntu-advantage/uaclient.conf ...
Traceback (most recent call last):
  File "<string>", line 10, in <module>
KeyError: 'status'
Traceback (most recent call last):
  File "<string>", line 10, in <module>
KeyError: 'status'

It's clearly nonfatal, but we shouldn't see python tracebacks in upgrade logs.

[Impact]
This releases will guarantee that unattached users installing ubuntu-advantage-tools in an architecture that is different from i386 and amd64
will no longer see the KeyError issue. Additionally, this will guarantee that the postinst flow where this error is triggered will be finished. However, this should not impact users that saw this bug, since the function was cleaning up old apt sources for esm-infra and esm-apps. However, since the user is unattached, that cleanup should have already happened if those service were once enabled.

[Test Case]

1.Launch an ubuntu machine:
  $ lxc launch ubuntu-daily:xenial dev-x
2. SSH into the machine and update ubuntu-advantage-tools to 27.4.1
3. Run ua status
4. Go into /var/lib/dpkg/info/ubuntu-advantage-tools.postinst and
   change the ESM_SUPPORTED_ARCHS variable to be empty
5. Run dpkg-reconfigure ubuntu-advantage-tools
6. Confirm that the expected error is there
7. Install the new UA package 27.4.2
   https://launchpad.net/~ua-client/+archive/ubuntu/staging/
8. Go into /var/lib/dpkg/info/ubuntu-advantage-tools.postinst and
   change the ESM_SUPPORTED_ARCHS variable to be empty
9. Run the dpkg command again and verify that no errors are shown

<TODO After released to -proposed: attach integration test artifacts>

[Regression Potential]
We currently don't see any regression potential, we are just making the code more resilient to potential errors on unattached scenarios.

[racb] We're adjusting the postinst, so if something goes wrong, it's likely to manifest in the console at package install or upgrade time.

[racb] Sometimes existing issues get exacerbated by issuing an update that causes the postinst to run again.

[Discussion]
Even though this will not affect all architecturse, we believe it is safer to address this as soon as possible, since we don't know when our next major release will be.

[Changelog]

     * d/tools.postinst:
       - Fix check_service_is_enabled function when the machine is
         unattached (LP: #1951705)

Related branches

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):
status: New → Confirmed
Revision history for this message
Renan Rodrigo (renanrodrigo) wrote :

Hello Steve, thanks for reporting this.
Could you please send us a copy of /var/log/ubuntu-advantage.log so the team can take a look on what is happening?
Thanks.

Changed in ubuntu-advantage-tools (Ubuntu):
status: Confirmed → Incomplete
Revision history for this message
Lucas Albuquerque Medeiros de Moura (lamoura) wrote (last edit ):

Hi Steve, I am also trying to reproduce this issue but so far I am unable to reproduce it using a clean lxd focal VM with ubuntu-advantage-tools version 27.3 installed by default. I tried running upgrade with a machine attached and unattached but still no failure prompts were generated.

Was there any config changes applied to the machine before the upgrade ?

Revision history for this message
Steve Langasek (vorlon) wrote :

Here is the complete /var/log/ubuntu-advantage.log from this system:

2021-11-13 05:42:15,532 - upgrade_lts_contract.py:(49) [DEBUG]: Check whether to upgrade-lts-contract
2021-11-13 05:42:15,533 - config.py:(959) [DEBUG]: Using UA client configuration file at /etc/ubuntu-advantage/uaclient.conf
2021-11-13 05:42:15,534 - util.py:(425) [DEBUG]: Reading file: /etc/ubuntu-advantage/uaclient.conf
2021-11-13 05:42:15,553 - util.py:(425) [DEBUG]: Reading file: /var/lib/ubuntu-advantage/private/machine-token.json
2021-11-13 05:42:15,553 - config.py:(508) [DEBUG]: File does not exist: /var/lib/ubuntu-advantage/private/machine-token.json
2021-11-13 05:42:15,554 - upgrade_lts_contract.py:(51) [DEBUG]: Skiping upgrade-lts-contract. Machine is unattached

There were no configuration changes made prior to upgrading. Note that this is an armhf system, so AFAIK no UA services are available for it anyawy.

Revision history for this message
Steve Langasek (vorlon) wrote :

Unrelated, 'Skiping' should be spelled 'Skipping' in the log ;)

Revision history for this message
Steve Langasek (vorlon) wrote :

If I modify the postinst with set -x, I'm able to see that the traceback is from this:

+ /usr/bin/python3 -c
import os
import json
from uaclient.config import UAConfig
cfg = UAConfig()
status = cfg.read_cache('status-cache')
if status:
    for service in status['services']:
       if service['name'] == 'esm-apps':
           print(service['status'])

Traceback (most recent call last):
  File "<string>", line 10, in <module>
KeyError: 'status'

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

Thanks for the information, Steve.
Indeed, this is a bug happening on arm, aarch64 and possibly other architectures.

There is a PR up to fix it: https://github.com/canonical/ubuntu-advantage-client/pull/1891

Changed in ubuntu-advantage-tools (Ubuntu):
status: Incomplete → In Progress
Revision history for this message
Oli D (oliver.drechsler) wrote :

Hi everyone,
i followed your thread and
i've the same error as reported above on my Raspberry Pi 4 with ubuntu server 20.04.
Now I can confirm that the above pull request solved the (and my) problem!
I changed the package on my system, applied the patch/fix manual with the GitHub PullRequest fix and my install worked!!!.
So please merge the GH PR and everything will be fine.

Here's my steps and output:

root:/# cp /var/cache/apt/archives/ubuntu-advantage-tools_27.4.1~20.04.1_arm64.deb /usr/src
root:/usr/src# cd /usr/src
root:/usr/src# mkdir ubuntu-advantage-tools
root:/usr/src# dpkg-deb -R ubuntu-advantage-tools_27.4.1~20.04.1_arm64.deb ubuntu-advantage-tools
root:/usr/src# vi ubuntu-advantage-tools/DEBIAN/postinst. #applied changed from GitHub pr to file
root:/usr/src# dpkg-deb -b ubuntu-advantage-tools ubuntu-advantage-tools_27.4.1-fix~20.04.1_arm64.deb
root:/usr/src# dpkg -i ubuntu-advantage-tools_27.4.1-fix~20.04.1_arm64.deb
(Lese Datenbank ... 162018 Dateien und Verzeichnisse sind derzeit installiert.)
Vorbereitung zum Entpacken von ubuntu-advantage-tools_27.4.1-fix~20.04.1_arm64.deb ...
Entpacken von ubuntu-advantage-tools (27.4.1~20.04.1) über (27.4.1~20.04.1) ...
ubuntu-advantage-tools (27.4.1~20.04.1) wird eingerichtet ...
Trigger für man-db (2.9.1-1) werden verarbeitet ...
root:/usr/src#

Revision history for this message
Lucas Albuquerque Medeiros de Moura (lamoura) wrote :

Hi Steve and Oli, we have landed the fix on main we will soon release it.
Thanks for reporting this issue and providing the additional context for it

Changed in ubuntu-advantage-tools (Ubuntu):
status: In Progress → Fix Committed
description: updated
summary: - traceback from postinst on upgrade
+ ubuntu-advantage-tools (27.4.1 -> 27.4.2) Xenial, Bionic, Focal,
+ Hirsute, Impish
Revision history for this message
Launchpad Janitor (janitor) wrote : Re: ubuntu-advantage-tools (27.4.1 -> 27.4.2) Xenial, Bionic, Focal, Hirsute, Impish

This bug was fixed in the package ubuntu-advantage-tools - 27.4.2~22.04.1

---------------
ubuntu-advantage-tools (27.4.2~22.04.1) jammy; urgency=medium

  * d/tools.postinst:
    - Fix check_service_is_enabled function when the machine is
      unattached (LP: #1951705)

 -- Lucas Moura <email address hidden> Tue, 23 Nov 2021 09:20:56 -0300

Changed in ubuntu-advantage-tools (Ubuntu):
status: Fix Committed → Fix Released
Robie Basak (racb)
description: updated
description: updated
summary: - ubuntu-advantage-tools (27.4.1 -> 27.4.2) Xenial, Bionic, Focal,
- Hirsute, Impish
+ traceback from postinst on upgrade
Revision history for this message
Robie Basak (racb) wrote : Please test proposed package

Hello Steve, or anyone else affected,

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

Hello Steve, 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.4.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 Focal):
status: New → Fix Committed
tags: added: verification-needed-focal
Revision history for this message
Robie Basak (racb) wrote :

Hello Steve, 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.4.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: New → Fix Committed
tags: added: verification-needed-bionic
Revision history for this message
Robie Basak (racb) wrote :

Hello Steve, 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.4.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: New → Fix Committed
tags: added: verification-needed-xenial
Revision history for this message
Robie Basak (racb) wrote :

Hello Steve, 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.4.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
Lucas Albuquerque Medeiros de Moura (lamoura) wrote :

Here is the results of our tests for this issue on release 27.4.2
Note that this issue should only affect LTS releases, which can be verified on the hirsute and impish tests.

we have also appended the test script we have used to generate those results

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

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

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

  * Backport new upstream release: (LP: #1951705) to impish

ubuntu-advantage-tools (27.4.2~22.04.1) jammy; urgency=medium

  * d/tools.postinst:
    - Fix check_service_is_enabled function when the machine is
      unattached (LP: #1951705)

 -- Lucas Moura <email address hidden> Tue, 23 Nov 2021 16:19:26 -0300

Changed in ubuntu-advantage-tools (Ubuntu Impish):
status: Fix Committed → Fix Released
Revision history for this message
Łukasz Zemczak (sil2100) 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.4.2~21.04.1

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

  * Backport new upstream release: (LP: #1951705) to hirsute

ubuntu-advantage-tools (27.4.2~22.04.1) jammy; urgency=medium

  * d/tools.postinst:
    - Fix check_service_is_enabled function when the machine is
      unattached (LP: #1951705)

 -- Lucas Moura <email address hidden> Tue, 23 Nov 2021 16:19:17 -0300

Changed in ubuntu-advantage-tools (Ubuntu Hirsute):
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.4.2~20.04.1

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

  * Backport new upstream release: (LP: #1951705) to focal

ubuntu-advantage-tools (27.4.2~22.04.1) jammy; urgency=medium

  * d/tools.postinst:
    - Fix check_service_is_enabled function when the machine is
      unattached (LP: #1951705)

 -- Lucas Moura <email address hidden> Tue, 23 Nov 2021 16:19:09 -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.4.2~18.04.1

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

  * Backport new upstream release: (LP: #1951705) to bionic

ubuntu-advantage-tools (27.4.2~22.04.1) jammy; urgency=medium

  * d/tools.postinst:
    - Fix check_service_is_enabled function when the machine is
      unattached (LP: #1951705)

 -- Lucas Moura <email address hidden> Tue, 23 Nov 2021 16:19:00 -0300

Changed in ubuntu-advantage-tools (Ubuntu Bionic):
status: Fix Committed → Fix Released
Revision history for this message
Łukasz Zemczak (sil2100) wrote :

I assume this also was meant to go to xenial-updates, even though xenial is in ESM mode now.

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

This bug was fixed in the package ubuntu-advantage-tools - 27.4.2~16.04.1

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

  * Backport new upstream release: (LP: #1951705) to xenial

ubuntu-advantage-tools (27.4.2~22.04.1) jammy; urgency=medium

  * d/tools.postinst:
    - Fix check_service_is_enabled function when the machine is
      unattached (LP: #1951705)

 -- Lucas Moura <email address hidden> Tue, 23 Nov 2021 16:18:47 -0300

Changed in ubuntu-advantage-tools (Ubuntu Xenial):
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.