check_mirroring: Retry automatically on 'Detected server failure' errors.

(imported from commit 2f834218bd492876749dd8953e522725935a7a1d)
This commit is contained in:
Tim Abbott 2012-12-10 13:37:50 -05:00
parent d451cf3dc0
commit 69c1b8beca

View file

@ -106,11 +106,16 @@ def send_humbug(message):
logger.error(result) logger.error(result)
print_status_and_exit(1) print_status_and_exit(1)
def send_zephyr(zwrite_args, content): def send_zephyr(zwrite_args, content, retry=False):
p = subprocess.Popen(zwrite_args, stdin=subprocess.PIPE, p = subprocess.Popen(zwrite_args, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p.communicate(input=content.encode("utf-8")) stdout, stderr = p.communicate(input=content.encode("utf-8"))
if p.returncode != 0: if p.returncode != 0:
if not retry and "Detected server failure while receiving acknowledgement for" in stderr:
logger.warning("Got server failure error sending zephyr; retrying")
logger.warning(stderr)
# Retry sending the message rather than bailing.
return send_zephyr(zwrite_args, content, True)
logger.error("Error sending zephyr:") logger.error("Error sending zephyr:")
logger.info(stdout) logger.info(stdout)
logger.error(stderr) logger.error(stderr)