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

Remove use of global fed metadata within client #798

Conversation

joereuss12
Copy link
Contributor

Changes include:

  • Created a local metadata object that store federation metadata per url.
  • Changed a lot of tests on client commands, we no longer rely on osdf for tests to pass
  • Made a function in config that discovers a federation but does not populate global config values

@joereuss12
Copy link
Contributor Author

Still a work in progress. Still need to have the url metadata be stored in a ttl cache and everything could use a little more testing.

Copy link
Collaborator

@bbockelm bbockelm left a comment

Choose a reason for hiding this comment

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

First round of feedback on the approach.

client/handle_http.go Outdated Show resolved Hide resolved
client/main.go Outdated Show resolved Hide resolved
client/main.go Outdated Show resolved Hide resolved
client/main.go Show resolved Hide resolved
client/main.go Show resolved Hide resolved
client/main.go Outdated Show resolved Hide resolved
config/config.go Outdated Show resolved Hide resolved
@joereuss12 joereuss12 force-pushed the cleanup-metadata-client-branch branch 2 times, most recently from f90f82c to 91d6f9c Compare February 19, 2024 17:36
@joereuss12 joereuss12 marked this pull request as ready for review February 19, 2024 17:36
@joereuss12 joereuss12 force-pushed the cleanup-metadata-client-branch branch from 91d6f9c to 144ec34 Compare February 19, 2024 17:41
Copy link
Collaborator

@bbockelm bbockelm left a comment

Choose a reason for hiding this comment

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

Another draft review contained.

Please talk with @haoming29 about how to have the cache expire objects. You'll need to run the Start() method to launch the goroutine and think about what lifetime you'd like it to have.

Do you have precommit setup on your development host? There's a large number of static check issues that are making it into the PR that should be caught by precommit.

assert.NoError(t, err)
if err == nil && len(transferDetailsUpload) == 2 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why delete all these tests? Do we have anything remaining that verifies the transferred files and their contents?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My thought process as well as discussion with Justin was to not fully rely on osg-htc.org for our tests so we should just make sure that everything is correct up to the point of the upload/download. Not super sure if that was the best way to do so or if we should just rely on osg-htc.org for osdf:// cases? The other tests do uploads and downloads and check for sizes of the returned files

