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

add logout to funcx endpoint #909

Merged
merged 1 commit into from
Sep 6, 2022
Merged

Conversation

LeiGlobus
Copy link
Contributor

@LeiGlobus LeiGlobus commented Aug 31, 2022

Added logout subcommand to funcx-endpoint. See linked SC: https://app.shortcut.com/funcx/story/18074/support-funcx-endpoint-logout

There is a slight modification to funcx_sdk.funcx.sdk.login_manager.manager.logout to return bool instead, plus see the associated TODO comment.

I expect to remove the TODO in LoginManager.logout and funcx_endpoint.cli.logout_endpoint before merging (the TODOs are to ensure PR comment)

EDIT all the TODOs were removed along with most of the proposed (and rejected) extra logic/params.

@shortcut-integration
Copy link

This pull request has been linked to Shortcut Story #18074: Support FuncX endpoint logout.

@LeiGlobus
Copy link
Contributor Author

Screen Shot 2022-08-31 at 12 13 39 PM

@LeiGlobus
Copy link
Contributor Author

See above screenshot for example usage - First funcx_endpoint start forces login (no previous logins). Second 'start' does not require re-auth as expected, after 'logout', 3rd start requires re-auth (confirming logout token clearing), and if login is aborted, 2nd 'logout' shows that no tokens were found to revoke

@LeiGlobus LeiGlobus force-pushed the funcx-endpoint-logout-sc-18074 branch 2 times, most recently from 170fd52 to 36f911a Compare August 31, 2022 18:04
@LeiGlobus LeiGlobus requested a review from sirosen August 31, 2022 18:09
@LeiGlobus
Copy link
Contributor Author

@sirosen LoginManager.logout was your original code, putting this on your radar in case you had any comments on whether we should support resource_server specific logouts or if you mind the bool return value of if tokens were found and removed.

Copy link
Contributor

@khk-globus khk-globus left a comment

Choose a reason for hiding this comment

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

Looks generally on target, save for a suggestion regarding giving more information to the user.

The one thing that does appear to be lacking is tests.

@LeiGlobus LeiGlobus force-pushed the funcx-endpoint-logout-sc-18074 branch from 36f911a to df18c2d Compare August 31, 2022 18:20
@khk-globus
Copy link
Contributor

Is this ... expected behavior?

$ funcx-endpoint logout
1661971619.692372 2022-08-31 14:46:59 WARNING MainProcess-1517847 MainThread-139622829592576 funcx_endpoint.cli:193 logout_endpoint No tokens were found to revoke during logout attempt

$

As I didn't specify an environment ... what do we expect to happen? From which environment did it attempt log me out?

Perhaps --environment should be required? Or should there be a single required positional argument?

@sirosen
Copy link
Member

sirosen commented Aug 31, 2022

Kevin asked me for my thoughts on this, so very briefly:

  • Consider whether or not --environment should have hidden=True set if it's going to be an option (also consider: can it just be an env var). Users generally don't know and don't care about various non-production environments, so avoid cluttering --help.
  • Similarly, users don't know and should not need to care what a Resource Server is. Don't show them information which presumes that they care about the implementation at the same level that the implementers do. If you want such information, you can always add it (later) as a --verbose option.
  • In globus-cli, we introduced an --ignore-errors option to handle the fact that a user might want to force logout OR they might want to abort if credential revocation fails. That may or may not be a good paradigm to follow here as well.
  • I like that this makes token revocation a responsibility of the LoginManager. globus-cli could do with that refinement too -- it's clearer than making the logout command do it.

Copy link
Contributor

@joshbryan-globus joshbryan-globus left a comment

Choose a reason for hiding this comment

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

I left a few, let me know if you have any questions.

funcx_endpoint/funcx_endpoint/cli.py Outdated Show resolved Hide resolved
funcx_endpoint/funcx_endpoint/cli.py Outdated Show resolved Hide resolved
funcx_sdk/funcx/sdk/login_manager/manager.py Show resolved Hide resolved
funcx_endpoint/funcx_endpoint/cli.py Outdated Show resolved Hide resolved
@LeiGlobus
Copy link
Contributor Author

  • Consider whether or not --environment should have hidden=True set if it's going to be an option (also consider: can it just be an env var). Users generally don't know and don't care about various non-production environments, so avoid cluttering --help.
    Yes users generally don't care about dev/production environments, this is mostly for developer use. For us, it isn't that big a deal to clear all env auths instead of adding this env option.

