[Bug 1882069] Re: DistUpgradeController.py key 'devRelease' not set correctly

Łukasz Zemczak 1882069 at bugs.launchpad.net
Mon Jul 20 23:32:58 UTC 2020


Hello Marcel, or anyone else affected,

Accepted ubuntu-release-upgrader into focal-proposed. The package will
build now and be available at https://launchpad.net/ubuntu/+source
/ubuntu-release-upgrader/1:20.04.22 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, what testing has been
performed on the package and change the tag from verification-needed-
focal to verification-done-focal. If it does not fix the bug for you,
please add a comment stating that, and change the tag to verification-
failed-focal. 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 Focal)
       Status: In Progress => Fix Committed

** Tags added: verification-needed verification-needed-focal

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

Title:
  DistUpgradeController.py key 'devRelease' not set correctly

Status in ubuntu-release-upgrader package in Ubuntu:
  Fix Released
Status in ubuntu-release-upgrader source package in Focal:
  Fix Committed

Bug description:
  Test Case
  ---------
  1) run do-release-upgrade
  2) cancel the upgrade 
  3) cd /tmp/ubuntu-release-upgrader-$TMPDIR
  4) edit DistUpgrade/DistUpgradeCache.py line 647 or so (immediately after self._verifyChanges()) and add 'raise SystemError' this will simulate a failure to calculate the upgrade. [It's easier than installing packages which will cause the upgrade to fail.]
  5) run 'sudo ./focal --frontend DistUpgradeViewGtk'

  Observe a traceback which ends with "configparser.NoOptionError: No
  option 'devrelease' in section: 'Options'" Because no options are
  passed to the release upgrader devRelease is not set which causes the
  traceback.

  With the version of the release upgrader from -proposed you will still
  need to edit DistUpgradeCache.py but will not encounter a Traceback.

  Original Description
  --------------------
  I encountered this bug when execution do-release-upgrade on an Ubuntu 19.10 machine.
  The release upgrade crashed ungracefully not calling abort() which should rollback all changes up to that point.
  So I ended up with kind of a broken packages and configuration hell on my server machine.
  I finally was able to perform the release upgrade by using apt / dpkg manually and resolving package dependencies and conflicts by hand.

  The bug is on actually two places:

  DistUpgradeController.py (parameter devRelease not set at all due to
  wrong indendation of else block)

  DistUpgradeCache.py (using unsafe code within except block: accessing
  undefined key 'devRelease' and provoke KeyError)

  In general: the idea of except or catch or whatever is not just
  execute different code logic in case of exception. It is about doing
  the most basic stuff in case anything goes wrong (which should be as
  exception (error) safe as possible)

  Bad practice:

  try
    doSomething();
  catch exception
    ignoreException();
    doSomethingElse();

  Good practice:

  try
    doSomethingUnsafe();
  catch exception e
    logAndHandleException(e);
    useAnotherTryIfAdditionalLogicIsRequired();

  That kind of bad structure costed me 1 day of error analysis (I am not
  a python guy) and another 1 day to revert the things from the failed
  upgrade.

  The bugs:

  Since I can not find any source code git repository, the next lines target the python module which can be  found in /usr/lib/python3/dist-packages/DistUpgrade (Ubuntu 19.10 / Ubuntu 20.04 LTS)
  (line numbers may differ)

  Major Bug:

  DistUpgradeController.py:138-139 (wrong indentation of else block)

  Current:
          if self.options:
              if self.options.devel_release:
                  self.config.set("Options","devRelease", "True")
          else:
              self.config.set("Options","devRelease", "False")

  Should be:

          if self.options:
              if self.options.devel_release:
                  self.config.set("Options","devRelease", "True")
              else:
                  self.config.set("Options","devRelease", "False")

  Minor Bug:

  DistUpgradeCache.py:651-694 (except block)

  Error arised in lines 667-668

              elif self.config.get("Options", "foreignPkgs") == "False" and \
                  self.config.get("Options", "devRelease") == "True":

  cause "devRelease" was not set on "Options" (see Major bug)
  except block should not excecute unsafe code cause its job is error handling and roll back.
  please make the entire block more fail safe (also use additional "try" if neccessary)
  Since it seems like that accessing keys in python is not safe (reminds me of javascript)
  it should be always checked if the key does even exist before accessing it.

  Thanks for taking care of that.

  Edit: I found the attachment feature after writing this report so
  please find the DistUpgradeController.py attached containing the major
  bug.

  Please keep me up to date
  marcel.sachtleben at snoobeam.com

  Best Regards

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/ubuntu-release-upgrader/+bug/1882069/+subscriptions



More information about the foundations-bugs mailing list