ubuntu-advantage-tools fails setup

Asked by richard

We recently encountered an issue with our deployment pipeline when installing Ubuntu 18.04.

"ubuntu-minimal" now depends on ubuntu-advantage-tools, but that package fails install with:
ModuleNotFoundError: No module named 'uaclient'

I added OS packages 'python-opcua' and 'python3-opcua' and the error changed to:
No module named 'uaclient.entitlements'

I'm wondering why the dependencies can't be resolved at install time through APT per usual. The setup consistently exits with a '1', which fails our build pipeline. Hopefully that's not the default behavior. More info in the comment below.

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu ubuntu-advantage-tools Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
richard (meusburger) said :
#1

On a newly installed system I can duplicate the error by reinstalling the package. Dpkg consistently returns exit code '1':

apt-get --reinstall install ubuntu-advantage-tools
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
  libiw30
Use 'apt autoremove' to remove it.
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
Need to get 0 B/622 kB of archives.
After this operation, 0 B of additional disk space will be used.
Preconfiguring packages ...
(Reading database ... 95689 files and directories currently installed.)
Preparing to unpack .../ubuntu-advantage-tools_27.0.2~18.04.1_amd64.deb ...
Unpacking ubuntu-advantage-tools (27.0.2~18.04.1) over (27.0.2~18.04.1) ...
Setting up ubuntu-advantage-tools (27.0.2~18.04.1) ...
Traceback (most recent call last):
  File "<string>", line 2, in <module>
ModuleNotFoundError: No module named 'uaclient.entitlements'
dpkg: error processing package ubuntu-advantage-tools (--configure):
 installed ubuntu-advantage-tools package post-installation script subprocess returned error exit status 1
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Errors were encountered while processing:
 ubuntu-advantage-tools
E: Sub-process /usr/bin/dpkg returned an error code (1)

Revision history for this message
Manfred Hampl (m-hampl) said :
#2

For diagnostic purposes, what is the output of the following commands:

uname -a
lsb_release -crid
apt-cache policy ubuntu-advantage-tools
python3 -c "from uaclient.entitlements import ENTITLEMENT_CLASS_BY_NAME"

I was not able to duplicate the error on my test systems.
Can you describe the exact steps necessary to show that error (e.g. which installer do you use)?

Revision history for this message
richard (meusburger) said :
#3

Here is the output from an Azure server built from Marketplace image:

tools@cis-ubu18:~$ uname -a
Linux cis-ubu18 5.4.0-1047-azure #49~18.04.1-Ubuntu SMP Thu Apr 22 21:28:54 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

tools@cis-ubu18:~$ lsb_release -crid
Distributor ID: Ubuntu
Description: Ubuntu 18.04.5 LTS
Release: 18.04
Codename: bionic

tools@cis-ubu18:~$ apt-cache policy ubuntu-advantage-tools
ubuntu-advantage-tools:
  Installed: 27.0.2~18.04.1
  Candidate: 27.0.2~18.04.1
  Version table:
 *** 27.0.2~18.04.1 500
        500 http://azure.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages
        100 /var/lib/dpkg/status
     17 500
        500 http://azure.archive.ubuntu.com/ubuntu bionic/main amd64 Packages

tools@cis-ubu18:~$ python3 -c "from uaclient.entitlements import ENTITLEMENT_CLASS_BY_NAME"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'uaclient.entitlements'

I have similar results from a server built from the 18.04.4 ISO:

tools@cis-601:~$ uname -a
Linux cis-601 4.15.0-143-generic #147-Ubuntu SMP Wed Apr 14 16:10:11 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

tools@cis-601:~$ lsb_release -crid
Distributor ID: Ubuntu
Description: Ubuntu 18.04.5 LTS
Release: 18.04
Codename: bionic

tools@cis-601:~$ apt-cache policy ubuntu-advantage-tools
ubuntu-advantage-tools:
  Installed: 17
  Candidate: 27.0.2~18.04.1
  Version table:
     27.0.2~18.04.1 500
        500 http://us.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages
 *** 17 500
        500 http://us.archive.ubuntu.com/ubuntu bionic/main amd64 Packages
        500 http://us.archive.ubuntu.com/ubuntu bionic/main i386 Packages
        100 /var/lib/dpkg/status

tools@cis-601:~$ python3 -c "from uaclient.entitlements import ENTITLEMENT_CLASS_BY_NAME"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'uaclient

Revision history for this message
richard (meusburger) said :
#4

