do-release-upgrade crashed with UnboundLocalError in _replaceDebsWithSnaps(): local variable 'proc' referenced before assignment

Bug #1781412 reported by Brian Murray
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
ubuntu-release-upgrader (Ubuntu)
Fix Released
High
Brian Murray
Bionic
Fix Released
Undecided
Unassigned

Bug Description

Adding support for transitioning debs to snaps when upgrading from 16.04 to 18.04, bug 1780841, ended up creating a crash in a specific scenario.

[Test Case]
1) Install and Ubuntu 16.04 desktop system
2) Modify /etc/hosts so api.snapcraft.io resolves to 127.0.0.1
3) Upgrade to Ubuntu 18.04 using u-r-u 18.04.20 (sudo ./bionic --frontend DistUpgradeViewText)
4) Observe the Traceback in this bug report

N.B. You'll need to manually download and extract the release upgrader tarball from http://archive.ubuntu.com/ubuntu/dists/bionic-proposed/main/dist-upgrader-all/current/ since the upgrade is to the development and proposed release.

I was testing a release upgrade from Ubuntu 16.04 to Ubuntu 18.04 where I had no connectivity to the snap store and encountered this crash.

ProblemType: CrashDistroRelease: Ubuntu 18.04
Package: ubuntu-release-upgrader-core 1:18.04.20
ProcVersionSignature: Ubuntu 4.4.0-121.145-generic 4.4.117
Uname: Linux 4.4.0-121-generic x86_64
ApportVersion: 2.20.9-0ubuntu7.2
Architecture: amd64
CrashDB: ubuntu
Date: Wed Jul 11 20:03:49 2018
ExecutablePath: /usr/bin/do-release-upgrade
ExecutableTimestamp: 1531169948
InstallationDate: Installed on 2016-10-04 (645 days ago)
InstallationMedia: Ubuntu 16.04.1 LTS "Xenial Xerus" - Release amd64 (20160719)
InterpreterPath: /usr/bin/python3.5
PackageArchitecture: all
ProcCmdline: /usr/bin/python3 ./bionic --frontend DistUpgradeViewText
ProcCwd: /tmp/u-r-u
ProcEnviron:
 TERM=screen
 SHELL=/bin/bash
 PATH=(custom, no user)
 LANG=en_US.UTF-8
 LC_CTYPE=en_US.UTF-8
Python3Details: /usr/bin/python3.6, Python 3.6.5, python3-minimal, 3.6.5-3ubuntu1
PythonArgs: ['/usr/bin/do-release-upgrade', '--frontend', 'DistUpgradeViewText']
PythonDetails: /usr/bin/python2.7, Python 2.7.15rc1, python-minimal, 2.7.15~rc1-1SourcePackage: ubuntu-release-upgrader
Title: do-release-upgrade crashed with UnboundLocalError in _replaceDebsWithSnaps(): local variable 'proc' referenced before assignment
UpgradeStatus: Upgraded to bionic on 2018-07-12 (0 days ago)
UserGroups:

modified.conffile..etc.update-manager.release-upgrades: [modified]
mtime.conffile..etc.update-manager.release-upgrades: 2016-10-04T13:43:38.934395

Related branches

Revision history for this message
Brian Murray (brian-murray) wrote :
Revision history for this message
Brian Murray (brian-murray) wrote :

Here's the Traceback:

Traceback (most recent call last):
  File "./bionic", line 8, in <module>
    sys.exit(main())
  File "/tmp/u-r-u/DistUpgrade/DistUpgradeMain.py", line 238, in main
    if app.run():
  File "/tmp/u-r-u/DistUpgrade/DistUpgradeController.py", line 1949, in run
    return self.fullUpgrade()
  File "/tmp/u-r-u/DistUpgrade/DistUpgradeController.py", line 1926, in fullUpgrade
    self.doPostUpgrade()
  File "/tmp/u-r-u/DistUpgrade/DistUpgradeController.py", line 1336, in doPostUpgrade
    self.quirks.run("PostUpgrade")
  File "/tmp/u-r-u/DistUpgrade/DistUpgradeQuirks.py", line 113, in run
    func()
  File "/tmp/u-r-u/DistUpgrade/DistUpgradeQuirks.py", line 138, in bionicPostUpgrade
    self._replaceDebsWithSnaps()
  File "/tmp/u-r-u/DistUpgrade/DistUpgradeQuirks.py", line 543, in _replaceDebsWithSnaps
    if proc.returncode == 0:
