Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

postinst: fix service check for unattached machine #1891

Merged

Conversation

lucasmoura
Copy link
Contributor

Proposed Commit Message

postinst: fix service check for unattached machine

When running in a LTS machine with an architecture that is different from i386 and amd64 we will try to unconfigure esm services on these non-supported architectures. Before we unconfigure those services, we check to see if they are enabled. However, the code that performs that check is looking for a key in the status cache that is only present when machine is attached to a subscription. We are now updating the code to not fail if the machine is unattached.

LP: #1951705
Fixes: #1888

Test Steps

To reproduce that error:

  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. Apply this change into the postint
  8. Run the command again and verify that no errors are shown

Desired commit type

  • Squash and merge: Using the "Proposed Commit Message"
  • Create a merge commit and use "Proposed Commit Message"
  • Rebase and merge, no merge commit, rely only on existing commit messages

Checklist

  • I have updated or added any unit tests accordingly
  • I have updated or added any integration tests accordingly
  • I have updated or added any documentation accordingly

When running in a LTS machine with an architecture that is different from
i386 and amd64 we will try to unconfigure esm services on these
non-supported architectures. Before we unconfigure those services, we
check to see if they are enabled. However, the code that performs that
check is looking for a key in the status cache that is only present
when machine is attached to a subscription. We are now updating the
code to not fail if the machine is unattached.

LP: #1951705
Fixes: canonical#1888
@lucasmoura lucasmoura force-pushed the fix-postinst-check-service-is-enabled branch from 9f24633 to 70d306e Compare November 22, 2021 19:57
@lucasmoura
Copy link
Contributor Author

@renanrodrigo code updated

Copy link
Collaborator

@orndorffgrant orndorffgrant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks for the quick fix!

@OliverDrechsler
Copy link

Hi,
as I commented in bug ticked at lanchpad this fix solved my problem
0 21:53:19 root:~# dpkg -i /var/cache/apt/archives/ubuntu-advantage-tools_27.4.1~20.04.1_arm64.deb (Lese Datenbank ... 162018 Dateien und Verzeichnisse sind derzeit installiert.) Vorbereitung zum Entpacken von .../ubuntu-advantage-tools_27.4.1~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 ... 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' Trigger für man-db (2.9.1-1) werden verarbeitet ... 0 21:54:15 root:~#

So, please merge it.

@lucasmoura
Copy link
Contributor Author

Thanks for confirming this @OliverDrechsler
I merge this right now and we hope to have that fix release pretty soon

@lucasmoura lucasmoura merged commit 0181dc3 into canonical:main Nov 23, 2021
@Conrad-T-Pino
Copy link

Conrad-T-Pino commented Nov 23, 2021

What is reasonable time to expect this fix to arrive in following repository set?

http://us.ports.ubuntu.com/ubuntu-ports/
http://ports.ubuntu.com/ubuntu-ports/

Best regards,
Conrad T. Pino

@lucasmoura
Copy link
Contributor Author

@Conrad-T-Pino We have already started the release process for this fix.
Hopefully, it will be available in the beginning of next week.

@Conrad-T-Pino
Copy link

@lucasmoura Thank you for the prompt reply.
I really appreciate the issue handling done here.

@lucasmoura
Copy link
Contributor Author

@Conrad-T-Pino just to let you know, we already have the package with the fix in the proposed pocket of jammy, in case you want to test it out.

However, I saw in the bug that you were using the focal, so I will let you know when the package hits the proposed pocket for the other releases as well.

@Conrad-T-Pino
Copy link

@lucasmoura A general time frame is good enough.
Issue has no effect on the single EC2 instance updated.
I'm holding off other updates in AWS until fix shows up.

@Conrad-T-Pino
Copy link

This fix remains unavailable from:

deb http://us.ports.ubuntu.com/ubuntu-ports/ focal main restricted
deb http://us.ports.ubuntu.com/ubuntu-ports/ focal-updates main restricted
deb http://us.ports.ubuntu.com/ubuntu-ports/ focal universe
deb http://us.ports.ubuntu.com/ubuntu-ports/ focal-updates universe
deb http://us.ports.ubuntu.com/ubuntu-ports/ focal multiverse
deb http://us.ports.ubuntu.com/ubuntu-ports/ focal-updates multiverse
deb http://us.ports.ubuntu.com/ubuntu-ports/ focal-backports main restricted universe multiverse
deb http://ports.ubuntu.com/ubuntu-ports focal-security main restricted
deb http://ports.ubuntu.com/ubuntu-ports focal-security universe
deb http://ports.ubuntu.com/ubuntu-ports focal-security multiverse

