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
1=== modified file 'lib/devscripts/ec2test/instance.py'
2--- lib/devscripts/ec2test/instance.py 2009-10-23 20:12:27 +0000
3+++ lib/devscripts/ec2test/instance.py 2009-11-23 20:45:28 +0000
4@@ -402,6 +402,9 @@
5 :param args: Passed to `func`.
6 :param kw: Passed to `func`.
7 """
8+ # We ignore the value of the 'shutdown' argument and always shut down
9+ # unless `func` returns normally.
10+ really_shutdown = True
11 try:
12 self.start()
13 try:
14@@ -412,6 +415,8 @@
15 # (in the finally block), and you can't figure out why it's
16 # broken.
17 traceback.print_exc()
18+ else:
19+ really_shutdown = shutdown
20 finally:
21 try:
22 if postmortem:
23@@ -420,7 +425,7 @@
24 postmortem_banner % {'dns': self.hostname})
25 print 'Postmortem console closed.'
26 finally:
27- if shutdown:
28+ if really_shutdown:
29 self.shutdown()
30
31 def _copy_single_file(self, sftp, local_path, remote_dir):