UnboundLocalError: local variable 'proc' referenced before assignment

information type: Private → Public
Changed in ubuntu-release-upgrader (Ubuntu):
status: New → In Progress
importance: Undecided → High
assignee: nobody → Brian Murray (brian-murray)
Revision history for this message
Brian Murray (brian-murray) wrote :

The fix for the Traceback creates a main.log that looks like this:

2018-07-12 12:40:29,870 DEBUG running Quirks.bionicPostUpgrade
2018-07-12 12:40:30,337 DEBUG Install of snap gtk-common-themes failed
2018-07-12 12:40:30,354 DEBUG Install of snap gnome-calculator failed
2018-07-12 12:40:30,370 DEBUG Install of snap gnome-characters failed
2018-07-12 12:40:30,385 DEBUG Install of snap gnome-logs failed
2018-07-12 12:40:30,402 DEBUG Install of snap gnome-system-monitor failed

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package ubuntu-release-upgrader - 1:18.10.5

---------------
ubuntu-release-upgrader (1:18.10.5) cosmic; urgency=medium

  * DistUpgradeQuirks.py: when a snap fails to install try the next one
    instead of trying to check the return code of the called process which
    causes a Traceback. (LP: #1781412)

 -- Brian Murray <email address hidden> Thu, 12 Jul 2018 13:07:14 -0700

Changed in ubuntu-release-upgrader (Ubuntu):
status: In Progress → Fix Released
description: updated
Revision history for this message
Łukasz Zemczak (sil2100) wrote : Please test proposed package

Hello Brian, or anyone else affected,

Accepted ubuntu-release-upgrader into bionic-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/ubuntu-release-upgrader/1:18.04.21 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!

Changed in ubuntu-release-upgrader (Ubuntu Bionic):
status: New → Fix Committed
tags: added: verification-needed verification-needed-bionic
Revision history for this message
Brian Murray (brian-murray) wrote :
Download full text (6.9 KiB)

I no longer receive this crash with the version of ubuntu-release-upgrader in bionic-proposed.

bdmurray@clean-xenial-amd64:/tmp/u-r-u$ cat DistUpgradeVersion.py
VERSION = '18.04.21'
bdmurray@clean-xenial-amd64:/tmp/u-r-u$ grep "snap " /var/log/dist-upgrade/main.log
2018-07-16 11:43:28,581 ERROR No snap store connectivity
2018-07-16 11:44:41,442 DEBUG Install: amd64-microcode apache2-bin apt-config-icons binutils-common binutils-x86-64-linux-gnu bolt cpp-7 cups-ipp-utils dbus-user-session dmsetup e2fsprogs-l10n espeak-ng-data fdisk fonts-beng fonts-beng-extra fonts-deva fonts-deva-extra fonts-droid-fallback fonts-gargi fonts-gubbi fonts-gujr fonts-gujr-extra fonts-indic fonts-kalapi fonts-knda fonts-liberation2 fonts-lohit-beng-assamese fonts-lohit-beng-bengali fonts-lohit-deva fonts-lohit-gujr fonts-lohit-knda fonts-lohit-mlym fonts-lohit-orya fonts-lohit-taml fonts-lohit-taml-classical fonts-lohit-telu fonts-mlym fonts-nakula fonts-navilu fonts-noto-color-emoji fonts-noto-mono fonts-orya fonts-orya-extra fonts-pagul fonts-sahadeva fonts-samyak-deva fonts-samyak-gujr fonts-samyak-mlym fonts-samyak-taml fonts-sarai fonts-smc fonts-smc-anjalioldlipi fonts-smc-chilanka fonts-smc-dyuthi fonts-smc-karumbi fonts-smc-keraleeyam fonts-smc-manjari fonts-smc-meera fonts-smc-rachana fonts-smc-raghumalayalamsans fonts-smc-suruma fonts-smc-uroob fonts-taml fonts-telu fonts-telu-extra fonts-ubuntu g++-7 gcc-7 gcc-7-base gcc-8-base gdm3 geoclue-2.0 gir1.2-accountsservice-1.0 gir1.2-gck-1 gir1.2-gcr-3 gir1.2-gdesktopenums-3.0 gir1.2-gdm-1.0 gir1.2-geoclue-2.0 gir1.2-geocodeglib-1.0 gir1.2-gnomebluetooth-1.0 gir1.2-gnomedesktop-3.0 gir1.2-gweather-3.0 gir1.2-mutter-2 gir1.2-nm-1.0 gir1.2-nma-1.0 gir1.2-polkit-1.0 gir1.2-rsvg-2.0 gir1.2-snapd-1 gir1.2-totemplparser-1.0 gir1.2-upowerglib-1.0 gjs gnome-control-center gnome-control-center-data gnome-control-center-faces gnome-getting-started-docs gnome-initial-setup gnome-keyring-pkcs11 gnome-online-accounts gnome-settings-daemon gnome-shell gnome-shell-common gnome-shell-extension-appindicator gnome-shell-extension-ubuntu-dock gnome-software-plugin-snap gnome-startup-applications gnome-themes-extra gnome-themes-extra-data gnome-todo gnome-todo-common gnome-user-docs gnupg-l10n gnupg-utils gpg gpg-agent gpg-wks-client gpg-wks-server gpgconf gpgsm grilo-plugins-0.3-base gstreamer1.0-gl gstreamer1.0-packagekit gtk-update-icon-cache gtk2-engines-pixbuf gtk3-nocsd hyphen-en-ca hyphen-fi hyphen-ga hyphen-id iio-sensor-proxy imagemagick-6-common indicator-common intel-microcode iucode-tool kerneloops libabw-0.1-1 libapache2-mod-dnssd libappstream4 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libargon2-0 libasan4 libbind9-160 libbinutils libblockdev-crypto2 libblockdev-fs2 libblockdev-loop2 libblockdev-part-err2 libblockdev-part2 libblockdev-swap2 libblockdev-utils2 libblockdev2 libboost-date-time1.65.1 libboost-filesystem1.65.1 libboost-iostreams1.65.1 libboost-locale1.65.1 libboost-system1.65.1 libboost-thread1.65.1 libbrotli1 libcairo-gobject-perl libcamel-1.2-61 libcapnp-0.6.1 libcdio-cdda2 libcdio-paranoia2 libcdio17 libcolamd2 libcolord-gtk1 libcom-err2 libcryptsetup12 libcurl4 libdata-dump-perl...

Read more...

tags: added: verification-done verification-done-bionic
removed: verification-needed verification-needed-bionic
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package ubuntu-release-upgrader - 1:18.04.21

---------------
ubuntu-release-upgrader (1:18.04.21) bionic; urgency=medium

  * DistUpgradeQuirks.py: when a snap fails to install try the next one
    instead of trying to check the return code of the called process which
    causes a Traceback. (LP: #1781412)
  * data/mirrors.cfg: Update the list of official mirrors.

ubuntu-release-upgrader (1:18.04.20) bionic; urgency=medium

  * Purge obsolete packages, if user agrees to remove obsolete
    packages. LP: #1775660
  * DistUpgradeQuirks.py, DistUpgradeController.py: move inhibiting of
    gnome-session idle so that it is called immediately after the upgrade
    starts (LP: #1778817), present a dialog notifying that the lock screen has
    been disabled (LP: #1174093), and do not reenable the lock screen as it
    may fail to work after a release upgrade. (LP: #1780342)
  * DistUpgradeQuirks.py: Add in a quirk for upgrading to Bionic that will
    check if the system has connectivity to the snap store and replace some
    desktop packages with snaps to ensure the system is similar to a fresh
    install. (LP: #1780841)
  * data/mirrors.cfg: Update the list of official mirrors.

 -- Brian Murray <email address hidden> Sun, 15 Jul 2018 10:16:16 -0700

Changed in ubuntu-release-upgrader (Ubuntu Bionic):
status: Fix Committed → Fix Released
Revision history for this message
Steve Langasek (vorlon) wrote : Update Released

The verification of the Stable Release Update for ubuntu-release-upgrader 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.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.