To clarify these are server not desktop images.

My final workaround was to:
a) pre-install 'python3-distutils' and 'python3-opcua'
b) force install ubuntu-advantage-tools (ignore the exit '1' error)
c) place ubuntu-advantage-tools on HOLD with apt-get mark

Then we were able to update all packages.

The ask here would be that if ubuntu-advantage-tools depends on the two python packages above that they be included in the dependency list, and that the setup exit with '0' on initial install.

Revision history for this message
richard (meusburger) said :
#5

Correction - that's 'apt-mark hold' not 'apt-get mark'. I have never had to place a package on hold previously.

Revision history for this message
Manfred Hampl (m-hampl) said :
#6

The strange thing is that the uaclient python packages are contained in the ubuntu-advantage-tools version 27.0.2~18.04.1 package. So I do not understand why the postinst script does not find them.

You write that you have found a workaround.

If you still want to tackle that problem further, then please provide the output of the following commands after a failed upgrade attempt:
ls -l /usr/lib/python3/dist-packages/uaclient/
ls -l /usr/lib/python3/dist-packages/uaclient/entitlements/

Revision history for this message
richard (meusburger) said :
#7

This is what I am seeing:

root@ubc60022:~#
root@ubc60022:~# dpkg --list | grep advantage
hi ubuntu-advantage-tools 17 all management tools for Ubuntu Advantage
root@ubc60022:~#
root@ubc60022:~# ls -l /usr/lib/python3/dist-packages/uaclient/
ls: cannot access '/usr/lib/python3/dist-packages/uaclient/': No such file or directory
root@ubc60022:~#
root@ubc60022:~# ls -l /usr/lib/python3/dist-packages/uaclient/entitlements/
ls: cannot access '/usr/lib/python3/dist-packages/uaclient/entitlements/': No such file or directory

Revision history for this message
richard (meusburger) said :
#8

This is what I am seeing:

root@ubc60022:~#
root@ubc60022:~# dpkg --list | grep advantage
hi ubuntu-advantage-tools 17 all management tools for Ubuntu Advantage
root@ubc60022:~#
root@ubc60022:~# ls -l /usr/lib/python3/dist-packages/uaclient/
ls: cannot access '/usr/lib/python3/dist-packages/uaclient/': No such file or directory
root@ubc60022:~#
root@ubc60022:~# ls -l /usr/lib/python3/dist-packages/uaclient/entitlements/
ls: cannot access '/usr/lib/python3/dist-packages/uaclient/entitlements/': No such file or directory

Revision history for this message
richard (meusburger) said :
#9

We are using a preseed file to configure our base server image. I've trimmed a few filesystems out and obfuscated a few items.

# Set locale and keyboard layout.
d-i keyboard-configuration/xkb-keymap select us
d-i console-setup/ask_detect boolean false
d-i debian-installer/locale string en_US

# Install the Ubuntu Server seed.
tasksel tasksel/force-tasks string server

# Skip making a regular user as we're going to join VMs cloned from this
# template to a domain. A root password must be set to continue this part of
# the installation, so it's set to something silly that will be removed later.
#d-i passwd/make-user boolean false
#d-i passwd/root-login boolean true
#d-i user-setup/allow-password-weak boolean true
#
#account gets removed by post-install:
d-i passwd/user-fullname string installer
d-i passwd/username string installer
d-i passwd/user-password password s3cr3t
d-i passwd/user-password-again password s3cr3t

# Set the time zone to Pacific Time.
d-i time/zone string US/Los_Angeles

# Use sda whole disk with single boot part and remainder LVM
d-i partman-auto/disk string /dev/sda
d-i partman-auto/method string lvm
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-md/device_remove_md boolean true
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true

# limit LVM to 48G - prevents 'growing' /home
d-i partman-auto-lvm/guided_size string 48GB

