-
Notifications
You must be signed in to change notification settings - Fork 226
Graceful cancellation for network dependent commands #123
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
Conversation
`ack-generate` uses go-git to clone and fetch repository tags, these actions can take time (more than a minute for cloning) and do not tollerate interruption (ctrl+C). Forcing a command to exit when it's running a `git.Clone` or a `git.FetchTags` cause the process to write uncomplete data on disk, and therefore it is impossible to re-run `ack-generate` without cleaning up the local cache. This patch adds a gracefull cancellation system for `ack-generate` subcommads. Which will allow users to safely ctrl+C and re-run their commands without any errors.
I see that it sets up a cancel context and prescribes timeouts to each git operation, but how does this prevent it from creating a faulty local version of the repositories? |
Yes on one hand this PR adds default timeouts for each git operation, on the other hand we also propagate a cancellation mechanism to all the functions using the main context ( Short answer: It is up the The cancellation mechanism doesn't guaranty that go-git will not write incomplete data and/or missing git blobs - but only ensure that we are correctly using go-git functions and any function that takes a long answer: Calling a How does go-git handle graceful cancellation for network calls and disk i/o operations ? For network calls - the cancellation mechanism is implemented in the standard libraries |
Glad /lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: A-Hilaly, RedbackThomson, vijtrip2 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
// recreate the context.CancelFunc | ||
cancelFunc := func() { | ||
signal.Stop(signalCh) | ||
cancel() |
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.
wouldn't cancel
have been called already on line 53?
@jaypipes If |
…-k8s#123) Issue N/A `ack-generate` uses go-git to clone and fetch repository tags, these actions are time consuming (more than a minute for cloning) and do not tolerate interruption (ctrl+C). Forcing a command to exit when it's running a `git.Clone` or a `git.FetchTags` cause the process to write incomplete data on disk, therefore re-running `ack-generate` will always return an error. The only solution for this problem is to delete the local sdk cache and let `ack-generate` reclone (without interruption) This patch adds a graceful cancellation system for `ack-generate` subcommads. Which will allow users to safely ctrl+C and re-run their commands without any errors. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Issue N/A
ack-generate
uses go-git to clone and fetch repository tags, theseactions are time consuming (more than a minute for cloning) and do
not tolerate interruption (ctrl+C). Forcing a command to exit when it's
running a
git.Clone
or agit.FetchTags
cause the process to writeincomplete data on disk, therefore re-running
ack-generate
willalways return an error. The only solution for this problem is to delete
the local sdk cache and let
ack-generate
reclone (without interruption)This patch adds a graceful cancellation system for
ack-generate
subcommads. Which will allow users to safely ctrl+C and re-run their
commands without any errors.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.