[Bug 1795696] Re: /usr/bin/unattended-upgrade:UnboundLocalError:/usr/bin/unattended-upgrade at 1991:main:do_auto_remove

Balint Reczey balint.reczey at canonical.com
Mon May 6 17:17:44 UTC 2019


Verified 1.1ubuntu1.18.04.7~16.04.3 on Xenial:

root at x-lp-1795696:~# apt-get autoremove 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  linux-image-unsigned-4.15.0-34-generic linux-modules-4.15.0-34-generic
0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
After this operation, 74.5 MB disk space will be freed.
Do you want to continue? [Y/n] n
Abort.
root at x-lp-1795696:~# dpkg -l unattended-upgrades | 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  unattended-upgrades 1.1ubuntu1.18.04.7~16.04.2 all          automatic installation of security upgrades
root at x-lp-1795696:~# unattended-upgrade --dry-run
Traceback (most recent call last):
  File "/usr/bin/unattended-upgrade", line 1998, in <module>
    sys.exit(main(options))
  File "/usr/bin/unattended-upgrade", line 1798, in main
    options.verbose or options.debug, options.dry_run)
  File "/usr/bin/unattended-upgrade", line 1495, in do_auto_remove
    if res:
UnboundLocalError: local variable 'res' referenced before assignment
...
root at x-lp-1795696:~# dpkg -l unattended-upgrades | 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  unattended-upgrades 1.1ubuntu1.18.04.7~16.04.3 all          automatic installation of security upgrades
root at x-lp-1795696:~# unattended-upgrade --dry-run          
root at x-lp-1795696:~# unattended-upgrade --dry-run --verbose
Initial blacklisted packages: 
Initial whitelisted packages: 
Starting unattended upgrades script
Allowed origins are: o=Ubuntu,a=xenial, o=Ubuntu,a=xenial-security, o=UbuntuESM,a=xenial
Removing unused kernel packages: linux-modules-4.15.0-34-generic
Keeping 1 auto-removable package(s) because it would also remove the following packages which should be kept in this step: linux-image-unsigned-4.15.0-34-generic
Packages that were successfully auto-removed: 
Packages that are kept back: 
No packages found that can be upgraded unattended and no pending auto-removals


** Tags removed: verification-needed verification-needed-xenial
** Tags added: verification-done verification-done-xenial

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

Title:
  /usr/bin/unattended-upgrade:UnboundLocalError:/usr/bin/unattended-
  upgrade at 1991:main:do_auto_remove

Status in unattended-upgrades package in Ubuntu:
  Fix Released
Status in unattended-upgrades source package in Xenial:
  Fix Committed
Status in unattended-upgrades source package in Bionic:
  Fix Released
Status in unattended-upgrades source package in Cosmic:
  Fix Released

Bug description:
  [Impact]

   * Unattended-upgrades crashes while auto-removing kernel packages.

  [Test Case]

  1. Install kernel packages to be automatically removed:
   #  eatmydata apt install linux-image-4.18.0-13-generic linux-image-4.18.0-14-generic linux-image-4.18.0-15-generic
   # apt-mark auto linux-image-4.18.0-13-generic linux-image-4.18.0-14-generic linux-image-4.18.0-15-generic
   #  /etc/kernel/postinst.d/apt-auto-removal

  2. Set up u-u to perform action in non-minimal steps:
  # grep Minimal /etc/apt/apt.conf.d/50unattended-upgrades
  Unattended-Upgrade::MinimalSteps "false";

  3. Run u-u in dry-run mode.
     Observe it failing with not fixed versions:
    # unattended-upgrade --dry-run
  Traceback (most recent call last):
    File "/usr/bin/unattended-upgrade", line 1998, in <module>
      sys.exit(main(options))
    File "/usr/bin/unattended-upgrade", line 1798, in main
      options.verbose or options.debug, options.dry_run)
    File "/usr/bin/unattended-upgrade", line 1495, in do_auto_remove
      if res:
  UnboundLocalError: local variable 'res' referenced before assignment

    Observe the fixed version running properly:
   # ./unattended-upgrade --dry-run
   #

  [Regression Potential]

   * The fix is very small and isolated, but a programming error could
  cause the misreporting of the success of auto-removals. Considering
  the size and simplicity of the change, regressions here seem unlikely.

  [Original Bug Text]

  The Ubuntu Error Tracker has been receiving reports about a problem regarding unattended-upgrades.  This problem was most recently seen with package version 1.1ubuntu1.18.04.5, the problem page at https://errors.ubuntu.com/problem/651a7b7a070dd794d8cf2f5ea8e974614fdedb8e contains more details, including versions of packages affected, stacktrace or traceback, and individual crash reports.
  If you do not have access to the Ubuntu Error Tracker and are a software developer, you can request it at http://forms.canonical.com/reports/.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/unattended-upgrades/+bug/1795696/+subscriptions



More information about the foundations-bugs mailing list