]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
task/restart: Handle error from script correctly
authorSam Lang <sam.lang@inktank.com>
Tue, 19 Mar 2013 13:08:05 +0000 (08:08 -0500)
committerSam Lang <sam.lang@inktank.com>
Tue, 19 Mar 2013 13:10:30 +0000 (08:10 -0500)
The exitstatus on the process is a gevent.AsyncResult
(not an int).  Use the try/except pattern for handling
errors instead.

Signed-off-by: Sam Lang <sam.lang@inktank.com>
teuthology/task/restart.py

index 6799c4e96b9da903a8515f161acca96abad2cd7c..baacb223eb9223b1fc0c2311ffcc679571d7d0c2 100644 (file)
@@ -143,10 +143,10 @@ def task(ctx, config):
                     restart_daemon(ctx, config, cmd[1], cmd[2], *cmd[3:])
                     proc.stdin.writelines(['restarted\n'])
                     proc.stdin.flush()
-                tor.wait([proc])
-                e = proc.exitstatus
-                if e != 0:
-                    raise Exception('restart task got non-zero exit status {d} from script: {s}'.format(d=e, s=c))
+                try:
+                    proc.exitstatus.get()
+                except tor.CommandFailedError:
+                    raise Exception('restart task got non-zero exit status from script: {s}'.format(s=c))
     finally:
         log.info('Finishing %s on %s...', task, role)
         remote.run(