[Bug 2107604] Re: Python error when upgrading to 25.04 - lsof command missing in minimal
Timo Aaltonen
2107604 at bugs.launchpad.net
Fri Oct 3 13:21:30 UTC 2025
Hello cocomac, 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/37ubuntu0~16.04 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.
** Changed in: ubuntu-advantage-tools (Ubuntu Xenial)
Status: New => Fix Committed
** Tags added: verification-needed-xenial
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to ubuntu-release-upgrader in
Ubuntu.
https://bugs.launchpad.net/bugs/2107604
Title:
Python error when upgrading to 25.04 - lsof command missing in minimal
Status in ubuntu-advantage-tools package in Ubuntu:
Fix Released
Status in ubuntu-release-upgrader package in Ubuntu:
Invalid
Status in ubuntu-advantage-tools source package in Xenial:
Fix Committed
Status in ubuntu-advantage-tools source package in Bionic:
Fix Committed
Status in ubuntu-advantage-tools source package in Focal:
Fix Committed
Status in ubuntu-advantage-tools source package in Jammy:
Fix Committed
Status in ubuntu-advantage-tools source package in Noble:
Fix Committed
Status in ubuntu-advantage-tools source package in Plucky:
Fix Committed
Bug description:
[ Impact ]
Users running minimal server installation will see errors on do-
release upgrade, because ubuntu-pro-client has a post-execution hook
to update services which uses the `lsof` command to check for APT
locks.
There are two problems there: first, checking if the lock is open is a
good indicator but not a guarantee the lock is held/released. Second,
the client does not depend on `lsof` and this package is not seeded in
server-minimal.
The solution here is: stop depending on `lsof`, removing the implicit
dependency and improving the logic to hold apt locks.
[ Test plan ]
There are acceptance tests for the Pro Client covering do-release-upgrade, which are part of the verification of LP #2125453.
Manual verification of server-minimal upgrades will be executed as part of the specifics on removing `lsof`:
- launch a <release> VM using a minimal server installation
- attach a pro subscription
- try to upgrade and check for the `lsof` error
- launch another VM using the same installation
- attach a pro subscription
- install the package from proposed
- verify that do-release-upgrade runs smoothly
[ Where problems could occur ]
This is changing the logic used to wait for the APT lock after a do-
release-upgrade. Mistakes in the implementation here would lead either
to errors in the post-execution hook, not updating the services as
expected, or never executing anything at all if we don't recognize the
lock as released. To avoid these situations, we have passing
integration tests with updates from all supported releases, and we had
Julian Klode (julian.klode at canonical.com) review it as the APT expert.
[ Original Description ]
Hello everyone - I got an error from Python when upgrading a VM from
24.10 to 25.04 (Ubuntu Server, AMD64). This was a minimized install
(using the option selected when installing the system). I had also
uninstalled Snap using https://askubuntu.com/a/1035917/ I was able to
reproduce this with two different VMs (same version of Ubuntu on
both).
The upgrade appeared to work, so I'm not sure if this is a major
issue, but it seemed worth reporting.
Here is the error:
```none
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/uaclient/system.py", line 701, in _subp
proc = subprocess.Popen( # nosec B603
bytes_args,
...<2 lines>...
env=merged_env,
)
File "/usr/lib/python3.13/subprocess.py", line 1039, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pass_fds, cwd, env,
^^^^^^^^^^^^^^^^^^^
...<5 lines>...
gid, gids, uid, umask,
^^^^^^^^^^^^^^^^^^^^^^
start_new_session, process_group)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.13/subprocess.py", line 1969, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: b'lsof'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/uaclient/system.py", line 710, in _subp
out_result = out.decode("utf-8", errors="ignore") if out else ""
^^^
UnboundLocalError: cannot access local variable 'out' where it is not associated with a value
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/ubuntu-advantage/upgrade_lts_contract.py", line 17, in <module>
upgrade_lts_contract.process_contract_delta_after_apt_lock(cfg)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
File "/usr/lib/python3/dist-packages/uaclient/upgrade_lts_contract.py", line 58, in process_contract_delta_after_apt_lock
out, _err = system.subp(["lsof", "/var/lib/apt/lists/lock"], rcs=[0, 1])
~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/uaclient/system.py", line 775, in subp
out, err = _subp(
~~~~~^
args,
^^^^^
...<4 lines>...
pipe_stdouterr=pipe_stdouterr,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/usr/lib/python3/dist-packages/uaclient/system.py", line 719, in _subp
raise exceptions.ProcessExecutionError(cmd=redacted_cmd)
uaclient.exceptions.ProcessExecutionError: Invalid command specified 'lsof /var/lib/apt/lists/lock'.
```
Running apt-cache policy ubuntu-release-upgrader simply produced 'N:
Unable to locate package do-release-upgrade'. If it helps, lsof was
not installed on the system.
I was expecting it to upgrade without an error. Instead, it produced
an error. Despite said error, it did appear to successfully upgrade,
and the log noted 'System upgrade is complete.' I also attached part
of the upgrade log in case it's useful (from do-release-upgrade, I
saved it using tmux).
Thanks,
cocomac
ProblemType: Bug
DistroRelease: Ubuntu 25.04
Package: ubuntu-release-upgrader-core 1:25.04.14
ProcVersionSignature: Ubuntu 6.11.0-24.24-generic 6.11.11
Uname: Linux 6.11.0-24-generic x86_64
ApportVersion: 2.32.0-0ubuntu5
Architecture: amd64
CasperMD5CheckResult: pass
CrashDB: ubuntu
CrashReports:
644:0:0:0:2025-04-17 21:57:33.181000000 +0000:2024-12-10 23:39:46.349000000 +0000:/var/crash/kdump_lock
640:0:0:25638:2025-04-17 23:31:51.230280620 +0000:2025-04-17 23:31:51.230280620 +0000:/var/crash/_usr_lib_ubuntu-advantage_upgrade_lts_contract.py.0.crash
Date: Fri Apr 18 00:11:55 2025
InstallationDate: Installed on 2024-12-10 (128 days ago)
InstallationMedia: Ubuntu-Server 24.10 "Oracular Oriole" - Release amd64 (20241007.1)
PackageArchitecture: all
ProcEnviron:
LANG=C.UTF-8
PATH=(custom, no user)
SHELL=/bin/bash
TERM=tmux-256color
XDG_RUNTIME_DIR=<set>
RebootRequiredPkgs: Error: path contained symlinks.
SourcePackage: ubuntu-release-upgrader
Symptom: ubuntu-release-upgrader
UpgradeStatus: Upgraded to plucky on 2025-04-17 (0 days ago)
VarLogDistupgradeXorgFixuplog:
INFO:root:/usr/bin/do-release-upgrade running
INFO:root:No xorg.conf, exiting
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/ubuntu-advantage-tools/+bug/2107604/+subscriptions
More information about the foundations-bugs
mailing list