** Description changed:

+ [ 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
+ ([email protected]) 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)
+   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 ""
-                                                          ^^^
+   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)
+   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
+  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>
+  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
+  INFO:root:/usr/bin/do-release-upgrade running
+  INFO:root:No xorg.conf, exiting

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2107604

Title:
  Python error when upgrading to 25.04 - lsof command missing in minimal

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/ubuntu-advantage-tools/+bug/2107604/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to