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

Director advertise origin instead of writebackhost #622

Conversation

joereuss12
Copy link
Contributor

Changes made with this PR:

  • Client now gets the endpoint for a put request through the director, this endpoint is the origin_url. PUTs now require a running director to work.
  • When running origin serve and as a configurable option, you can specify if the origin is writeable (default is true).
  • Made a test within handle_http_test.go end-to-end with xrootd, using the federation in a box since now PUTs require a director to be running.
  • To remove an import cycle, made the pelican version global through config

Might have missed some other patch work to make everything work properly as well but this is the gist of it

Changes made with this PR:
- Client now gets the endpoint for a put request through the director,
  this endpoint is the origin_url. PUTs now require a running director
  to work.
- When running origin serve and as a configurable option, you can
  specify if the origin is writeable (default is true).
- Made a test within handle_http_test.go end-to-end with xrootd, using
  the federation in a box since now PUTs require a director to be
  running.
- To remove an import cycle, made the pelican version global through
  config
@joereuss12 joereuss12 added this to the v7.4.0 milestone Jan 8, 2024
Copy link
Collaborator

@turetske turetske left a comment

Choose a reason for hiding this comment

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

I need clarification on why it's a PUT request, I feel like I'm misunderstanding something.

director/redirect.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@turetske turetske left a comment

Choose a reason for hiding this comment

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

LGTM

@turetske turetske merged commit cc216be into PelicanPlatform:main Jan 9, 2024
9 checks passed
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.

Medium-sized changes requested. The crux of the request is to change to sending PUTs from the client and not a GET, allowing curl interoperability.

Also -- is the periodic OSDF advertise updated as well? I'm not seeing code that suggests it is.

}

payload := []byte("forPUT")
req, err := http.NewRequest("GET", directorUrl.String(), bytes.NewBuffer(payload))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this calling GET in order to do a PUT? Shouldn't it just invoke a PUT and rely on the director to redirect?

What's the implications on backward compatibility here? Doesn't this break OSDF integration because it doesn't use the topology information when that's the preferred mechanism?

To avoid backward compat breaks, we should do something similar to what is done with downloads:
0. Based on configuration, perhaps take the topology code branches.

  1. If using the director, invoke a PUT to the director when doing the namespace resolution.
  2. Instead of following the redirect, look at the headers / redirect location header to determine the "real" location of the destination.
  3. Based on (2), fill in the namespace structure accordingly.
  4. Then, the upload code proceeds without knowing where the namespace information comes from.

For examples from the analogous GET case, see https://github.com/PelicanPlatform/pelican/blob/v7.3.3/client/director.go#L66

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it a put? It's not doing an update to the director, is it? It's getting information.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bbockelm Just want to make sure I am approaching this correctly:
So should I move this logic to around where we query the director/CreateNsFromDirectorResp within client/main.go and populate writebackhost with the correct value in cases we do not use topology. Then change uploadfile to get the destination from writebackhost in the namespace struct?

Copy link
Collaborator

Choose a reason for hiding this comment

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

One tweak:

Then change uploadfile to get the destination from writebackhost in the namespace struct?

I'd say change uploadfile back to this behavior. Basically, revert the changes in that method back to where it was before.

Copy link
Collaborator

@bbockelm bbockelm Jan 9, 2024

Choose a reason for hiding this comment

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

Oh, another clarification:

move this logic to around where we query the director

The logic should also change slightly too. Instead of a GET with body contents, it should be a PUT.

// Actually perform the Put request to the server
func doPut(request *http.Request, responseChan chan<- *http.Response, errorChan chan<- error) {
var UploadClient = &http.Client{Transport: config.GetTransport()}
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's the impact of this? Shouldn't clients be shared?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved this within the function because when it was a global variable, the transport was not being set correctly. For example, it did not recognize TLSSkipVerify being set to true and it was always false. Somehow it was getting the transport before any init functions in config were called.

client/main.go Show resolved Hide resolved
client/main.go Show resolved Hide resolved
docs/parameters.yaml Show resolved Hide resolved
director/redirect.go Show resolved Hide resolved
joereuss12 added a commit to joereuss12/pelican that referenced this pull request Jan 9, 2024
These fixes are for PR PelicanPlatform#622 which helps reinstate backwards
compatibility. Changes include:
- Returning `uploadFile` to its original state
- Running a PUT on the director to get PUT endpoint instead of a GET
   - Moved this logic to `client/main.go` when we gather ns info
- Moved the gathering of ns info to a seperate function
@joereuss12
Copy link
Contributor Author

Also -- is the periodic OSDF advertise updated as well? I'm not seeing code that suggests it is.

Yes, Emma fixed this in one of her PRs

@turetske
Copy link
Collaborator

turetske commented Jan 9, 2024

Also -- is the periodic OSDF advertise updated as well? I'm not seeing code that suggests it is.

Yes, Emma fixed this in one of her PRs

It depends on what you mean by "updated".

joereuss12 added a commit to joereuss12/pelican that referenced this pull request Jan 10, 2024
These fixes are for PR PelicanPlatform#622 which helps reinstate backwards
compatibility. Changes include:
- Returning `uploadFile` to its original state
- Running a PUT on the director to get PUT endpoint instead of a GET
   - Moved this logic to `client/main.go` when we gather ns info
- Moved the gathering of ns info to a seperate function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants