curtin exit codes broken by collect_logs misuse of sys.exit

Bug #1751176 reported by Ryan Harper
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
curtin
Fix Released
Undecided
Unassigned
curtin (Ubuntu)
Fix Released
High
Ryan Harper

Bug Description

Currently any invocation of curtin that incurs an exception during the 'install' phase will trigger a path which runs the error log collection code.

THere's a bug there which runs sys.exit() in the non-main body of the code; Instead only subcommands _main_ methods should use sys.exit(); the collection method (create_log_tarfile) need only return.

 % git diff
diff --git a/curtin/commands/collect_logs.py b/curtin/commands/collect_logs.py
index a61d91e..2078f37 100644
--- a/curtin/commands/collect_logs.py
+++ b/curtin/commands/collect_logs.py
@@ -48,6 +48,7 @@ def collect_logs_main(args):
                 SAVE_INSTALL_CONFIG, CURTIN_PACK_CONFIG_DIR))
         cfg = CONFIG_BUILTIN.copy()
     create_log_tarfile(args.output, cfg)
+ sys.exit(0)

 def create_log_tarfile(tarfile, config):
@@ -104,7 +105,7 @@ def create_log_tarfile(tarfile, config):
         if os.path.exists(tmp_dir):
             shutil.rmtree(tmp_dir)
     sys.stderr.write('Wrote: %s\n' % tarfile)
- sys.exit(0)
+ return

ProblemType: Bug
DistroRelease: Ubuntu 18.04
Package: curtin 17.1-37-g82622f12-0ubuntu1
ProcVersionSignature: Ubuntu 4.13.0-32.35~16.04.1-generic 4.13.13
Uname: Linux 4.13.0-32-generic x86_64
ApportVersion: 2.20.8-0ubuntu10
Architecture: amd64
Date: Fri Feb 23 02:00:28 2018
PackageArchitecture: all
ProcEnviron:
 TERM=xterm-256color
 PATH=(custom, no user)
 LANG=C.UTF-8
SourcePackage: curtin
UpgradeStatus: No upgrade log present (probably fresh install)

Related branches

Revision history for this message
Ryan Harper (raharper) wrote :
Scott Moser (smoser)
Changed in curtin (Ubuntu):
status: New → Confirmed
importance: Undecided → High
assignee: nobody → Ryan Harper (raharper)
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package curtin - 17.1-40-g46f8000f-0ubuntu1

---------------
curtin (17.1-40-g46f8000f-0ubuntu1) bionic; urgency=medium

  * New upstream snapshot.
    - clear_holders: wipe complex devices before disassembly (LP: #1750519)
    - vmtests: network_mtu: fix bug number and move date out one month
    - fix /usr/bin/curtin exit code in install failure (LP: #1751176)

 -- Scott Moser <email address hidden> Wed, 07 Mar 2018 02:55:23 -0500

Changed in curtin (Ubuntu):
status: Confirmed → Fix Released
Revision history for this message
Scott Moser (smoser) wrote : Fixed in Cloud-init 18.1

This bug is believed to be fixed in curtin in 18.1. If this is still a problem for you, please make a comment and set the state back to New

Thank you.

Changed in curtin:
status: New → 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.