** Description changed:

  [Impact]
  
  There are various setups where snap will not behave as expected, such as
  in WSL or chroot environments. There are currently quirks in ubuntu-
  release-upgrader that are not resilient to general snap failures.
  
  Such errors currently are fatal to the upgrade, but they should not be.
  
  [Test Plan]
  
  Test #1
  
- In an Ubuntu container, simulate snap errors by doing:
+ In an Ubuntu container, simulate snap errors by "removing" snap:
  
- $ ln -s /usr/bin/false /usr/local/bin/snap
- $ which snap
- /usr/local/bin/snap
+ $ mv /usr/bin/snap /usr/bin/.snap
  
  Then, attempt an upgrade. Without a patch, the upgrade will fail early:
  
  $ do-release-upgrade
  
  [...]
  
- Building dependency tree... Done
+ Reading package lists... Done    
+ Building dependency tree... Done 
  Reading state information... Done
  
  Traceback (most recent call last):
-   File "/tmp/ubuntu-release-upgrader-0xsphvrt/noble", line 8, in <module>
-     sys.exit(main())
-   File 
"/tmp/ubuntu-release-upgrader-0xsphvrt/DistUpgrade/DistUpgradeMain.py", line 
241, in main
-     if app.run():
-   File 
"/tmp/ubuntu-release-upgrader-0xsphvrt/DistUpgrade/DistUpgradeController.py", 
line 2662, in run
-     return self.fullUpgrade()
-   File 
"/tmp/ubuntu-release-upgrader-0xsphvrt/DistUpgrade/DistUpgradeController.py", 
line 2467, in fullUpgrade
-     if not self.doPostInitialUpdate():
-   File 
"/tmp/ubuntu-release-upgrader-0xsphvrt/DistUpgrade/DistUpgradeController.py", 
line 1438, in doPostInitialUpdate
-     self.quirks.run("PostInitialUpdate")
-   File 
"/tmp/ubuntu-release-upgrader-0xsphvrt/DistUpgrade/DistUpgradeQuirks.py", line 
102, in run
-     func()
-   File 
"/tmp/ubuntu-release-upgrader-0xsphvrt/DistUpgrade/DistUpgradeQuirks.py", line 
127, in noblePostInitialUpdate
-     self._test_and_fail_on_tpm_fde()
-   File 
"/tmp/ubuntu-release-upgrader-0xsphvrt/DistUpgrade/DistUpgradeQuirks.py", line 
1906, in _test_and_fail_on_tpm_fde
-     snap_list = subprocess.check_output(['snap', 'list'])
-   File "/usr/lib/python3.10/subprocess.py", line 421, in check_output
-     return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
-   File "/usr/lib/python3.10/subprocess.py", line 526, in run
-     raise CalledProcessError(retcode, process.args,
- subprocess.CalledProcessError: Command '['snap', 'list']' returned non-zero 
exit status 1.
+   File "/tmp/ubuntu-release-upgrader-ihkoc99x/noble", line 8, in <module>
+     sys.exit(main())
+   File 
"/tmp/ubuntu-release-upgrader-ihkoc99x/DistUpgrade/DistUpgradeMain.py", line 
241, in main
+     if app.run():
+   File 
"/tmp/ubuntu-release-upgrader-ihkoc99x/DistUpgrade/DistUpgradeController.py", 
line 2662, in run
+     return self.fullUpgrade()
+   File 
"/tmp/ubuntu-release-upgrader-ihkoc99x/DistUpgrade/DistUpgradeController.py", 
line 2467, in fullUpgrade
+     if not self.doPostInitialUpdate():
+   File 
"/tmp/ubuntu-release-upgrader-ihkoc99x/DistUpgrade/DistUpgradeController.py", 
line 1438, in doPostInitialUpdate
+     self.quirks.run("PostInitialUpdate")
+   File 
"/tmp/ubuntu-release-upgrader-ihkoc99x/DistUpgrade/DistUpgradeQuirks.py", line 
102, in run
+     func()
+   File 
"/tmp/ubuntu-release-upgrader-ihkoc99x/DistUpgrade/DistUpgradeQuirks.py", line 
143, in noblePostInitialUpdate
+     self._checkStoreConnectivity()
+   File 
"/tmp/ubuntu-release-upgrader-ihkoc99x/DistUpgrade/DistUpgradeQuirks.py", line 
661, in _checkStoreConnectivity
+     connected = Popen(["snap", "debug", "connectivity"], stdout=PIPE,
+   File "/usr/lib/python3.10/subprocess.py", line 971, in __init__
+     self._execute_child(args, executable, preexec_fn, close_fds,
+   File "/usr/lib/python3.10/subprocess.py", line 1863, in _execute_child
+     raise child_exception_type(errno_num, err_msg, err_filename)
+ FileNotFoundError: [Errno 2] No such file or directory: 'snap'
  
- With a patch in place, the error should be logged instead, and the
- upgrade should continue.
+ 
+ With a patch in place, the error should be logged instead, and the upgrade 
should continue.
  
  Test #2 (from Noble only, not necessary from Jammy b/c TPM FDE does not
  exist there)
  
  Ensure that the fix does not regress the quirk on TPM FDE systems.
  Create a 24.04 LTS VM, select hardware-backed full disk encryption in
  the installer. Then, attempt an upgrade with:
  
  $ do-release-upgrade --proposed
  
  The upgrade should still be blocked.
  
  [Where problems could occur]
  
  This patch changes an existing quirk designed to prevent unsupported
  upgrades on TPM FDE systems. An incorrect patch could regress that
  quirk. To mitigate this, Test #2 above verifies the quirk still works as
  intended.
  
  [Original Description]
  
  Original report: https://github.com/ubuntu/WSL/issues/493
  
  On WSL, systemd is not always enabled. This is the case on WSL1 where it
  cannot be enabled and on WSL2 when it's been disabled or not enabled by
  default.
  
  When systemd is not available do-release-upgrade fails with the error
  below and upgrade is cancelled:
  
  From the report
  ===
  Traceback (most recent call last):
    File "/tmp/ubuntu-release-upgrader-uqmd8iby/noble", line 8, in <module>
      sys.exit(main())
    File 
"/tmp/ubuntu-release-upgrader-uqmd8iby/DistUpgrade/DistUpgradeMain.py", line 
241, in main
      if app.run():
    File 
"/tmp/ubuntu-release-upgrader-uqmd8iby/DistUpgrade/DistUpgradeController.py", 
line 2642, in run
      return self.fullUpgrade()
    File 
"/tmp/ubuntu-release-upgrader-uqmd8iby/DistUpgrade/DistUpgradeController.py", 
line 2447, in fullUpgrade
      if not self.doPostInitialUpdate():
    File 
"/tmp/ubuntu-release-upgrader-uqmd8iby/DistUpgrade/DistUpgradeController.py", 
line 1438, in doPostInitialUpdate
      self.quirks.run("PostInitialUpdate")
    File 
"/tmp/ubuntu-release-upgrader-uqmd8iby/DistUpgrade/DistUpgradeQuirks.py", line 
102, in run
      func()
    File 
"/tmp/ubuntu-release-upgrader-uqmd8iby/DistUpgrade/DistUpgradeQuirks.py", line 
127, in noblePostInitialUpdate
      self._test_and_fail_on_tpm_fde()
    File 
"/tmp/ubuntu-release-upgrader-uqmd8iby/DistUpgrade/DistUpgradeQuirks.py", line 
1898, in _test_and_fail_on_tpm_fde
      snap_list = subprocess.check_output(['snap', 'list'])
    File "/usr/lib/python3.10/subprocess.py", line 421, in check_output
      return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
    File "/usr/lib/python3.10/subprocess.py", line 526, in run
      raise CalledProcessError(retcode, process.args,
  subprocess.CalledProcessError: Command '['snap', 'list']' returned non-zero 
exit status 1.
  """
  
  This error should be ignored when systemd is not running.
  
  Read https://github.com/ubuntu/WSL/issues/493#issuecomment-2324510606
  for details. Thanks to Vadim for the investigation.
  
  """
  In /tmp/ubuntu-release-upgrader-t8sg0mg9/DistUpgrade/DistUpgradeQuirks.py:
  
       def _test_and_fail_on_tpm_fde(self):
          """
          LP: #2065229
          """
          try:
              snap_list = subprocess.check_output(['snap', 'list'])
              snaps = [s.decode().split()[0] for s in snap_list.splitlines()]
          except FileNotFoundError:
              # snapd not installed?
              return
  I think except FileNotFoundError: should be extended to except:
  
  Because DistUpgradeQuirks.py is stored in some temp directory, it was hard to 
change it inplace, but I succeeded, and then the upgrade process continued as 
it should
  ===

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

Title:
  do-release-upgrade fails when snap returns non-zero exit code [[wsl]
  do-release-upgrade fails with systemd disabled]

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/ubuntu-release-upgrader/+bug/2080233/+subscriptions


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

Reply via email to