So with Josh's suggestion below, I'll remove the environment param altogether for now.

  • Similarly, users don't know and should not need to care what a Resource Server is. Don't show them information which presumes that they care about the implementation at the same level that the implementers do. If you want such information, you can always add it (later) as a --verbose option.

Yes the resource_server ones are entwined anyway for most consents and most users don't care about individual ones. Especially in this case, removing individual ones aren't relevant to the original shortcut story. Removing references and logic here.

  • In globus-cli, we introduced an --ignore-errors option to handle the fact that a user might want to force logout OR they might want to abort if credential revocation fails. That may or may not be a good paradigm to follow here as well.

Adding a --force option re: Josh currently running endpoints which will require a bit more refactoring in the next commit.

@LeiGlobus LeiGlobus force-pushed the funcx-endpoint-logout-sc-18074 branch from df18c2d to 824eaac Compare August 31, 2022 21:55
@LeiGlobus
Copy link
Contributor Author

Is this ... expected behavior?

$ funcx-endpoint logout
1661971619.692372 2022-08-31 14:46:59 WARNING MainProcess-1517847 MainThread-139622829592576 funcx_endpoint.cli:193 logout_endpoint No tokens were found to revoke during logout attempt

$

As I didn't specify an environment ... what do we expect to happen? From which environment did it attempt log me out?

Perhaps --environment should be required? Or should there be a single required positional argument?

See other comments - removed --environment as I mostly agree with sirosen and Josh that it is too dev-specific, but did change the resulting user-facing output

@LeiGlobus
Copy link
Contributor Author

Looks generally on target, save for a suggestion regarding giving more information to the user.

The one thing that does appear to be lacking is tests.

Let's discuss offline, but as logout_endpoint just calls LoginManager.logout directly, there isn't much PR specific logic to test. (most of the logic is Click option related, the rest LoginManager related, so should be added in separate PR if desired IMO). The get_running_endpoints() refactor is slightly testable but not much.

@LeiGlobus
Copy link
Contributor Author

Added logout subcommand to funcx-endpoint. See linked SC: https://app.shortcut.com/funcx/story/18074/support-funcx-endpoint-logout

There is a slight modification to funcx_sdk.funcx.sdk.login_manager.manager.logout to return bool instead, plus see the associated TODO comment.

I expect to remove the TODO in LoginManager.logout and funcx_endpoint.cli.logout_endpoint before merging (the TODOs are to ensure PR comment)

edit

@LeiGlobus LeiGlobus closed this Aug 31, 2022
@LeiGlobus LeiGlobus force-pushed the funcx-endpoint-logout-sc-18074 branch 2 times, most recently from 583007a to c4e719c Compare September 1, 2022 22:54
@LeiGlobus
Copy link
Contributor Author

Added sys.exit() non-
Screen Shot 2022-09-01 at 5 48 43 PM
zero behavior to logout, if any tokens were actually found/revoked. See attached screenshot example (which doesn't show re-auth scenarios which I will leave to the reviewer to test if desired, which should also work)

@LeiGlobus LeiGlobus force-pushed the funcx-endpoint-logout-sc-18074 branch 2 times, most recently from 35e374b to c0f13a7 Compare September 2, 2022 17:25
@LeiGlobus
Copy link
Contributor Author

Redid the logout messages (in log.info and in ClickException command return). See all 4 scenarios below: (In order, they are 1) Logout failure with running endpoint 2) Logout success with running endpoint and --force 3) logout success with no running endpoints 4) logout failure when tokens were already cleared

Screen Shot 2022-09-02 at 12 25 25 PM

Screen Shot 2022-09-02 at 12 25 46 PM

@LeiGlobus LeiGlobus force-pushed the funcx-endpoint-logout-sc-18074 branch from c0f13a7 to 54c06f1 Compare September 2, 2022 17:44
modify erorr message

lint formatting

tmp

mypy and lint
@LeiGlobus LeiGlobus force-pushed the funcx-endpoint-logout-sc-18074 branch from 54c06f1 to e84feba Compare September 2, 2022 18:20
Copy link
Contributor

@khk-globus khk-globus left a comment

Choose a reason for hiding this comment

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

Well done, mate! That was the "5-minute" PR from hell, right? Heh.

@LeiGlobus
Copy link
Contributor Author

@joshbryan-globus I think the --force flag resolves the comment? But it's still showing changes requested. You may have to click something again

@LeiGlobus LeiGlobus merged commit ad5801e into main Sep 6, 2022
@LeiGlobus LeiGlobus deleted the funcx-endpoint-logout-sc-18074 branch September 6, 2022 19:12
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.

4 participants