From 2c7d530da441f27cb9156337b66e0a88811b96f8 Mon Sep 17 00:00:00 2001 From: Andrew Aikawa Date: Wed, 27 Nov 2024 06:35:02 +0000 Subject: [PATCH] fix missing do credential for CI --- sky/clouds/do.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sky/clouds/do.py b/sky/clouds/do.py index c92023a5c05..368824d1bbd 100644 --- a/sky/clouds/do.py +++ b/sky/clouds/do.py @@ -258,20 +258,22 @@ def check_credentials(cls) -> Tuple[bool, Optional[str]]: """Verify that the user has valid credentials for DO.""" try: # attempt to make a CURL request for listing instances - do_utils.client().droplets.list() + client = do_utils.client() + if client is None: + return False, "no valid credentials found, run `doctl auth init`" + client.droplets.list() except do.exceptions().HttpResponseError as err: return False, str(err) return True, None def get_credential_file_mounts(self) -> Dict[str, str]: - try: - do_utils.client() # to initialize `do_utils.CREDENTIALS_PATH` + client = do_utils.client() # to initialize `do_utils.CREDENTIALS_PATH` + if client is not None: return { f'~/.config/doctl/{_CREDENTIAL_FILE}': do_utils.CREDENTIALS_PATH } - except do_utils.DigitalOceanError as err: - logger.debug(err) + else: return {} @classmethod