Best regards,
Conrad T. Pino

@lucasmoura
Copy link
Contributor Author

Hi @Conrad-T-Pino, the package is already sitting in the proposed pocket of all of the older releases. The reason why it is not fully released yet is that whenever we release a package to an older version of Ubuntu, we let it sit on the proposed pocket for a week before releasing it.

We have uploaded the package last Friday, so it should be released today, but we avoid having package releases on older versions on Friday. Therefore, I strongly believe the package will be ready on Monday.

However, if you want to test the version in proposed, just follow this guide to enable that pocket:
https://wiki.ubuntu.com/Testing/EnableProposed

Just be aware that more package could be sitting on that pocket besides ubuntu-advantage-client. Therefore, I suggest only upgrading that package directly.

And I should have explained that process to you earlier, sorry for that.

@Conrad-T-Pino
Copy link

Hi @lucasmoura, thank you for the prompt unexpected response.

My only concern is error free update to AWS EC2 arm64 instances so no explanations to my team are necessary.
Since we're not Ubuntu Advantage participant whether the package works or not does not matter.
Testing the fix from another repository source does not matter.
Expect periodic updates until fix is fully deployed.
I plan to confirm when fix appears as I expect.
BTW, I expect no response to status updates.

@lucasmoura
Copy link
Contributor Author

@Conrad-T-Pino the release with the fix is officially out.
Let me know if it is working for you

@Conrad-T-Pino
Copy link

Error free update and upgrade at Mon 06 Dec 2021 11:23:52 AM PST:

user@host:~$ sudo apt-get update
Get:1 http://ports.ubuntu.com/ubuntu-ports focal-security InRelease [114 kB]
Hit:2 http://us.ports.ubuntu.com/ubuntu-ports focal InRelease
Get:3 http://us.ports.ubuntu.com/ubuntu-ports focal-updates InRelease [114 kB]
Get:4 http://us.ports.ubuntu.com/ubuntu-ports focal-backports InRelease [108 kB]
Get:5 http://us.ports.ubuntu.com/ubuntu-ports focal-updates/main arm64 Packages [988 kB]
Get:6 http://ports.ubuntu.com/ubuntu-ports focal-security/main arm64 Packages [698 kB]
Get:7 http://us.ports.ubuntu.com/ubuntu-ports focal-updates/main Translation-en [281 kB]
Get:8 http://us.ports.ubuntu.com/ubuntu-ports focal-updates/main arm64 c-n-f Metadata [14.2 kB]
Get:9 http://us.ports.ubuntu.com/ubuntu-ports focal-updates/universe arm64 Packages [827 kB]
Get:10 http://us.ports.ubuntu.com/ubuntu-ports focal-updates/universe arm64 c-n-f Metadata [17.9 kB]
Get:11 http://ports.ubuntu.com/ubuntu-ports focal-security/main arm64 c-n-f Metadata [8,732 B]
Get:12 http://ports.ubuntu.com/ubuntu-ports focal-security/universe arm64 Packages [613 kB]
Get:13 http://ports.ubuntu.com/ubuntu-ports focal-security/universe arm64 c-n-f Metadata [11.0 kB]
Fetched 3,795 kB in 2s (1,725 kB/s)
Reading package lists... Done
user@host:~$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages will be upgraded:
ubuntu-advantage-tools
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 781 kB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 http://us.ports.ubuntu.com/ubuntu-ports focal-updates/main arm64 ubuntu-advantage-tools arm64 27.4.2~20.04.1 [781 kB]
Fetched 781 kB in 1s (1,254 kB/s)
Preconfiguring packages ...
(Reading database ... 109204 files and directories currently installed.)
Preparing to unpack .../ubuntu-advantage-tools_27.4.2~20.04.1_arm64.deb ...
Unpacking ubuntu-advantage-tools (27.4.2~20.04.1) over (27.4.1~20.04.1) ...
Setting up ubuntu-advantage-tools (27.4.2~20.04.1) ...
Processing triggers for man-db (2.9.1-1) ...
Many thanks!
Conrad T. Pino

@Conrad-T-Pino
Copy link

@lucasmoura your care and interest over and above the necessary is seen and appreciated. Be safe and well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AWS t4g.nano apt-get update ubuntu-advantage-tools failures
5 participants