-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
rpcenc: Support reader redirect #6952
Conversation
e7470ed
to
8426a62
Compare
(note that this should not require api version bump, as older clients should still "just work", they just won't support redirects) |
cc @jacobheun for tracking. |
This won't be in v1.11.1. |
This would be great to have, but it's an optimisation and we should consider for 1.11.3. |
@raulk is this still need if storage.Json is copied overs/shared to the market nodes too? |
Yes, when adding pieces without this data would still flow through the main miner process |
@jennijuju I would like to challenge the decision on postponing for future releases. |
3.1. If the reader is of type `*sealing.NullReader`, the resulting object | ||
is `ReaderStream{ Type: "null", Info: "[base 10 number of bytes]" }` | ||
3.2. If the reader is of type `*RpcReader`, and it wasn't read from, we | ||
notify that RpcReader to go a different push endpoint, and return | ||
a `ReaderStream` object like in 3.4. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When do each of these cases happen?
c.CheckRedirect = func(req *http.Request, via []*http.Request) error { | ||
return http.ErrUseLastResponse | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this interrupt the redirect flow on the first occurrence? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's meant to, we want to handle the redirect ourselves in https://github.com/filecoin-project/lotus/pull/6952/files#diff-309dd201d9384284851cf021bce98a146c76f5db8a982949b87f1e4b3d63cb26R138 (we need to save the last URL form the HEAD requests for the final POST. Unfortunately we can't just do a POST and have Go handle the redirects, because Go's http client will send the request body with the first request, evan if it then gets the redirect response - which is why we do this whole HEAD request dance here)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(and we have to use this weird CheckRedirect to be able to save the last redirect Location
header, as otherwise if you just let the http client handle the redirect, there is no way to get that URL)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this error has a very special meaning, perhaps not obvious:
ErrUseLastResponse can be returned by Client.CheckRedirect hooks to control how redirects are processed. If returned, the next request is not sent and the most recent response is returned with its body unclosed
func ReaderParamEncoder(addr string) jsonrpc.Option { | ||
// Client side parameter encoder. Runs on the rpc client side. io.Reader -> ReaderStream{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hoist to godoc for this method.
Hey team - what’s the status on this PR? Is anyone actively working on it and address the comments? |
We'll aim to land this in 1.11.3 as the 1.11.2-rc is going out today and more testing is needed here, so we don't need to worry about backporting this to the 1.11.2 release. |
I validated this on |
Includes docs and tests!
This should allow market processes to send piece bytes directly to workers
Closes #7107