Skip to content
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

[Identity] Make the identity loading more robust #2033

Merged
merged 3 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions sky/backends/backend_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1638,6 +1638,9 @@ def check_owner_identity(cluster_name: str) -> None:
for i, (owner,
current) in enumerate(zip(owner_identity,
current_user_identity)):
# Clean up the owner identiy for the backslash and newlines, caused
# by the cloud CLI output, e.g. gcloud.
owner = owner.replace('\n', '').replace('\\', '')
if owner == current:
if i != 0:
logger.warning(
Expand Down
1 change: 1 addition & 0 deletions sky/clouds/gcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,7 @@ def get_current_user_identity(cls) -> Optional[List[str]]:
try:
account = _run_output('gcloud auth list --filter=status:ACTIVE '
'--format="value(account)"')
account = account.strip()
except subprocess.CalledProcessError as e:
with ux_utils.print_exception_no_traceback():
raise exceptions.CloudUserIdentityError(
Expand Down
7 changes: 4 additions & 3 deletions sky/global_user_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,9 +495,10 @@ def _load_owner(record_owner: Optional[str]) -> Optional[List[str]]:
if result is not None and not isinstance(result, list):
# Backwards compatibility for old records, which were stored as
# a string instead of a list. It is possible that json.loads
# will parse the string with all numbers as an int, so we need
# to convert it back to a list of strings.
return [str(result)]
# will parse the string with all numbers as an int or escape
# some characters, such as \n, so we need to use the original
# record_owner.
return [record_owner]
return result
except json.JSONDecodeError:
# Backwards compatibility for old records, which were stored as
Expand Down