-
Notifications
You must be signed in to change notification settings - Fork 187
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
libgit2: ensure context timeout cancels transfer #477
Conversation
f09e14d
to
ca57aee
Compare
Timeout
cancels transfer0093d58
to
0b94450
Compare
With the information from the refactor still fresh in mind, I continue to find new paths now I mentally tamed the git2go beast. `libgit2` seems to assume that a transport will eventually tell by itself that it has timed out. This also means that at present any timeout configuration does not seem have an effect. It will continue to transfer until the remote (or _something_ else) tells it is no longer transfering. This commit introduces a simple check (without tests) which was used to confirm the theory in combination with the tests in `pkg/git/strategy` (by setting it to a very low timeout and observing it fail). A future iteration should probably take the data given to the callback into account to ensure it doesn't error out if the given data[1] reports it has successfully received all objects. Another candidate for this check may be `CompletionCallback`, but one should study the C code (and likely some Go code as well) before this. In addition, to ensure the same timeout is taken into account for push operations, `PushTransferProgressCallback` may require a likewise helper. [1]: https://github.com/libgit2/git2go/blob/main/remote.go#L50-L58 Signed-off-by: Hidde Beydals <hello@hidde.co>
In transferProgressCallback(), if the received objects is equal to the total objects, return early with OK. Signed-off-by: Sunny <darkowlzz@protonmail.com>
Add SidebandProgressCallback to be able to cancel the network operation before any transfer operation. Add PushTransferProgressCallback to be able to cancel the push transfer operation. Signed-off-by: Sunny <darkowlzz@protonmail.com>
9f10b07
to
9561ccf
Compare
Added
Performed some manual testing of |
cc6bfd0
to
6769485
Compare
- Adds tests for the libgit2 remote callbacks - Adds tests for CheckoutStrategyForImplementation with context timeout and verify timeout is respected by both the git implementations. Signed-off-by: Sunny <darkowlzz@protonmail.com>
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.
Can not review my own PR, but this looks good to me. Thanks a lot for taking over and getting to the bottom of it @darkowlzz 🌻
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.
LGTM
Thanks @hiddeco and @darkowlzz 🏅
libgit2
seems to assume that a transport will eventually tell byitself that it has timed out. This also means that at present any
timeout configuration does not seem have an effect. It will continue
to transfer until the remote (or something else) tells it is no
longer transferring.
This commit adds libgit2 remote callbacks
SidebandProgressCallback
,TransferProgressCallback
andPushTransferProgressCallback
tosignal libgit2 to stop the operations based on the context and the
operation status.
Refer git2go/remote.go for a list of supported remote callbacks.