From 3eb2e2ab90f547c37dff43645ca82bb043b2bcaa Mon Sep 17 00:00:00 2001 From: Ankush Agarwal Date: Wed, 13 Jun 2018 10:52:28 -0700 Subject: [PATCH] Retry on ssl.SSLError in vm_util - this resolves test flakiness (#987) * Handle ssl.SSLError in vm_util This causes test flakiness * Update --- testing/vm_util.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/testing/vm_util.py b/testing/vm_util.py index 2f4a85eff73..10ad3120bcb 100644 --- a/testing/vm_util.py +++ b/testing/vm_util.py @@ -3,6 +3,7 @@ import datetime import logging import os +import ssl import subprocess import time import uuid @@ -37,13 +38,16 @@ def wait_for_operation(client, """ endtime = datetime.datetime.now() + timeout while True: - if zone: - op = client.zoneOperations().get( - project=project, zone=zone, operation=op_id).execute() - else: - op = client.globalOperations().get(project=project, - operation=op_id).execute() - + try: + if zone: + op = client.zoneOperations().get( + project=project, zone=zone, operation=op_id).execute() + else: + op = client.globalOperations().get(project=project, + operation=op_id).execute() + except ssl.SSLError as e: + logging.error("Ignoring error %s", e) + continue status = op.get("status", "") # Need to handle other status's if status == "DONE": @@ -97,4 +101,4 @@ def execute_script(project, zone, vm, script): script, target, "--zone=" + zone]) util.run(["gcloud", "compute", "--project=" + project, "ssh", - "--zone=" + zone, vm, "--", "chmod a+rx " + target_path + " && " + target_path]) \ No newline at end of file + "--zone=" + zone, vm, "--", "chmod a+rx " + target_path + " && " + target_path])