[Bug 1798951] [NEW] Unattended Upgrades failing with variable reference error
Knut Ahlers
knut at ahlers.me
Sat Oct 20 10:57:43 UTC 2018
Public bug reported:
When running unattended-upgrades with auto-remove enabled the script
complains about a variable being referenced before assignment:
```
# unattended-upgrade -d
[...]
Removing unused kernel packages: linux-image-4.15.0-32-generic linux-modules-4.15.0-32-generic
Keeping 2 auto-removable package(s) because it would also remove the following packages which should be kept in this step: [...]
Traceback (most recent call last):
File "/usr/bin/unattended-upgrade", line 1991, in <module>
sys.exit(main(options))
File "/usr/bin/unattended-upgrade", line 1791, in main
options.verbose or options.debug, options.dry_run)
File "/usr/bin/unattended-upgrade", line 1480, in do_auto_remove
if res:
UnboundLocalError: local variable 'res' referenced before assignment
```
This causes the apt-daily-upgrade.service to "fail" which then again
causes no updates to be installed, which means the package does not
fulfil its purpose:
```
# systemctl status apt-daily-upgrade.service
● apt-daily-upgrade.service - Daily apt upgrade and clean activities
Loaded: loaded (/lib/systemd/system/apt-daily-upgrade.service; static; vendor preset: enabled)
Active: inactive (dead) since Sat 2018-10-20 06:17:09 CEST; 6h ago
Docs: man:apt(8)
Main PID: 32708 (code=exited, status=0/SUCCESS)
Oct 20 06:16:00 myhost systemd[1]: Starting Daily apt upgrade and clean activities...
Oct 20 06:17:09 myhost apt.systemd.daily[32708]: Traceback (most recent call last):
Oct 20 06:17:09 myhost apt.systemd.daily[32708]: File "/usr/bin/unattended-upgrade", line 1991, in <module>
Oct 20 06:17:09 myhost apt.systemd.daily[32708]: sys.exit(main(options))
Oct 20 06:17:09 myhost apt.systemd.daily[32708]: File "/usr/bin/unattended-upgrade", line 1791, in main
Oct 20 06:17:09 myhost apt.systemd.daily[32708]: options.verbose or options.debug, options.dry_run)
Oct 20 06:17:09 myhost apt.systemd.daily[32708]: File "/usr/bin/unattended-upgrade", line 1480, in do_auto_remove
Oct 20 06:17:09 myhost apt.systemd.daily[32708]: if res:
Oct 20 06:17:09 myhost apt.systemd.daily[32708]: UnboundLocalError: local variable 'res' referenced before assignment
Oct 20 06:17:09 myhost systemd[1]: Started Daily apt upgrade and clean activities.
# apt-get --just-print upgrade | grep ^Inst | wc -l
99
```
Mapped to the current source code of the script within the bionic branch
the error occurs in this line:
https://git.launchpad.net/ubuntu/+source/unattended-upgrades/tree
/unattended-
upgrade?h=ubuntu/bionic&id=165a91cd44a77a03a83c64cd3812831ba26e3a80#n1418
Used version of the package:
```
# apt-cache policy unattended-upgrades
unattended-upgrades:
Installed: 1.1ubuntu1.18.04.5
Candidate: 1.1ubuntu1.18.04.5
Version table:
*** 1.1ubuntu1.18.04.5 500
500 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages
500 http://archive.ubuntu.com/ubuntu bionic-updates/main i386 Packages
500 http://mirror.hetzner.de/ubuntu/packages bionic-updates/main amd64 Packages
500 http://mirror.hetzner.de/ubuntu/packages bionic-updates/main i386 Packages
100 /var/lib/dpkg/status
1.1ubuntu1 500
500 http://archive.ubuntu.com/ubuntu bionic/main amd64 Packages
500 http://archive.ubuntu.com/ubuntu bionic/main i386 Packages
500 http://mirror.hetzner.de/ubuntu/packages bionic/main amd64 Packages
500 http://mirror.hetzner.de/ubuntu/packages bionic/main i386 Packages
```
** Affects: unattended-upgrades (Ubuntu)
Importance: Undecided
Status: New
--
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/1798951
Title:
Unattended Upgrades failing with variable reference error
Status in unattended-upgrades package in Ubuntu:
New
Bug description:
When running unattended-upgrades with auto-remove enabled the script
complains about a variable being referenced before assignment:
```
# unattended-upgrade -d
[...]
Removing unused kernel packages: linux-image-4.15.0-32-generic linux-modules-4.15.0-32-generic
Keeping 2 auto-removable package(s) because it would also remove the following packages which should be kept in this step: [...]
Traceback (most recent call last):
File "/usr/bin/unattended-upgrade", line 1991, in <module>
sys.exit(main(options))
File "/usr/bin/unattended-upgrade", line 1791, in main
options.verbose or options.debug, options.dry_run)
File "/usr/bin/unattended-upgrade", line 1480, in do_auto_remove
if res:
UnboundLocalError: local variable 'res' referenced before assignment
```
This causes the apt-daily-upgrade.service to "fail" which then again
causes no updates to be installed, which means the package does not
fulfil its purpose:
```
# systemctl status apt-daily-upgrade.service
● apt-daily-upgrade.service - Daily apt upgrade and clean activities
Loaded: loaded (/lib/systemd/system/apt-daily-upgrade.service; static; vendor preset: enabled)
Active: inactive (dead) since Sat 2018-10-20 06:17:09 CEST; 6h ago
Docs: man:apt(8)
Main PID: 32708 (code=exited, status=0/SUCCESS)
Oct 20 06:16:00 myhost systemd[1]: Starting Daily apt upgrade and clean activities...
Oct 20 06:17:09 myhost apt.systemd.daily[32708]: Traceback (most recent call last):
Oct 20 06:17:09 myhost apt.systemd.daily[32708]: File "/usr/bin/unattended-upgrade", line 1991, in <module>
Oct 20 06:17:09 myhost apt.systemd.daily[32708]: sys.exit(main(options))
Oct 20 06:17:09 myhost apt.systemd.daily[32708]: File "/usr/bin/unattended-upgrade", line 1791, in main
Oct 20 06:17:09 myhost apt.systemd.daily[32708]: options.verbose or options.debug, options.dry_run)
Oct 20 06:17:09 myhost apt.systemd.daily[32708]: File "/usr/bin/unattended-upgrade", line 1480, in do_auto_remove
Oct 20 06:17:09 myhost apt.systemd.daily[32708]: if res:
Oct 20 06:17:09 myhost apt.systemd.daily[32708]: UnboundLocalError: local variable 'res' referenced before assignment
Oct 20 06:17:09 myhost systemd[1]: Started Daily apt upgrade and clean activities.
# apt-get --just-print upgrade | grep ^Inst | wc -l
99
```
Mapped to the current source code of the script within the bionic
branch the error occurs in this line:
https://git.launchpad.net/ubuntu/+source/unattended-upgrades/tree
/unattended-
upgrade?h=ubuntu/bionic&id=165a91cd44a77a03a83c64cd3812831ba26e3a80#n1418
Used version of the package:
```
# apt-cache policy unattended-upgrades
unattended-upgrades:
Installed: 1.1ubuntu1.18.04.5
Candidate: 1.1ubuntu1.18.04.5
Version table:
*** 1.1ubuntu1.18.04.5 500
500 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages
500 http://archive.ubuntu.com/ubuntu bionic-updates/main i386 Packages
500 http://mirror.hetzner.de/ubuntu/packages bionic-updates/main amd64 Packages
500 http://mirror.hetzner.de/ubuntu/packages bionic-updates/main i386 Packages
100 /var/lib/dpkg/status
1.1ubuntu1 500
500 http://archive.ubuntu.com/ubuntu bionic/main amd64 Packages
500 http://archive.ubuntu.com/ubuntu bionic/main i386 Packages
500 http://mirror.hetzner.de/ubuntu/packages bionic/main amd64 Packages
500 http://mirror.hetzner.de/ubuntu/packages bionic/main i386 Packages
```
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/unattended-upgrades/+bug/1798951/+subscriptions
More information about the foundations-bugs
mailing list