-
Notifications
You must be signed in to change notification settings - Fork 536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[UX] warning before launching jobs/serve when using a reauth required credentials #4479
base: master
Are you sure you want to change the base?
Conversation
sky/clouds/aws.py
Outdated
def can_credential_expire(self) -> bool: | ||
"""Check if the AWS identity type can expire.""" | ||
expirable_types = { | ||
AWSIdentityType.SSO, AWSIdentityType.ENV, AWSIdentityType.IAM_ROLE, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are IAM_ROLE and ENV guaranteed to be expirable? Is there some quick command we can run to check if credentials are expiring instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accordig to https://d-926790655e.awsapps.com/start/#/?tab=accounts
IAM_ROLE has a longer validity period after configed by aws confirure sso
.
sky/clouds/aws.py
Outdated
expirable_types = { | ||
AWSIdentityType.SSO, AWSIdentityType.IAM_ROLE, | ||
AWSIdentityType.CONTAINER_ROLE | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure these credential types are expiring? We may want to use a CLI command to check expiry of credentials. e.g., claude tells me to use sts get-session-token --query 'Credentials.Expiration'
, but we should double check if these actually work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for gcloud CLI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition, we may want to trigger the CLI check only if IdentityType is one of AWSIdentityType.SSO, AWSIdentityType.IAM_ROLE, AWSIdentityType.CONTAINER_ROLE
. We may also want to use it with functools.lru_cache()
.
This is because CLI check can be expensive and we don't want to slow down sky jobs launch
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
claude result is not correct
~/skypilot on dev/hong/controller wip > aws sts get-session-token --query 'Credentials.Expiration' py sky at 16:28:58
An error occurred (AccessDenied) when calling the GetSessionToken operation: Cannot call GetSessionToken with session credentials
we can find session infos from ~/.aws/sso/cache/*json
~/skypilot on dev/hong/controller wip > cat ~/.aws/sso/cache/ 254 py sky at 16:29:05
7505d64a54e061b7acd54ccd58b49dc43500b635.json d45209530cbfb256d65dc516ece32996c9054fed.json
Each sso login will generate two json files, one is aws_sso_credentials.json
the other is sso_cache.json
in any of the file we can find "expiresAt": "2024-12-19T08:22:34Z",
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
About get-session-token refer to https://docs.aws.amazon.com/cli/latest/reference/sts/get-session-token.html:
Returns a set of temporary credentials for an Amazon Web Services account or IAM user. The credentials consist of an access key ID, a secret access key, and a security token. Typically, you use GetSessionToken if you want to use MFA to protect programmatic calls to specific Amazon Web Services API operations like Amazon EC2 StopInstances .
MFA-enabled IAM users must call GetSessionToken and submit an MFA code that is associated with their MFA device.
@@ -536,6 +536,10 @@ def get_credential_file_mounts(self) -> Dict[str, str]: | |||
""" | |||
raise NotImplementedError | |||
|
|||
def can_credential_expire(self) -> bool: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
def can_credential_expire(self) -> bool: | |
def can_credentials_expire(self) -> bool: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checks the active credential(only one), the original make sense I think.
issue link: #4433
Test Case:
Test for ENV with leakage warning:
Test for ENV without leakage warning:
Test GCP
SHARED_CREDENTIALS_FILE
bash
Launch jobs with warning
TEST GCP service account
active service account
Launch job with service account without warning
Tested (run the relevant ones):
bash format.sh
pytest tests/test_smoke.py
pytest tests/test_smoke.py::test_fill_in_the_name
conda deactivate; bash -i tests/backward_compatibility_tests.sh