do-release-upgrade on WSL failed horribly due to grub and others

Bug #1816753 reported by Søren Boisen on 2019-02-20
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
systemd (Ubuntu)
Undecided
Unassigned
Xenial
Undecided
Unassigned
Bionic
Undecided
Unassigned
Cosmic
Undecided
Unassigned
Disco
Undecided
Unassigned

Bug Description

[Impact]

 * Package maintainer scripts and services use systemd-detect-virt and systemd's virtualization detection to determine the environment they are ran in and based on that skip not applicable operations, such as installing grub info to the MBR or to the EFI partition in a container. The WSL environment is similar to containers in that boot loader and initramfs preparations are not useful, but without this change only ad-hoc tests could be implemented in each separate package to avoid obsolete actions or failing in trying not applicable operations.
 * The fix detects WSL as a container type, called wsl in systemd and as a result make packages behave like they would in classic Linuxcontainers.

[Test Case]

 * Install the fixed systemd package in WSL and observe that it is detected as a container:
 $ systemd-detect-virt --container
 wsl
 $

 * Install the fixed systemd package in LXC and observe that it is still detected correctly:
 $ systemd-detect-virt --container
 lxc
 $

 * Install the fixed systemd package in a VM or on a bare metal systemd and observe that it is still detected correctly:
 $ systemd-detect-virt --container
 none
 $ echo $?
 1

 * Observe the man page of sytemd-detect-virt mentioning wsl.

[Regression Potential]

 * The changes is virtualization detection could break the detection logic but the test cases here cover most of the relevant code paths and the detection logic is also exercised in autopkgtests thus causing a regression is unlikely.
 * The changes to the man pages could break the formatting, but a simple observation mitigates that risk, too.

[Original Bug Text]

Upon reading an Ubuntu page that said it was possible to upgrade my Ubuntu-under-Windows 10 install (WSL) from 16.04 LTS just by running do-release-upgrade, I excitedly went to my terminal and ran the command.

First it refused to run because system was not fully updated. Fine, I ran:
sudo apt update
sudo apt dist-upgrade

This process completed without any errors. I then ran do-release-upgrade again. This time it started okay and got through most of the process.

But then at some point it decided to run grub even though I am running Ubuntu under WSL, so presumably grub should not be used. It did apparently detect that it wasn't needed, because it asked me if I was sure I didn't want to install it on the boot device. I answered yes. Then the install proceeded to LXD but soon after came an error related to grub.

After that it went downhill fast with at least 2 other errors.

Additionally, when the system attempted to roll back the upgrade I got an error from a kernel package.

ProblemType: Package
DistroRelease: Ubuntu 18.04
Package: friendly-recovery 0.2.38ubuntu1
ProcVersionSignature: Microsoft 4.4.0-17763.253-Microsoft 4.4.35
Uname: Linux 4.4.0-17763-Microsoft x86_64
ApportVersion: 2.20.9-0ubuntu7.5
Architecture: amd64
Date: Tue Feb 19 23:50:44 2019
Dmesg: [ 0.017808] Microsoft 4.4.0-17763.253-Microsoft 4.4.35
ErrorMessage: installed friendly-recovery package post-installation script subprocess returned error exit status 1
PackageArchitecture: all
Python3Details: /usr/bin/python3.6, Python 3.6.7, python3-minimal, 3.6.7-1~18.04
PythonDetails: /usr/bin/python2.7, Python 2.7.15rc1, python-minimal, 2.7.15~rc1-1
RelatedPackageVersions:
 dpkg 1.19.0.5ubuntu2.1
 apt 1.6.8
SourcePackage: grub2
Title: package friendly-recovery 0.2.38ubuntu1 failed to install/upgrade: installed friendly-recovery package post-installation script subprocess returned error exit status 1
UpgradeStatus: Upgraded to bionic on 2019-02-20 (0 days ago)

