Merge lp:~mwhudson/launchpad/ec2-test-shutdown-if-setup-fails into lp:launchpad

Proposed by Michael Hudson-Doyle
Status: Merged
Approved by: Michael Hudson-Doyle
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~mwhudson/launchpad/ec2-test-shutdown-if-setup-fails
Merge into: lp:launchpad
Diff against target: 31 lines (+6/-1)
1 file modified
lib/devscripts/ec2test/instance.py (+6/-1)
To merge this branch: bzr merge lp:~mwhudson/launchpad/ec2-test-shutdown-if-setup-fails
Reviewer Review Type Date Requested Status
Tim Penhey (community) Approve
Review via email: mp+15138@code.launchpad.net

Commit message

In EC2Instance.set_up_and_run, only pay attention to the 'shutdown' argument if the supplied function exits normally

To post a comment you must log in.
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

EC2Instance.set_up_and_run leaves the instance running when shutdown is false even if the setup of the instance fails. That's not very sensible. This branch changes it to only respect the 'shutdown' argument if instance setup and running the function completes normally

Revision history for this message
Tim Penhey (thumper) wrote :

> # We ignore the value of the 'shutdown' argument and always shut down
> # unless `func` returns nromally.

s/nromally/normally/

Apart from that, r=me

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/devscripts/ec2test/instance.py'
--- lib/devscripts/ec2test/instance.py 2009-10-23 20:12:27 +0000
+++ lib/devscripts/ec2test/instance.py 2009-11-23 20:45:28 +0000
@@ -402,6 +402,9 @@
402 :param args: Passed to `func`.402 :param args: Passed to `func`.
403 :param kw: Passed to `func`.403 :param kw: Passed to `func`.
404 """404 """
405 # We ignore the value of the 'shutdown' argument and always shut down
406 # unless `func` returns normally.
407 really_shutdown = True
405 try:408 try:
406 self.start()409 self.start()
407 try:410 try:
@@ -412,6 +415,8 @@
412 # (in the finally block), and you can't figure out why it's415 # (in the finally block), and you can't figure out why it's
413 # broken.416 # broken.
414 traceback.print_exc()417 traceback.print_exc()
418 else:
419 really_shutdown = shutdown
415 finally:420 finally:
416 try:421 try:
417 if postmortem:422 if postmortem:
@@ -420,7 +425,7 @@
420 postmortem_banner % {'dns': self.hostname})425 postmortem_banner % {'dns': self.hostname})
421 print 'Postmortem console closed.'426 print 'Postmortem console closed.'
422 finally:427 finally:
423 if shutdown:428 if really_shutdown:
424 self.shutdown()429 self.shutdown()
425430
426 def _copy_single_file(self, sftp, local_path, remote_dir):431 def _copy_single_file(self, sftp, local_path, remote_dir):