diff options
author | Helmut Grohne <helmut@subdivi.de> | 2019-08-01 10:12:37 +0200 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2019-08-01 10:12:37 +0200 |
commit | f93b427b821a0ee9021ea3ddf02894eccb669f2c (patch) | |
tree | 7c8d53baa2c996a8648431670104716bd17debc4 | |
parent | 330fe08852dd954f60f17fa04a06d00d3a15be74 (diff) | |
download | crossqa-f93b427b821a0ee9021ea3ddf02894eccb669f2c.tar.gz |
build.py: handle errors from ssh in a better way
Previously, it would retry immediately and produce empty log files
marked as failures. When ssh fails, we no longer record a build nor log.
We also wait a little before retrying.
-rwxr-xr-x | build.py | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -31,12 +31,17 @@ def do_build(source, version, architecture, server): now.strftime("%Y%m%d%H%M%S")) cmdline = ["ssh", server, "sh", "/dev/stdin", architecture, "%s_%s" % (source, version)] - with open(os.path.join("logs", logtarget), "w+b") as output: + logname = os.path.join("logs", logtarget) + with open(logname, "w+b") as output: with open("build.sh", "rb") as instructions: code = subprocess.call(cmdline, stdin=instructions, stdout=output) output.seek(0) status = scan_log_status(output) - print("status %s code %d" % (status, code)) + if code == 255: + os.unlink(logname) + time.sleep(300) + raise RuntimeError("ssh failed") + print("status %s code %d" % (status, code)) return (now, code == 0, logtarget, status == "given-back") def main(): |