Søren Boisen (sb001) wrote :
Balint Reczey (rbalint) wrote :

This particular grub failure occurred because grub tries systemd-detect-virt --quiet --container to see if it has to skip grub-install.

I'm fixing this in systemd to detect wsl as a container.

Changed in grub2 (Ubuntu):
assignee: nobody → Balint Reczey (rbalint)
affects: grub2 (Ubuntu) → systemd (Ubuntu)
Changed in systemd (Ubuntu):
assignee: Balint Reczey (rbalint) → nobody
Søren Boisen (sb001) wrote :

Sounds good. Would be really really nice if the error during rollback could be fixed as well, so all changes are properly rolled back.

Balint Reczey (rbalint) on 2019-03-14
description: updated
Balint Reczey (rbalint) on 2019-03-14
Changed in systemd (Ubuntu Disco):
status: New → In Progress
Changed in systemd (Ubuntu Cosmic):
status: New → In Progress
Changed in systemd (Ubuntu Bionic):
status: New → In Progress
Changed in systemd (Ubuntu Xenial):
status: New → In Progress
tags: added: patch
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package systemd - 240-6ubuntu3

---------------
systemd (240-6ubuntu3) disco; urgency=medium

  * virt: detect WSL environment as a container (LP: #1816753)
  * debian/control: Update Vcs-{Browser|Git} to Ubuntu's packaging repository
  * debian/gbp.conf: Set tag format to ubuntu/*

 -- Balint Reczey <email address hidden> Fri, 22 Mar 2019 18:39:48 +0100

Changed in systemd (Ubuntu Disco):
status: In Progress → Fix Released

Hello Søren, or anyone else affected,

Accepted systemd into cosmic-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/systemd/239-7ubuntu10.11 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 and change the tag from verification-needed-cosmic to verification-done-cosmic. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-cosmic. 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 systemd (Ubuntu Cosmic):
status: In Progress → Fix Committed
tags: added: verification-needed verification-needed-cosmic
Łukasz Zemczak (sil2100) wrote :

Hello Søren, or anyone else affected,

Accepted systemd into bionic-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/systemd/237-3ubuntu10.17 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 and change the tag from verification-needed-bionic to verification-done-bionic. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-bionic. 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 systemd (Ubuntu Bionic):
status: In Progress → Fix Committed
tags: added: verification-needed-bionic
Łukasz Zemczak (sil2100) wrote :

Hello Søren, or anyone else affected,

Accepted systemd into xenial-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/systemd/229-4ubuntu21.19 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 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 systemd (Ubuntu Xenial):
status: In Progress → Fix Committed
tags: added: verification-needed-xenial
Balint Reczey (rbalint) wrote :

Verified 237-3ubuntu10.17 on Bionic:
...
[K]0;ubuntu@DESKTOP-V4DDKSS: ~ubuntu@DESKTOP-V4DDKSS:~$ systemd-detect-virt --container
wsl
...

...
root@bb-ua:~# dpkg -l systemd | cat
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-==============-================-============-=================================
ii systemd 237-3ubuntu10.17 amd64 system and service manager
root@bb-ua:~# systemd-detect-virt --container
lxc
...

...
rbalint@yogi:~$ dpkg -l systemd |cat
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-==============-================-============-=================================
ii systemd 237-3ubuntu10.17 amd64 system and service manager
rbalint@yogi:~$ systemd-detect-virt
none
rbalint@yogi:~$
...

tags: added: verification-done-bionic
removed: verification-needed-bionic
Balint Reczey (rbalint) wrote :

Verified 229-4ubuntu21.19 on Xenial:

# systemd-detect-virt --container
wsl

...
root@x-uu-upgrade:~# systemd-detect-virt
lxc
oot@x-uu-upgrade:~# dpkg -l systemd | cat
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-==============-================-============-=================================
ii systemd 229-4ubuntu21.19 amd64 system and service manager
...

...
ubuntu@ubuntu-Standard-PC-i440FX-PIIX-1996:~$ systemd-detect-virt --container
none
ubuntu@ubuntu-Standard-PC-i440FX-PIIX-1996:~$ echo $?
1
ubuntu@ubuntu-Standard-PC-i440FX-PIIX-1996:~$ dpkg -l systemd | cat
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-==============-================-============-===========================
...

tags: added: verification-done-xenial
removed: verification-needed-xenial
Balint Reczey (rbalint) wrote :

Verified 239-7ubuntu10.11 on Cosmic:

...
ubuntu@DESKTOP-V4DDKSS:~$ dpkg -l systemd | cat
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-==============-================-============-=================================
ii systemd 239-7ubuntu10.11 amd64 system and service manager
ubuntu@DESKTOP-V4DDKSS:~$ systemd-detect-virt --container
wsl
ubuntu@DESKTOP-V4DDKSS:~$ systemd-detect-virt
wsl
...

...
root@cc-daily:~# systemd-detect-virt
lxc
root@cc-daily:~# dpkg -l systemd
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-=======================-================-================-===================================================
ii systemd 239-7ubuntu10.11 amd64 system and service manager
...

Balint Reczey (rbalint) wrote :

Verified 239-7ubuntu10.11 on Cosmic:

test@test-Standard-PC-i440FX-PIIX-1996:~$ systemd-detect-virt --container
none
test@test-Standard-PC-i440FX-PIIX-1996:~$ echo $?
1
test@test-Standard-PC-i440FX-PIIX-1996:~$ dpkg -l systemd | cat
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-==============-================-============-=================================
ii systemd 239-7ubuntu10.11 amd64 system and service manager

tags: added: verification-done verification-done-cosmic
removed: verification-needed verification-needed-cosmic
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package systemd - 239-7ubuntu10.11

---------------
systemd (239-7ubuntu10.11) cosmic; urgency=medium

  * virt: detect WSL environment as a container (LP: #1816753)

 -- Balint Reczey <email address hidden> Mon, 25 Mar 2019 11:30:22 +0100

Changed in systemd (Ubuntu Cosmic):
status: Fix Committed → Fix Released

The verification of the Stable Release Update for systemd has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Launchpad Janitor (janitor) wrote :

This bug was fixed in the package systemd - 229-4ubuntu21.19

---------------
systemd (229-4ubuntu21.19) xenial; urgency=medium

  [ Michael Vogt ]
  * d/p/fix-race-daemon-reload-11121.patch:
    - backport systemd upstream PR#8803 and PR#11121 to fix race
      when doing systemctl and systemctl daemon-reload at the
      same time LP: #1819728

  [ Balint Reczey ]
  * d/p/virt-detect-WSL-environment-as-a-container.patch:
    - virt: detect WSL environment as a container (LP: #1816753)

 -- Michael Vogt <email address hidden> Mon, 25 Mar 2019 16:04:56 +0100

Changed in systemd (Ubuntu Xenial):
status: Fix Committed → Fix Released
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package systemd - 237-3ubuntu10.17

---------------
systemd (237-3ubuntu10.17) bionic; urgency=medium

  [ Michael Vogt ]
  * d/p/Support-system-image-read-only-etc.patch:
    - re-add support for /etc/writable for core18 (LP: #1778936)
  * d/p/fix-race-daemon-reload-8803.patch:
    - backport systemd upstream PR#8803 and PR#11121 to fix race
      when doing systemctl and systemctl daemon-reload at the
      same time LP: #1819728

  [ Balint Reczey ]
   * d/p/virt-detect-WSL-environment-as-a-container.patch:
     - virt: detect WSL environment as a container (LP: #1816753)

 -- Michael Vogt <email address hidden> Mon, 18 Mar 2019 08:40:44 +0100

Changed in systemd (Ubuntu Bionic):
status: Fix Committed → Fix Released
To post a comment you must log in.