E3SM-Project / zstash

Long term HPSS archiving tool for E3SM
BSD 3-Clause "New" or "Revised" License
8 stars 11 forks source link

Refactor auth logic #349

Open forsyth2 opened 2 months ago

forsyth2 commented 2 months ago

Issue resolution

Select one: This pull request is...

1. Does this do what we want it to do?

Objectives:

Required:

If applicable:

2. Are the implementation details accurate & efficient?

Required:

If applicable:

3. Is this well documented?

Required:

4. Is this code clean?

Required:

If applicable:

forsyth2 commented 2 months ago

I've tried to do a preliminary code change here to address #338 and #339. However, the code in this pull request unfortunately results in python -u -m unittest tests/test_globus.py just hanging after prompting for one auth code. I will continue looking into this. In the meantime:

To @golaz's point in #339, the Globus authentication process has really impacted zstash's usability. We should address it before the next E3SM Unified release. Examples of impacts:

The two biggest problems at the moment seem to be:

  1. To use Globus in any zstash production use case requires doing a toy problem with zstash to get the authentications sorted out first.
  2. Losing authentication in the middle of a multi-day transfer.
mahf708 commented 2 months ago

My main recommendation is completely getting rid of fair_research_login; also, the test tests/test_globus.py seems to be independent of zstash/globus.py, which means changing one isn't necessarily going to be reflected in the other. I am misreading this? If my understanding is correct, the test has to be updated, right?

The fair_research_login stuff seems to still be in use here:

mahf708 commented 2 months ago

Additionally, once you get rid of fair_research_login, be sure to relax the constraint on the globus sdk:

https://github.com/E3SM-Project/zstash/blob/1aa459e9c33d08d21da7f115b40dea8ef0b6fff4/conda/meta.yaml#L25

forsyth2 commented 1 month ago

the test tests/test_globus.py seems to be independent of zstash/globus.py

Yes, the test function preactivate_globus replaces the production-use function globus_activate.

Details, going through the test code:

testLs calls helperLsGlobus

helperLsGlobus calls self.preactivate_globus()

helperLsGlobus then sets up the HPSS path, the cache, and the directory setupDir to archive.

helperLsGlobus then calls self.create() which will run zstash create. This will trigger Globus because hpss_path was set as f"globus://{hpss_globus_endpoint}/~/zstash_test/" in testLs. That is, it will ultimately call globus.py globus_transfer. Now, globus_activate("globus://" + remote_ep) will not be called because test_globus.py preactivate_globus already set self.transfer_client = TransferClient(authorizer=transfer_authorizer).