From feb1b1843571bf7e5b6fb54af21a7b98c20060e8 Mon Sep 17 00:00:00 2001 From: Zhanghao Wu Date: Thu, 24 Aug 2023 09:26:58 -0700 Subject: [PATCH 1/6] [AWS] Add identity info when check fails --- sky/clouds/aws.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sky/clouds/aws.py b/sky/clouds/aws.py index f8b67e58c39..8dd050d6da0 100644 --- a/sky/clouds/aws.py +++ b/sky/clouds/aws.py @@ -441,7 +441,7 @@ def check_credentials(cls) -> Tuple[bool, Optional[str]]: # Checks if AWS credentials 1) exist and 2) are valid. # https://stackoverflow.com/questions/53548737/verify-aws-credentials-with-boto3 try: - cls.get_current_user_identity() + identity = cls.get_current_user_identity() except exceptions.CloudUserIdentityError as e: return False, str(e) @@ -486,9 +486,10 @@ def check_credentials(cls) -> Tuple[bool, Optional[str]]: aws_catalog.get_default_instance_type() except RuntimeError as e: return False, ( - 'Failed to fetch the availability zones for the account. It is ' - 'likely due to permission issues, please check the minimal ' - 'permission required for AWS: https://skypilot.readthedocs.io/en/latest/cloud-setup/cloud-permissions/aws.html' # pylint: disable= + 'Failed to fetch the availability zones for the account ' + f'{identity}. It is likely due to permission issues, please ' + 'check the minimal permission required for AWS: ' + 'https://skypilot.readthedocs.io/en/latest/cloud-setup/cloud-permissions/aws.html' # pylint: disable= f'\n{cls._INDENT_PREFIX}Details: ' f'{common_utils.format_exception(e, use_bracket=True)}') return True, hints From ae62f0c1e3639d1878d3e60a33c632eea9bfc095 Mon Sep 17 00:00:00 2001 From: Zhanghao Wu Date: Thu, 24 Aug 2023 09:32:51 -0700 Subject: [PATCH 2/6] More observebility --- sky/clouds/service_catalog/data_fetchers/fetch_aws.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sky/clouds/service_catalog/data_fetchers/fetch_aws.py b/sky/clouds/service_catalog/data_fetchers/fetch_aws.py index 006e9608c69..78e4def0f29 100644 --- a/sky/clouds/service_catalog/data_fetchers/fetch_aws.py +++ b/sky/clouds/service_catalog/data_fetchers/fetch_aws.py @@ -136,7 +136,8 @@ def _get_availability_zones(region: str) -> Optional[pd.DataFrame]: 'Failed to retrieve availability zone. ' 'Please ensure that the `ec2:DescribeAvailabilityZones` ' 'action is enabled for your AWS account in IAM. ' - 'Ref: https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeAvailabilityZones.html' # pylint: disable=line-too-long + 'Ref: https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeAvailabilityZones.html.\n' # pylint: disable=line-too-long + f'Details: {e}' ) from None else: raise From 316b667484616867820148d5770521e1d47b94b3 Mon Sep 17 00:00:00 2001 From: Zhanghao Wu Date: Thu, 24 Aug 2023 09:40:04 -0700 Subject: [PATCH 3/6] format --- sky/clouds/service_catalog/data_fetchers/fetch_aws.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sky/clouds/service_catalog/data_fetchers/fetch_aws.py b/sky/clouds/service_catalog/data_fetchers/fetch_aws.py index 78e4def0f29..acccb0c6416 100644 --- a/sky/clouds/service_catalog/data_fetchers/fetch_aws.py +++ b/sky/clouds/service_catalog/data_fetchers/fetch_aws.py @@ -137,8 +137,7 @@ def _get_availability_zones(region: str) -> Optional[pd.DataFrame]: 'Please ensure that the `ec2:DescribeAvailabilityZones` ' 'action is enabled for your AWS account in IAM. ' 'Ref: https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeAvailabilityZones.html.\n' # pylint: disable=line-too-long - f'Details: {e}' - ) from None + f'Details: {e}') from None else: raise for resp in response['AvailabilityZones']: From e40011a17db1654d95db772a8897758fbf1bdcfe Mon Sep 17 00:00:00 2001 From: Zhanghao Wu Date: Thu, 24 Aug 2023 09:46:13 -0700 Subject: [PATCH 4/6] Update sky/clouds/service_catalog/data_fetchers/fetch_aws.py Co-authored-by: Zongheng Yang --- sky/clouds/service_catalog/data_fetchers/fetch_aws.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sky/clouds/service_catalog/data_fetchers/fetch_aws.py b/sky/clouds/service_catalog/data_fetchers/fetch_aws.py index acccb0c6416..c6c1d9eb0bf 100644 --- a/sky/clouds/service_catalog/data_fetchers/fetch_aws.py +++ b/sky/clouds/service_catalog/data_fetchers/fetch_aws.py @@ -133,7 +133,7 @@ def _get_availability_zones(region: str) -> Optional[pd.DataFrame]: elif e.response['Error']['Code'] == 'UnauthorizedOperation': with ux_utils.print_exception_no_traceback(): raise RuntimeError( - 'Failed to retrieve availability zone. ' + 'Failed to retrieve availability zones. ' 'Please ensure that the `ec2:DescribeAvailabilityZones` ' 'action is enabled for your AWS account in IAM. ' 'Ref: https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeAvailabilityZones.html.\n' # pylint: disable=line-too-long From d82df7ad7502c530f5211f8dbd30ff64746cafbb Mon Sep 17 00:00:00 2001 From: Zhanghao Wu Date: Thu, 24 Aug 2023 09:47:55 -0700 Subject: [PATCH 5/6] address comments --- sky/clouds/service_catalog/data_fetchers/fetch_aws.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sky/clouds/service_catalog/data_fetchers/fetch_aws.py b/sky/clouds/service_catalog/data_fetchers/fetch_aws.py index acccb0c6416..a08b68fec02 100644 --- a/sky/clouds/service_catalog/data_fetchers/fetch_aws.py +++ b/sky/clouds/service_catalog/data_fetchers/fetch_aws.py @@ -14,6 +14,7 @@ import pandas as pd from sky.adaptors import aws +from sky.utils import common_utils from sky.utils import ux_utils # Enable most of the regions. Each user's account may have a subset of these @@ -137,7 +138,9 @@ def _get_availability_zones(region: str) -> Optional[pd.DataFrame]: 'Please ensure that the `ec2:DescribeAvailabilityZones` ' 'action is enabled for your AWS account in IAM. ' 'Ref: https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeAvailabilityZones.html.\n' # pylint: disable=line-too-long - f'Details: {e}') from None + 'Details: ' + f'{common_utils.format_exception(e, use_bracket=True)}' + ) from None else: raise for resp in response['AvailabilityZones']: From 016a74bfae16af38af6852859a31d7ad0c55bda4 Mon Sep 17 00:00:00 2001 From: Zhanghao Wu Date: Thu, 24 Aug 2023 10:18:38 -0700 Subject: [PATCH 6/6] logging --- sky/clouds/service_catalog/data_fetchers/fetch_aws.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sky/clouds/service_catalog/data_fetchers/fetch_aws.py b/sky/clouds/service_catalog/data_fetchers/fetch_aws.py index 0b8e6e2a2a6..5e976aab57c 100644 --- a/sky/clouds/service_catalog/data_fetchers/fetch_aws.py +++ b/sky/clouds/service_catalog/data_fetchers/fetch_aws.py @@ -137,8 +137,7 @@ def _get_availability_zones(region: str) -> Optional[pd.DataFrame]: 'Failed to retrieve availability zones. ' 'Please ensure that the `ec2:DescribeAvailabilityZones` ' 'action is enabled for your AWS account in IAM. ' - 'Ref: https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeAvailabilityZones.html.\n' # pylint: disable=line-too-long - 'Details: ' + 'Ref: https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeAvailabilityZones.html.' # pylint: disable=line-too-long f'{common_utils.format_exception(e, use_bracket=True)}' ) from None else: