Permalink
Browse files

ping() should provide details on SSH failure

  • Loading branch information...
1 parent c5dea68 commit 97b74408727a4905dbcff516d90dbff95d184210 @lirazsiri lirazsiri committed Aug 5, 2011
Showing with 9 additions and 10 deletions.
  1. +5 −3 cloudtask/executor.py
  2. +4 −7 cloudtask/ssh.py
@@ -114,7 +114,7 @@ def __init__(self, session, taskconf, address=None, destroy=None, event_stop=Non
login_name=taskconf.user,
callback=self.handle_stop)
except SSH.Error, e:
- self.status("ssh error: " + str(e))
+ self.status("unreachable via ssh: " + str(e))
traceback.print_exc(file=self.wlog)
raise self.Error(e)
@@ -190,9 +190,11 @@ def handler(ssh_command, buf):
return
if read_timeout.expired():
- if not self.ssh.is_alive():
+ try:
+ self.ssh.ping()
+ except self.ssh.Error, e:
ssh_command.terminate()
- self.status("worker died # %s" % command)
+ self.status("worker died (%s) # %s" % (e, command))
raise SSH.TimeoutError
read_timeout.reset()
View
@@ -79,17 +79,14 @@ def __init__(self, address,
self.login_name = login_name
self.callback = callback
- if not self.is_alive():
- raise self.Error("%s is unreachable via ssh" % address)
+ self.ping()
- def is_alive(self, timeout=TIMEOUT):
+ def ping(self, timeout=TIMEOUT):
command = self.command('true')
try:
command.close(timeout)
- except (command.TimeoutError, command.Error):
- return False
-
- return True
+ except (command.TimeoutError, command.Error), e:
+ raise self.Error(str(e).strip())
def command(self, command, pty=False):
return self.Command(self.address, command,

0 comments on commit 97b7440

Please sign in to comment.