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

[User identity] Fix identity check #1550

Merged
merged 9 commits into from
Dec 25, 2022
Merged

[User identity] Fix identity check #1550

merged 9 commits into from
Dec 25, 2022

Conversation

Michaelvll
Copy link
Collaborator

@Michaelvll Michaelvll commented Dec 20, 2022

Describe the changes in this PR:
(related to #1513) This PR fixes the identity check for the sky status -r as it does not go through refresh_cluster_status_handle.

Tested (run the relevant ones):

  • sky launch -c test -t t3.micro; AWS_PROFILE=admin-user sky status -r

@@ -1809,7 +1809,8 @@ def _update_cluster_status_no_lock(

def _update_cluster_status(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not clearly remember the differences between _update_cluster_status() and refresh_cluster_status_handle(). After reading the docstrings, still having some troubles telling the differences.

The status -r code path calls the former:

def _refresh_cluster(cluster_name):
try:
record = _update_cluster_status(
cluster_name, acquire_per_cluster_status_lock=True)
except (exceptions.ClusterStatusFetchingError,
exceptions.ClusterOwnerIdentityMismatchError) as e:
record = {'status': 'UNKNOWN', 'error': e}
progress.update(task, advance=1)
return record

Would this change be needed if it calls the latter? Which already had identity checks.

Copy link
Collaborator Author

@Michaelvll Michaelvll Dec 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main difference is the former returns the entire record but the latter returns the (status, handle) tuple. If we let the status -r call the later, we may have to add a argument to the latter function to return the record. I would prefer the current implementation, since the refresh_cluster_status_handle is public and used a lot in other modules.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I refactored it a bit, by adding a new function refresh_cluster_record, and all the callers will go through this function now. Does that look better @concretevitamin? : )

Copy link
Member

@concretevitamin concretevitamin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Mainly to clarify the two functions (I feel they do the same thing and differ on in return values).

sky/backends/backend_utils.py Outdated Show resolved Hide resolved
sky/backends/backend_utils.py Outdated Show resolved Hide resolved
sky/backends/backend_utils.py Outdated Show resolved Hide resolved
force_refresh: bool = False,
acquire_per_cluster_status_lock: bool = True
) -> Optional[Dict[str, Any]]:
"""Refresh the cluster record.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""Refresh the cluster record.
"""Refresh the cluster, and return the possibly updated record.

Conceptually I feel the difference between the two functions is only what is returned?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the only difference is the return value.

sky/backends/backend_utils.py Outdated Show resolved Hide resolved
@Michaelvll Michaelvll merged commit 1ad0868 into master Dec 25, 2022
@Michaelvll Michaelvll deleted the fix-identity-check branch December 25, 2022 05:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants