From 18d0fdd0dddb8b6fa5c6262e5cc7a71255bba5bf Mon Sep 17 00:00:00 2001 From: Zongheng Yang Date: Mon, 28 Nov 2022 07:49:00 +0800 Subject: [PATCH] Print errors for GCP timeout. --- sky/authentication.py | 5 +++++ sky/utils/common_utils.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/sky/authentication.py b/sky/authentication.py index a6d1008bcc4..0e2a9158907 100644 --- a/sky/authentication.py +++ b/sky/authentication.py @@ -3,6 +3,7 @@ import functools import os import re +import socket import subprocess import sys import textwrap @@ -174,6 +175,10 @@ def setup_gcp_authentication(config: Dict[str, Any]) -> Dict[str, Any]: sys.exit(1) else: raise + except socket.timeout: + logger.error('Socket timed out when trying to get the GCP project. ' + 'Please check your network connection.') + raise project_oslogin = next( (item for item in project['commonInstanceMetadata'].get('items', []) diff --git a/sky/utils/common_utils.py b/sky/utils/common_utils.py index fe320800a7e..df6ea4d11e1 100644 --- a/sky/utils/common_utils.py +++ b/sky/utils/common_utils.py @@ -246,9 +246,9 @@ def method_with_retries(*args, **kwargs): try: return method(*args, **kwargs) except Exception as e: # pylint: disable=broad-except - logger.warning(f'Caught {e}. Retrying.') try_count += 1 if try_count < max_retries: + logger.warning(f'Caught {e}. Retrying.') time.sleep(backoff.current_backoff()) else: raise