d-i partman-auto-lvm/new_vg_name string rootvg
d-i partman-auto/expert_recipe string \
              512 512 512 ext3 \
                      $primary{ } \
                      $bootable{ } \
                      mountpoint{ /boot } \
                      method{ format } \
                      format{ } \
                      use_filesystem{ } \
                      filesystem{ ext3 } \
              . \
              100 1000 1000000000 ext3 \
                        $defaultignore{ } \
                        $primary{ } \
                        method{ lvm } \
                        device{ /dev/sda } \
                        vg_name{ rootvg } \
              . \
              512 4096 50% linux-swap \
                      $lvmok{ } \
                      lv_name{ lv_swap } \
                      in_vg{ rootvg } \
                      method{ swap } \
                      format{ } \
              . \
              8192 8192 8192 xfs \
                      $lvmok{ } \
                      mountpoint{ / } \
                      lv_name{ lv_root } \
                      in_vg{ rootvg } \
                      method{ format } \
                      format{ } \
                      use_filesystem{ } \
                      filesystem{ xfs } \
              . \
              2048 2048 2048 xfs \
                      $lvmok{ } \
                      mountpoint{ /tmp } \
                      lv_name{ lv_tmp } \
                      in_vg{ rootvg } \
                      method{ format } \
                      format{ } \
                      options/nodev{ nodev } \
                      options/nosuid{ nosuid } \
                      use_filesystem{ } \
                      filesystem{ xfs } \
              . \
              4096 4096 4096 xfs \
                      $lvmok{ } \
                      mountpoint{ /var } \
                      lv_name{ lv_var } \
                      in_vg{ rootvg } \
                      method{ format } \
                      format{ } \
                      use_filesystem{ } \
                      filesystem{ xfs } \
              . \
              2048 2048 2048 xfs \
                      $lvmok{ } \
                      mountpoint{ /home } \
                      lv_name{ lv_home } \
                      in_vg{ rootvg } \
                      method{ format } \
                      format{ } \
                      options/nodev{ nodev } \
                      use_filesystem{ } \
                      filesystem{ xfs } \
              .
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true

# Only install basic language packs. Let tasksel ask about tasks.
#d-i pkgsel/language-pack-patterns string
d-i pkgsel/language-packs multiselect en

# No language support packages.
d-i pkgsel/install-language-support boolean false

### Package selection
tasksel tasksel/first multiselect ubuntu-server

# Install some extra packages.
d-i pkgsel/include string openssh-server open-vm-tools net-tools ifupdown resolvconf iptables ufw auditd libpam-pwquality chrony aide aide-common apparmor man sssd samba-common-bin man wget ruby-shadow parted tcpd cloud-init curl
d-i pkgsel/exclude string telnet ftp

# Disable automatic updates. We don't want Ubuntu potentially mysteriously
# breaking things by default.
d-i pkgsel/update-policy select none

# Set the hardware clock to localtime. VMware is currently configured to use
# localtime, so this setting is necessary to ensure that the clock is set to
# the correct time.
d-i clock-setup/utc boolean false

# Verbose output and no boot splash screen.
d-i debian-installer/quiet boolean false
d-i debian-installer/splash boolean false

# Install the debconf oem-config frontend (if in OEM mode).
#d-i oem-config-udeb/frontend string debconf

# Install GRUB to the MBR.
d-i grub-installer/only_debian boolean true

# Add the network and tasks oem-config steps by default.
#oem-config oem-config/steps multiselect language, timezone, keyboard, user, network, tasks

# tell the installer to fire up the network console (for Packer) while the install runs
# we don't want to use the menu-driven network-console, so we set the "installer" to use ssh instead
d-i network-console/start select continue
d-i debconf/priority select critical
d-i auto-install/enabled boolean true
d-i network-console/password password s3cr3t
d-i network-console/password-again password s3cr3t
d-i preseed/early_command string \
  anna-install network-console openssh-client-udeb && \
  sed -i 's/network-console/sh/' /etc/passwd

#d-i preseed/late_command string \
d-i preseed/late_command string echo "installer ALL=(ALL) NOPASSWD: ALL" >> /target/etc/sudoers.d/55-installer; chmod 0600 /target/etc/sudoers.d/55-installer

# Halt the machine after the install. Packer will power off the machine after
# it's done provisioning it with Chef.
#d-i debian-installer/exit/poweroff boolean true
d-i finish-install/reboot_in_progress note

Revision history for this message
Manfred Hampl (m-hampl) said :
#10

"ls: cannot access '/usr/lib/python3/dist-packages/uaclient/': No such file or directory"

That is a consequence of apt-mark hold to version 17.
/usr/lib/python3/dist-packages/uaclient/ is provided only by version 27.0.2~18.04.1

You have to be aware that the package management system most probably has been left in an inconsistent state:
see the output of

sudo dpkg --audit

Revision history for this message
richard (meusburger) said :
#11

The package is placed on HOLD as it exits with a non-zero status, which breaks our CI/CD pipeline.

Since I'm doing a fresh install, I'm not sure why version 27.0.2~18.04.1 is not available?

