free space need for /usr could be negative which is wrong

Bug #1786484 reported by Carlo Wood
12
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
Cosmic
Fix Released
Undecided
Unassigned

Bug Description

[Impact]
The checkFreeSpace function doesn't ensure that the space needed is a positive number thereby causing a situation where a partition, like /usr, doesn't have enough free space which then results in a failure during upgrade.

[Test Case]
It's not clear to me how to recreate this scenario, however I believe this falls into the "obviously safe" patch category. The specific change to checkFreeSpace, which is described as "this checks if we have enough free space", from DistUpgradeCache.py follows:

1200 # we are ensuring we have more than enough free space not less
1201 if size < 0:
1202 continue

This stops the needed space from being a negative number.

[Regression Potential]
Other than a typo in the change there won't be any.

[Original Description]
In my case I ran out of diskspace in /usr which required a temporary 4 GB of more data during upgrade. Things just start to fail, and I can tell you - then you are screwed. I find this unacceptable for a wide-spread official LTS upgrader.

ProblemType: BugDistroRelease: Ubuntu 18.04
Package: ubuntu-release-upgrader-core 1:18.04.22
ProcVersionSignature: Ubuntu 4.15.0-30.32-generic 4.15.18
Uname: Linux 4.15.0-30-generic x86_64
NonfreeKernelModules: nvidia_modeset nvidia
ApportVersion: 2.20.9-0ubuntu7.2
Architecture: amd64
CrashDB: ubuntu
CurrentDesktop: KDE
Date: Fri Aug 10 15:14:33 2018
InstallationDate: Installed on 2016-01-11 (941 days ago)
InstallationMedia: Kubuntu 14.04.3 LTS "Trusty Tahr" - Beta amd64 (20150805)
PackageArchitecture: allSourcePackage: ubuntu-release-upgrader
Symptom: release-upgrade
UpgradeStatus: Upgraded to bionic on 2018-08-09 (0 days ago)
mtime.conffile..etc.update-manager.release-upgrades: 2018-08-06T15:08:30.181962

Related branches

Revision history for this message
Carlo Wood (carlo-alinoe) wrote :
tags: added: xenial2bionic
tags: added: third-party-packages
Revision history for this message
Brian Murray (brian-murray) wrote :

The free space checks for /usr seem a bit strange:

2018-08-09 19:17:15,431 DEBUG Free space on /: 1110441984
2018-08-09 19:17:15,431 DEBUG Free space on /usr: 2819907584
2018-08-09 19:17:15,432 DEBUG Free space on /var: 3585171456
2018-08-09 19:17:15,432 DEBUG Free space on /boot: 301889536
2018-08-09 19:17:15,432 DEBUG Dir /var/cache/apt/archives mounted on /var
2018-08-09 19:17:15,432 DEBUG Free space on /tmp: 10716753920
2018-08-09 19:17:15,432 DEBUG Free space on /home: 2221584384
2018-08-09 19:17:15,432 DEBUG Dir /tmp mounted on /tmp
2018-08-09 19:17:15,432 DEBUG fs_free contains: '{'/': <DistUpgrade.DistUpgradeCache.MyCache.checkFreeSpace.<locals>.FreeSpace object at 0x7f9460e6bd30>, '/usr': <DistUpgrade.DistUpgradeCache.MyCache.checkFreeSpace.<locals>.FreeSpace object at 0x7f9460e6bd68>, '/var/cache/apt/archives': <DistUpgrade.DistUpgradeCache.MyCache.checkFreeSpace.<locals>.FreeSpace object at 0x7f9460e6beb8>, '/boot': <DistUpgrade.DistUpgradeCache.MyCache.checkFreeSpace.<locals>.FreeSpace object at 0x7f9460e6be10>, '/var': <DistUpgrade.DistUpgradeCache.MyCache.checkFreeSpace.<locals>.FreeSpace object at 0x7f9460e6beb8>, '/home': <DistUpgrade.DistUpgradeCache.MyCache.checkFreeSpace.<locals>.FreeSpace object at 0x7f9460e6bef0>, '/tmp': <DistUpgrade.DistUpgradeCache.MyCache.checkFreeSpace.<locals>.FreeSpace object at 0x7f9460e6bcf8>}'
2018-08-09 19:17:16,690 DEBUG linux-image-4.15.0-30-generic (new-install) added with 20705456 to boot space
2018-08-09 19:17:19,295 DEBUG dir '/var/cache/apt/archives' needs '3474732250' of '<DistUpgrade.DistUpgradeCache.MyCache.checkFreeSpace.<locals>.FreeSpace object at 0x7f9460e6beb8>' (3585171456.000000)
2018-08-09 19:17:19,296 DEBUG dir '/usr' needs '-3102259200' of '<DistUpgrade.DistUpgradeCache.MyCache.checkFreeSpace.<locals>.FreeSpace object at 0x7f9460e6bd68>' (2819907584.000000)
2018-08-09 19:17:19,296 DEBUG dir '/usr' needs '52428800' of '<DistUpgrade.DistUpgradeCache.MyCache.checkFreeSpace.<locals>.FreeSpace object at 0x7f9460e6bd68>' (5922166784.000000)
2018-08-09 19:17:19,296 DEBUG dir '/boot' needs '121070520.8' of '<DistUpgrade.DistUpgradeCache.MyCache.checkFreeSpace.<locals>.FreeSpace object at 0x7f9460e6be10>' (301889536.000000)
2018-08-09 19:17:19,296 DEBUG dir '/tmp' needs '5242880' of '<DistUpgrade.DistUpgradeCache.MyCache.checkFreeSpace.<locals>.FreeSpace object at 0x7f9460e6bcf8>' (10716753920.000000)
2018-08-09 19:17:19,296 DEBUG dir '/' needs '10485760' of '<DistUpgrade.DistUpgradeCache.MyCache.checkFreeSpace.<locals>.FreeSpace object at 0x7f9460e6bd30>' (1110441984.000000)
2018-08-09 19:17:19,296 DEBUG dir '/tmp' needs '0.0' of '<DistUpgrade.DistUpgradeCache.MyCache.checkFreeSpace.<locals>.FreeSpace object at 0x7f9460e6bcf8>' (10711511040.000000)
2018-08-09 19:17:19,296 DEBUG dir '/usr' needs '0.0' of '<DistUpgrade.DistUpgradeCache.MyCache.checkFreeSpace.<locals>.FreeSpace object at 0x7f9460e6bd68>' (5869737984.000000)