client/main.go Show resolved Hide resolved
func newPelicanURL(remoteUrl *url.URL, scheme string) (pelicanURL PelicanURL, err error) {
if remoteUrl.Host != "" {
if scheme == "osdf" || scheme == "stash" {
remoteUrl.Path, err = url.JoinPath(remoteUrl.Host, remoteUrl.Path)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's not change the URL provided by the caller.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This section is used when someone does an osdf or stash url but only puts two /'s instead of 3 (hence they have a hostname). What would you like me to do differently? Create our own url like the comment below and modify that url?

log.Debugln("Detected pelican:// url, getting federation metadata from specified host")
federationUrl, _ := url.Parse(remoteUrl.String())
federationUrl.Scheme = "https"
federationUrl.Path = ""
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's other parts of the URL - the query and fragment, for example - that may be passed through.

Instead of taking everything and overwriting a few known attributes, let's create a fresh URL and populate only the parts we need.

client/main.go Outdated Show resolved Hide resolved
client/main.go Show resolved Hide resolved
// Verify valid scheme
err = schemeUnderstood(sourceScheme)
if err != nil {
return nil, err
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wrap the error message here to make sure the user knows what URL is being considered.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The user should be told the scheme they tried as well as the permitted ones from the err returned from schemeUnderstood:

pelican/client/main.go

Lines 488 to 489 in 144ec34

return fmt.Errorf("Do not understand the destination scheme: %s. Permitted values are %s",
scheme, strings.Join(understoodSchemes, ", "))

client/main.go Show resolved Hide resolved
config/config.go Outdated Show resolved Hide resolved
config/config.go Outdated Show resolved Hide resolved
@joereuss12
Copy link
Contributor Author

Do you have precommit setup on your development host? There's a large number of static check issues that are making it into the PR that should be caught by precommit.

The linter was not working for me for a while, I took a few stabs at fixing it but each time was taking a little to long so I put it off. I just updated it here: #829 and it seems to be working now

Changes include:
- Created a local metadata object that store federation metadata per
  url.
- Changed a lot of tests on client commands, we no longer rely on osdf
  for tests to pass
- Made a function in config that discovers a federation but does not
  populate global config values
Changes include:
- Addressing comments on PR
- Making unit tests for new functions
- Fix previous typo in "discovery"
- Added ttl cache for federations
- Fixed merge conflicts
Changes:
- Changed around some of the test logic and improved tests
- Improved ttl cache with a custom loader function
- Other misc changes addressing PR comments
@joereuss12 joereuss12 force-pushed the cleanup-metadata-client-branch branch from 144ec34 to a6b7f3a Compare February 21, 2024 16:54
@joereuss12
Copy link
Contributor Author

@bbockelm check out these changes and my comments. Let me know if anything needs tweaking. Also, look to see where the cache is created, where the loader function is (right next to cache creation), and where I start and stop the cache. I think the locations are pretty good but let me know what you think.

Was failing because it was doing a pelican prefix and a osdf scheme,
causing us to load osdf defaults for metadata instead of our specified
metadata we want.
@bbockelm
Copy link
Collaborator

@joereuss12 - now that the big client refactor has merged, please clear up the conflicts here.

joereuss12 added a commit to joereuss12/pelican that referenced this pull request Mar 1, 2024
This is v2 of PR PelicanPlatform#798 since the merge conflicts were becoming very
tedious. Therefore, I took the changes from that PR and converted it
over to a new branch. You can get the changes split up a little better
from that PR as well but I will do my best to list them here:

Changes include:
- Added a ttl cache for storing federation url metadata so we do not
  have to look up each time
- Improved unit tests for client commands, Note: for pelican prefix and
  osdf:// url scheme, it's hard to test since we use osg-htc.org for
  metadata lookup. Therefore it is hard to work with fed in a box so I
  just check for the proper metadata lookup
- Added function called discoverUrlFederation which discovers a
  federation from a url and does not populate global metadata config
  values
- Added a function called schemeUnderstood to take some repeated code
  within client into one function to check for understood url schemes
- Added unit tests for discoverUrlFederation and schemeUnderstood
@joereuss12
Copy link
Contributor Author

Closed with #878

@joereuss12 joereuss12 closed this Mar 1, 2024
joereuss12 added a commit to joereuss12/pelican that referenced this pull request Mar 1, 2024
This is v2 of PR PelicanPlatform#798 since the merge conflicts were becoming very
tedious. Therefore, I took the changes from that PR and converted it
over to a new branch. You can get the changes split up a little better
from that PR as well but I will do my best to list them here:

Changes include:
- Added a ttl cache for storing federation url metadata so we do not
  have to look up each time
- Improved unit tests for client commands, Note: for pelican prefix and
  osdf:// url scheme, it's hard to test since we use osg-htc.org for
  metadata lookup. Therefore it is hard to work with fed in a box so I
  just check for the proper metadata lookup
- Added function called discoverUrlFederation which discovers a
  federation from a url and does not populate global metadata config
  values
- Added a function called schemeUnderstood to take some repeated code
  within client into one function to check for understood url schemes
- Added unit tests for discoverUrlFederation and schemeUnderstood
joereuss12 added a commit to joereuss12/pelican that referenced this pull request Mar 4, 2024
This is v2 of PR PelicanPlatform#798 since the merge conflicts were becoming very
tedious. Therefore, I took the changes from that PR and converted it
over to a new branch. You can get the changes split up a little better
from that PR as well but I will do my best to list them here:

Changes include:
- Added a ttl cache for storing federation url metadata so we do not
  have to look up each time
- Improved unit tests for client commands, Note: for pelican prefix and
  osdf:// url scheme, it's hard to test since we use osg-htc.org for
  metadata lookup. Therefore it is hard to work with fed in a box so I
  just check for the proper metadata lookup
- Added function called discoverUrlFederation which discovers a
  federation from a url and does not populate global metadata config
  values
- Added a function called schemeUnderstood to take some repeated code
  within client into one function to check for understood url schemes
- Added unit tests for discoverUrlFederation and schemeUnderstood
joereuss12 added a commit to joereuss12/pelican that referenced this pull request Mar 5, 2024
This is v2 of PR PelicanPlatform#798 since the merge conflicts were becoming very
tedious. Therefore, I took the changes from that PR and converted it
over to a new branch. You can get the changes split up a little better
from that PR as well but I will do my best to list them here:

Changes include:
- Added a ttl cache for storing federation url metadata so we do not
  have to look up each time
- Improved unit tests for client commands, Note: for pelican prefix and
  osdf:// url scheme, it's hard to test since we use osg-htc.org for
  metadata lookup. Therefore it is hard to work with fed in a box so I
  just check for the proper metadata lookup
- Added function called discoverUrlFederation which discovers a
  federation from a url and does not populate global metadata config
  values
- Added a function called schemeUnderstood to take some repeated code
  within client into one function to check for understood url schemes
- Added unit tests for discoverUrlFederation and schemeUnderstood
joereuss12 added a commit to joereuss12/pelican that referenced this pull request Mar 13, 2024
This is v2 of PR PelicanPlatform#798 since the merge conflicts were becoming very
tedious. Therefore, I took the changes from that PR and converted it
over to a new branch. You can get the changes split up a little better
from that PR as well but I will do my best to list them here:

Changes include:
- Added a ttl cache for storing federation url metadata so we do not
  have to look up each time
- Improved unit tests for client commands, Note: for pelican prefix and
  osdf:// url scheme, it's hard to test since we use osg-htc.org for
  metadata lookup. Therefore it is hard to work with fed in a box so I
  just check for the proper metadata lookup
- Added function called discoverUrlFederation which discovers a
  federation from a url and does not populate global metadata config
  values
- Added a function called schemeUnderstood to take some repeated code
  within client into one function to check for understood url schemes
- Added unit tests for discoverUrlFederation and schemeUnderstood
joereuss12 added a commit to joereuss12/pelican that referenced this pull request Mar 14, 2024
This is v2 of PR PelicanPlatform#798 since the merge conflicts were becoming very
tedious. Therefore, I took the changes from that PR and converted it
over to a new branch. You can get the changes split up a little better
from that PR as well but I will do my best to list them here:

Changes include:
- Added a ttl cache for storing federation url metadata so we do not
  have to look up each time
- Improved unit tests for client commands, Note: for pelican prefix and
  osdf:// url scheme, it's hard to test since we use osg-htc.org for
  metadata lookup. Therefore it is hard to work with fed in a box so I
  just check for the proper metadata lookup
- Added function called discoverUrlFederation which discovers a
  federation from a url and does not populate global metadata config
  values
- Added a function called schemeUnderstood to take some repeated code
  within client into one function to check for understood url schemes
- Added unit tests for discoverUrlFederation and schemeUnderstood
joereuss12 added a commit to joereuss12/pelican that referenced this pull request Mar 14, 2024
This is v2 of PR PelicanPlatform#798 since the merge conflicts were becoming very
tedious. Therefore, I took the changes from that PR and converted it
over to a new branch. You can get the changes split up a little better
from that PR as well but I will do my best to list them here:

Changes include:
- Added a ttl cache for storing federation url metadata so we do not
  have to look up each time
- Improved unit tests for client commands, Note: for pelican prefix and
  osdf:// url scheme, it's hard to test since we use osg-htc.org for
  metadata lookup. Therefore it is hard to work with fed in a box so I
  just check for the proper metadata lookup
- Added function called discoverUrlFederation which discovers a
  federation from a url and does not populate global metadata config
  values
- Added a function called schemeUnderstood to take some repeated code
  within client into one function to check for understood url schemes
- Added unit tests for discoverUrlFederation and schemeUnderstood
joereuss12 added a commit to joereuss12/pelican that referenced this pull request Mar 15, 2024
This is v2 of PR PelicanPlatform#798 since the merge conflicts were becoming very
tedious. Therefore, I took the changes from that PR and converted it
over to a new branch. You can get the changes split up a little better
from that PR as well but I will do my best to list them here:

Changes include:
- Added a ttl cache for storing federation url metadata so we do not
  have to look up each time
- Improved unit tests for client commands, Note: for pelican prefix and
  osdf:// url scheme, it's hard to test since we use osg-htc.org for
  metadata lookup. Therefore it is hard to work with fed in a box so I
  just check for the proper metadata lookup
- Added function called discoverUrlFederation which discovers a
  federation from a url and does not populate global metadata config
  values
- Added a function called schemeUnderstood to take some repeated code
  within client into one function to check for understood url schemes
- Added unit tests for discoverUrlFederation and schemeUnderstood
joereuss12 added a commit to joereuss12/pelican that referenced this pull request Mar 18, 2024
This is v2 of PR PelicanPlatform#798 since the merge conflicts were becoming very
tedious. Therefore, I took the changes from that PR and converted it
over to a new branch. You can get the changes split up a little better
from that PR as well but I will do my best to list them here:

Changes include:
- Added a ttl cache for storing federation url metadata so we do not
  have to look up each time
- Improved unit tests for client commands, Note: for pelican prefix and
  osdf:// url scheme, it's hard to test since we use osg-htc.org for
  metadata lookup. Therefore it is hard to work with fed in a box so I
  just check for the proper metadata lookup
- Added function called discoverUrlFederation which discovers a
  federation from a url and does not populate global metadata config
  values
- Added a function called schemeUnderstood to take some repeated code
  within client into one function to check for understood url schemes
- Added unit tests for discoverUrlFederation and schemeUnderstood
joereuss12 added a commit to joereuss12/pelican that referenced this pull request Mar 26, 2024
This is v2 of PR PelicanPlatform#798 since the merge conflicts were becoming very
tedious. Therefore, I took the changes from that PR and converted it
over to a new branch. You can get the changes split up a little better
from that PR as well but I will do my best to list them here:

Changes include:
- Added a ttl cache for storing federation url metadata so we do not
  have to look up each time
- Improved unit tests for client commands, Note: for pelican prefix and
  osdf:// url scheme, it's hard to test since we use osg-htc.org for
  metadata lookup. Therefore it is hard to work with fed in a box so I
  just check for the proper metadata lookup
- Added function called discoverUrlFederation which discovers a
  federation from a url and does not populate global metadata config
  values
- Added a function called schemeUnderstood to take some repeated code
  within client into one function to check for understood url schemes
- Added unit tests for discoverUrlFederation and schemeUnderstood
joereuss12 added a commit to joereuss12/pelican that referenced this pull request Apr 1, 2024
This is v2 of PR PelicanPlatform#798 since the merge conflicts were becoming very
tedious. Therefore, I took the changes from that PR and converted it
over to a new branch. You can get the changes split up a little better
from that PR as well but I will do my best to list them here:

Changes include:
- Added a ttl cache for storing federation url metadata so we do not
  have to look up each time
- Improved unit tests for client commands, Note: for pelican prefix and
  osdf:// url scheme, it's hard to test since we use osg-htc.org for
  metadata lookup. Therefore it is hard to work with fed in a box so I
  just check for the proper metadata lookup
- Added function called discoverUrlFederation which discovers a
  federation from a url and does not populate global metadata config
  values
- Added a function called schemeUnderstood to take some repeated code
  within client into one function to check for understood url schemes
- Added unit tests for discoverUrlFederation and schemeUnderstood
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants