Browse files

Fix args to _cleanup_jobs() and improve logging

  • Loading branch information...
1 parent 00b4b55 commit 19339b770a2a9ffc36e6e9d3470b5f550d3dcda2 Steve Johnson committed Jun 26, 2012
Showing with 11 additions and 5 deletions.
  1. +8 −2 mrjob/emr.py
  2. +3 −3 tests/test_emr.py
View
10 mrjob/emr.py
@@ -1265,7 +1265,7 @@ def _cleanup_logs(self):
except Exception, e:
log.exception(e)
- def _cleanup_jobs(self, mode):
+ def _cleanup_jobs(self):
# kill the job if we won't be taking down the whole job flow
if not (self._emr_job_flow_id or
self._opts['emr_job_flow_id'] or
@@ -1279,10 +1279,16 @@ def _cleanup_jobs(self, mode):
'flow %s".' % self._emr_job_flow_id)
try:
- ssh_terminate_single_job(
+ log.info("Attempting to terminate job...")
+ had_job = ssh_terminate_single_job(
self._opts['ssh_bin'],
self._address_of_master(),
self._opts['ec2_key_pair_file'])
+ if had_job:
+ log.info("Succeeded in terminating job")
+ else:
+ log.info("Job appears to have already been terminated")
+
except SSHException:
log.info(error_msg)
except IOError:
View
6 tests/test_emr.py
@@ -2850,7 +2850,7 @@ def test_job_cleanup_mechanics_succeed(self):
r._emr_job_flow_id = 'kevin'
r._address = 'Albuquerque, NM'
with patch.object(mrjob.emr, 'ssh_terminate_single_job') as m:
- r._cleanup_jobs('JOB')
+ r._cleanup_jobs()
self.assertTrue(m.called)
m.assert_any_call(['ssh'], 'Albuquerque, NM', None)
@@ -2866,7 +2866,7 @@ def die_ssh(*args, **kwargs):
log_to_stream('mrjob.emr', stderr)
with patch.object(mrjob.emr, 'ssh_terminate_single_job',
side_effect=die_ssh):
- r._cleanup_jobs('JOB')
+ r._cleanup_jobs()
self.assertIn('Unable to kill job', stderr.getvalue())
def test_job_cleanup_mechanics_io_fail(self):
@@ -2881,5 +2881,5 @@ def die_io(*args, **kwargs):
side_effect=die_io):
stderr = StringIO()
log_to_stream('mrjob.emr', stderr)
- r._cleanup_jobs('JOB')
+ r._cleanup_jobs()
self.assertIn('Unable to kill job', stderr.getvalue())

0 comments on commit 19339b7

Please sign in to comment.