Could you provide some information regarding how your disk and partitions are setup? Thanks in advance!

Changed in ubuntu-release-upgrader (Ubuntu):
importance: Undecided → High
Changed in ubuntu-release-upgrader (Ubuntu):
status: New → Incomplete
Revision history for this message
Brian Murray (brian-murray) wrote :

Looking at the code it seems pretty obvious that we shouldn't use a negative number for the space needed in /usr.

summary: - Updater doesn't check size of partitions.
+ free space need for /usr could be negative which is wrong
Changed in ubuntu-release-upgrader (Ubuntu):
status: Incomplete → In Progress
assignee: nobody → Brian Murray (brian-murray)
Revision history for this message
Carlo Wood (carlo-alinoe) wrote :

Note sure if this is the info you wanted,

sean:~>df -h
Filesystem Size Used Avail Use% Mounted on
udev 16G 0 16G 0% /dev
tmpfs 3,2G 2,0M 3,2G 1% /run
/dev/sda5 2,3G 964M 1,2G 45% /
/dev/sda6 19G 16G 1,9G 90% /usr
tmpfs 16G 441M 16G 3% /dev/shm
tmpfs 5,0M 12K 5,0M 1% /run/lock
tmpfs 16G 0 16G 0% /sys/fs/cgroup
/dev/sdb3 56G 26G 27G 50% /SSD2
/dev/sda3 454M 162M 265M 38% /boot
/dev/sda7 9,1G 6,8G 1,8G 80% /usr/local
/dev/sda9 5,4G 2,5G 2,7G 48% /var
/dev/sdc1 148G 96G 45G 69% /usr/src
tmpfs 1,0G 11M 1014M 1% /var/tmp
tmpfs 10G 3,3M 10G 1% /tmp
/dev/mapper/ata-WDC_WD5003ABYZ-011FA0_WD-WMAYP0MAMT68-part2_crypt 311G 23G 273G 8% /encrypted
/dev/mapper/ata-WDC_WD40EFRX-68WT0N0_WD-WCC4E7CR9HX8-part1_crypt 433G 329G 83G 80% /opt
/dev/mapper/ata-WDC_WD40EFRX-68WT0N0_WD-WCC4E7CR9HX8-part2_crypt 3,2T 1,9T 1,2T 63% /opt/verylarge
/dev/mapper/ata-OCZ-VERTEX4_OCZ-5T94F27KZ830YPJT-part8_crypt 14G 12G 1,5G 89% /home
tmpfs 3,2G 28K 3,2G 1% /run/user/1000

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

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