I can try staging the 27.0.2~18.04.1 DEB package somewhere that our pipeline can access it, and try to pre-install it before doing the apt-get update and upgrade. This seems like an issue with the server package repositories if I'm not getting the latest package by default.

Revision history for this message
richard (meusburger) said :
#12

It appears that ubuntu-advantage-tools v27.0.2~18.04.1 was back-ported to Bionic on 5/12/21.

It is now in the 18.04 repositories. Reverting my changes for the above and validating that fixes our pipeline issue.

Revision history for this message
richard (meusburger) said :
#13

Within my pipeline I am getting version 27.0.2~18.04.1, but am its setup is still exiting with a '1' as shown below.

Preparing to unpack .../21-ubuntu-advantage-tools_27.0.2~18.04.1_amd64.deb

dpkg: error processing package ubuntu-advantage-tools (--configure):", " installed ubuntu-advantage-tools package post-installation script subprocess returned error exit status 1

"dpkg: error processing package ubuntu-minimal (--configure):", " dependency problems - leaving unconfigured"

Still trying to work around.

Revision history for this message
richard (meusburger) said :
#14

Within my pipeline I am getting version 27.0.2~18.04.1, but am its setup is still exiting with a '1' as shown below.

Preparing to unpack .../21-ubuntu-advantage-tools_27.0.2~18.04.1_amd64.deb

dpkg: error processing package ubuntu-advantage-tools (--configure):", " installed ubuntu-advantage-tools package post-installation script subprocess returned error exit status 1

"dpkg: error processing package ubuntu-minimal (--configure):", " dependency problems - leaving unconfigured"

Still trying to work around.

Revision history for this message
Manfred Hampl (m-hampl) said :
#15

There is Bug #1927905 describing a similar problem for Ubuntu 16.04
and there is already a new version in development, see Bug #1929597

Revision history for this message
Kai Z. (kaiyutony) said :
#16

I am facing a similar problem. When I do `sudo apt upgrade`, I get "ModuleNotFoundError: No module named 'uaclient'". This happens every time I run an apt command (including installing). It was all fine yesterday, until I did an Ubuntu base upgrade today. My language input selection icon that's always on the top bar was also gone.

...
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up ubuntu-advantage-tools (27.0.2~18.04.1) ...
Traceback (most recent call last):
  File "<string>", line 2, in <module>
ModuleNotFoundError: No module named 'uaclient'
dpkg: error processing package ubuntu-advantage-tools (--configure):
 installed ubuntu-advantage-tools package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 ubuntu-advantage-tools
E: Sub-process /usr/bin/dpkg returned an error code (1)

What to do about this?

Revision history for this message
Manfred Hampl (m-hampl) said :
#17

@Kai Z.:
Please do not piggyback on somebody else's question, but create a question document of your own.
Your case is different.

The error message received by richard is "No module named 'uaclient.entitlements'"
and yours is "No module named 'uaclient'"

Revision history for this message
Kai Z. (kaiyutony) said (last edit ):
#18

Apologies. I am now getting "No module named 'uaclient.entitlements'" after I ran 'pip3 install opcua-client', which seems to have fixed "No module named 'uaclient'"

I'll not continue my end of the thread here.

Revision history for this message
Eduardo de Miguel (shide) said :
#19

You should install `opcua` and `opcua-client` with default python command:

    python -m pip install --upgrade opcua

    python -m pip install --upgrade opcua-client

Revision history for this message
ljgww (lj011-mt) said (last edit ):
#20

(on Ubuntu 18.04.5 LTS)

Having failed updates for a while

Believe this shall rather be (python 3 ?)

    python3 -m pip install --upgrade opcua
    python3 -m pip install --upgrade opcua-client

even after this, which passes well, updates fail

$ sudo apt-get upgrade

Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n]
Setting up ubuntu-advantage-tools (27.0.2~18.04.1) ...
Traceback (most recent call last):
  File "<string>", line 2, in <module>
ModuleNotFoundError: No module named 'uaclient.entitlements'
dpkg: error processing package ubuntu-advantage-tools (--configure):
 installed ubuntu-advantage-tools package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 ubuntu-advantage-tools
E: Sub-process /usr/bin/dpkg returned an error code (1)

what is interesting is this:

$ sudo apt-get --reinstall install ubuntu-advantage-tools

Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
E: Internal Error, No file name for ubuntu-advantage-tools:amd64

--
lj

Can you help with this problem?

Provide an answer of your own, or ask richard for more information if necessary.

To post a message you must log in.