-
Notifications
You must be signed in to change notification settings - Fork 1k
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
I signed it! |
CLAs look good, thanks! |
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.
Yay! This is sorely needed, thank you for submitting this! 💖
README.md
Outdated
@@ -234,6 +234,15 @@ You might, for example, include a constraint in your manifest that specifies `ve | |||
* `0.2.3` becomes the range `>=0.2.3, <0.3.0` | |||
* `0.0.3` becomes the range `>=0.0.3, <0.1.0` | |||
|
|||
## Timeouts | |||
|
|||
`dep ensure` can sometime fail on very slow system due to underlying operations taking too long to perform. This is especially true on Windows due to filesystem issues. |
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 not just ensure that uses these timeouts, for example init triggers a ton of clones into the source cache, which can timeout.
Not sure we need to call out Windows specific, especially since we aren't linking to a known issue or anything. I've seen timeouts on all OS's when using dep. 😀
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.
You are right that the bit about Windows isn't necessary. I removed it.
README.md
Outdated
|
||
If the built-in timeouts are not suitable to your environment, you can override those by setting specific environment variables: | ||
|
||
* `DEP_EXPENSIVE_CMD_TIMEOUT`: Set the maximum number of seconds expensive operations can take. The default is 2 minutes (120 seconds). |
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 would help to give at least one example of what an expensive or common operation may be. Otherwise it is hard to tell which one needs to be bumped.
I know that essentially anything that hits the network is expensive, such as cloning a repository, otherwise it's considered default, like getting revision information.
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.
Truth be told, I have no idea how to actually know for sure which operations are performed that happen to timeout.
dep
verbose mode doesn't tell us exactly what it does and for how long it tries. Perhaps it'd be a good idea if there was a debug flag of some sort that gives that kind of information.
What do you think ?
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 we include more information in the error message when the command times out, telling them which flag they can set to override the timeout? That way it's not hidden in verbose and shows up only when it's needed (when the timeout is hit).
seconds, err := strconv.Atoi(os.Getenv(key)) | ||
|
||
if err != nil { | ||
return def |
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.
This gives no indication to the user when their environment variable is set but isn't convertible.
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.
Correct. It might be confusing.
I don't mind making this more user-friendly. However I will put that on hold until we have consensus that the environment variables are indeed the way to go.
const ( | ||
// envExpensiveCmdTimeout is the environment variable to read for the | ||
// expensiveCmdTimeout default, in seconds. | ||
envExpensiveCmdTimeout = "DEP_EXPENSIVE_CMD_TIMEOUT" |
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.
Currently dep isn't relying upon any environment variables (other than in tests). I'm not sure if we want to start doing that, instead of continuing to use flags? I'll let @sdboyer have the final say on that though.
If we do stick with environment variables, they should be documented in the help text too.
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.
I actually felt uncomfortable adding those environment variables where no other were currently used.
I went with those anyway because:
- Timeouts are not something I'd like to set on each invocation of
dep
. If an operation takes a long time on my machine, this is likely to happen often - or even every time. - It somehow felt like leaking an implementation detail: if we end up having 15 sorts of timeouts in
dep
and all of those have to be exposed as flags (part of the CLI API so to speak), things will get ugly fast.
Perhaps a configuration file of some sort (like git
has), would serve us better in that regard.
That being said, when in Rome, I'll do as the romans do so feel free to confirm or reject my decisions and I'll happily update my PR !
dep
is awesome :)
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.
That's a good point, I hadn't thought of that! Personally I'm fine with the environment variable. Let's move forward with that for now. 👍
The next step is to get some tests that exercise changing the timeout. I don't know how easy/hard that will end up being so if you find yourself going down a rabbit hole, post back here and we can think about it more!
(peeking out from vacation) so, I agree that env vars are the generally correct way of doing this. but there some caveats. the first is one that @ereOn noted - this isn't a terribly scalable approach to handling this problem. ideally, I would prefer that we improve our activity detection mechanism so as to render custom configuration unnecessary, but that's a Hard Problem™, so it's best to assume there's a ceiling on what we can achieve there, and that it may not be adequate. the other problem is more mundane software design: this makes gps directly aware of its environment. in general, we try very hard to encapsulate gps, requiring the implementing application (here, dep) to pass on all configuration options, like this one. the problem with that is, there's no vector for this information to make it into gps right now. the only way we could do it, realistically, is to use context.Context values. I generally find those repugnant, but this situation might merit them. I need to cogitate on that a little more. I suspect I'll talk myself into it, though, which means it's worth following @carolynvs' advice and thinking about tests for this 😁 |
bit of an update - i think we're actually just going to get rid of these timeouts in a lot of cases. they're doing more harm than good. it's a minor refactor, but not awful. |
yeah, gonna close this in favor of #1110. thanks for the attempt at this, anyway! |
What does this do / why do we need it?
This PR allows users to override the various timeouts currently hard-coded within
dep
.We noticed that some of our developers constantly hit the 10s default command timeout when issuing a
dep ensure -update
in our current development environment. Some developers with the same environment manage to getdep ensure
to work, but we suspect they are very close to the 10s mark as well as the overrall command execution time is slow. It is unclear which commands exactly takes so long.This happens mostly on Windows.
One solution would be to raise the default timeout but... what "magic" value should we use ? I suspect that even if we raised it to 30s, some other people would still have the issue on even slower systems. Hence the rationale of making it overridable with environment variables.
What should your reviewer look out for in this PR?
It should not break the current behavior.
If a user sets
DEP_EXPENSIVE_CMD_TIMEOUT
orDEP_DEFAULT_CMD_TIMEOUT
,dep
honors these timeouts accordingly.Do you need help or clarification on anything?
Nope.
Which issue(s) does this PR fix?
None.