---------------
ubuntu-release-upgrader (1:19.04.7) disco; urgency=medium

  [ Brian Murray ]
  * DistUpgrade/DistUpgradeCache.py: When calculating free space needed for
    mount points don't use a negative number as the buffer. (LP: #1786484)
  * fix more typos re RELEASE_UPRADER_ALLOW_THIRD_PARTY
  * DistUpgrade/DistUpgradeCache.py: When calculating free space needed for
    mount points don't use a negative number as the buffer. (LP: #1786484)
  * fix more typos re RELEASE_UPRADER_ALLOW_THIRD_PARTY
  * DistUpgrade/DistUpgradeController.py: When rewriting sources.list entries
    check to see if the source provides packages for the release to which the
    upgrade is occurring. If it doesn't the entry is disabled thereby
    improving upgrades with PPAs. (LP: #1807043)
  * do-release-upgrade: add a parameter to allow third party mirrors and
    repositories, additionally pass along the environmental variable
    RELEASE_UPGRADER_ALLOW_THIRD_PARTY via pkexec and sudo. (LP: #1807032)
  * DistUpgrade/DistUpgradeCache.py: improve messaging regarding failures to
    calculate the upgrade and suggest using ppa-purge if PPAs are an issue.
  * DistUpgrade/DistUpgradeCache.py: in the event there is a failure to
    calculate the upgrade provide information about the log files in
    /var/log/dist-upgrade. (LP: #1771387)

  [ Jeremy Bicha ]
  * autopkgtest: Update dependency from gir1.2-webkit-3.0 to gir1.2-webkit2-4.0

 -- Brian Murray <email address hidden> Tue, 11 Dec 2018 15:35:34 -0800

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 Carlo, or anyone else affected,

Accepted ubuntu-release-upgrader into cosmic-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/ubuntu-release-upgrader/1:18.10.11.3 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 ubuntu-release-upgrader (Ubuntu Cosmic):
status: New → Fix Committed
tags: added: verification-needed verification-needed-cosmic
Revision history for this message
Brian Murray (brian-murray) wrote :

I went ahead and tested an upgrade from Ubuntu 18.04 to Ubuntu 18.10 to ensure things still work as expected and the upgrade proceeded without any errors.

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

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

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

  * DistUpgrade/DistUpgradeCache.py: When calculating free space needed for
    mount points don't use a negative number as the buffer. (LP: #1786484)
  * fix more typos re RELEASE_UPRADER_ALLOW_THIRD_PARTY.
  * DistUpgrade/DistUpgradeController.py: When rewriting sources.list entries
    check to see if the source provides packages for the release to which the
    upgrade is occurring. If it doesn't the entry is disabled thereby
    improving upgrades with PPAs. (LP: #1807043)
  * do-release-upgrade: add a parameter to allow third party mirrors and
    repositories, additionally pass along the environmental variable
    RELEASE_UPGRADER_ALLOW_THIRD_PARTY via pkexec and sudo. (LP: #1807032)
  * DistUpgrade/DistUpgradeCache.py: improve messaging regarding failures to
    calculate the upgrade and suggest using ppa-purge if PPAs are an issue.
  * DistUpgrade/DistUpgradeCache.py: in the event there is a failure to
    calculate the upgrade provide information about the log files in
    /var/log/dist-upgrade. (LP: #1771387)
  * debian/source_ubuntu-release-upgrader.py: Include xorg_fixup.log if it
    exists.
  * DistUpgrade/xorg_fix_proprietary.py: modify how the system is checked to
    see if nvidia is being used, drop fglrx check since it has been
    deprecated. (LP: #1773637)

 -- Brian Murray <email address hidden> Thu, 20 Dec 2018 12:31:37 -0800

Changed in ubuntu-release-upgrader (Ubuntu Cosmic):
status: Fix Committed → Fix Released
Revision history for this message
Chris Halse Rogers (raof) 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.

Revision history for this message
Łukasz Zemczak (sil2100) wrote : Please test proposed package

Hello Carlo, 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.30 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 ubuntu-release-upgrader (Ubuntu Bionic):
status: New → Fix Committed
tags: added: verification-needed verification-needed-bionic
removed: verification-done
Revision history for this message
Brian Murray (brian-murray) wrote :

I went ahead and tested an upgrade from Ubuntu 16.04 to Ubuntu 18.04 to ensure things still work as expected and the upgrade proceeded without any errors.

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.30

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

  * data/release-upgrades: Clarify documentation regarding the behavior for
    different Prompt settings. (LP: #1795024)
  * do-release-upgrade: Utilize information regarding what Prompt is set to so
    that a more informative error message can be displayed.
    (LP: #1798618, LP: #1795024)
  * DistUpgrade/DistUpgradeCache.py: When calculating free space needed for
    mount points don't use a negative number as the buffer. (LP: #1786484)
  * fix more typos re RELEASE_UPRADER_ALLOW_THIRD_PARTY
  * DistUpgrade/DistUpgradeController.py: When rewriting sources.list entries
    check to see if the source provides packages for the release to which the
    upgrade is occurring. If it doesn't the entry is disabled thereby
    improving upgrades with PPAs. (LP: #1807043)
  * do-release-upgrade: add a parameter to allow third party mirrors and
    repositories, additionally pass along the environmental variable
    RELEASE_UPGRADER_ALLOW_THIRD_PARTY via pkexec and sudo. (LP: #1807032)
  * DistUpgrade/DistUpgradeCache.py: improve messaging regarding failures to
    calculate the upgrade and suggest using ppa-purge if PPAs are an issue.
  * DistUpgrade/DistUpgradeCache.py: in the event there is a failure to
    calculate the upgrade provide information about the log files in
    /var/log/dist-upgrade. (LP: #1771387)
  * debian/source_ubuntu-release-upgrader.py: Include xorg_fixup.log if it
    exists.
  * DistUpgrade/xorg_fix_proprietary.py: modify how the system is checked to
    see if nvidia is being used, drop fglrx check since it has been
    deprecated. (LP: #1773637)

 -- Brian Murray <email address hidden> Wed, 16 Jan 2019 15:53:58 -0800

Changed in ubuntu-release-upgrader (Ubuntu Bionic):
status: Fix Committed → Fix Released
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.