Repository navigation
Support for async execs. - #2214
Conversation
|
I wanted to open this open quickly (hence the draft) because I want to double check if the way I'm setting up an explicit dependency is actually sound: Above you can see the explicit dependency set on the line The thing is, _dep is not a field I have defined in #StopAsyncExec. In fact, this seems to work with any private field, i.e. you could write I feel like I'm missing something because it seems too easy, but it does work at least in this case AFAICT. I also tested briefly and found it worked for setting up multiple deps like My question is if this can be a solution to the problem of setting up explicit dependencies in general? Or (more likely) am I missing something that prevents us from using this everywhere. |
|
@sipsma This should work! But it does have some caveats. If |
There was a problem hiding this comment.
random suggestion: if it helps avoiding duplicating code, we could do something like:
Register("Exec", func() Task { return &execTask{} })
Register("AsyncExec", func() Task { return &execTask{async: true} })And then use the same task for both sync and async
There was a problem hiding this comment.
In this case it won't help more as all the deduplication already happens via the parseCommon func called by both methods, but that's a good idea in general to take advantage of struct params when helpful
|
Instead of a separate |
I think this is possible but I went with the separate types because even though there is a lot of overlap between the two, there are fields and requirements that are mutually exclusive to one or the other, e.g.:
If we made Let me know if you disagree of if there's a way of approaching this with cue that I'm not aware of. |
|
I see. My problem is that we have a lot of definitions on top of |
EDIT: Actually, I just remembered the |
|
@helderco I tried out combining the two types using In practice, this means that if you accidentally try to stop an Exec where In terms of higher-level packages, I actually don't think having separate |
Yes, that was my second thought in case doing it in core isn't ideal. |
856ba8b to
9e87ead
Compare
|
Re-pinging. Realize our main focus right now is elsewhere, but this new feature would be quite useful for some other things we are working on, such as being able to test complex workflows involving cache import/export (as described here). If we want to put this on hold I understand too though and can just use it in my fork for now. |
shykes
left a comment
There was a problem hiding this comment.
Thanks for the ping @sipsma
-
I agree this feature is much needed!
-
CUE API seems fine. I feel obligated to ask whether you considered making it a special case of
#Execsince it has so many fields in common. -
How exactly will we define "async" to developers, and explain when to use one versus the other?
-
Developers will ask: "why can't I kill a synchronous exec?" What will we answer?
-
Any thoughts on how we might integrate this in
docker?
Thanks!
|
(I just realized my point 2. has been addressed in earlier comments) |
There was a problem hiding this comment.
Not necessary, but we could use another (probably hidden) definition to pull out the commonalities between #Exec and #AsyncExec.
There was a problem hiding this comment.
Yeah I actually did that in an earlier revision but backtracked because I felt like it made it more difficult to know all the fields in each definition; you had to jump between the main def and the hidden separate one. No clear right answer though so let me know if you disagree.
|
Also, just wanted to note that I'm excited to have this! It'll unblock the changelog.com config that's been in stasis for while longer than I'd like. |
Here's a first shot, can expand in documentation followups to this PR:
Example use cases include:
The output of a synchronous ^^ This kind of ignores more subtleties to the issue here. BuildKit/Dagger doesn't actually force an
I mean on the most basic level we can obviously make a type that accepts a |
|
Thanks for the details @sipsma . I think calling them Wrappers would be |
9bb891b to
aea314e
Compare
This adds a new task type called Start which has a similar interface as Exec, but unblocks once the exec has started rather than waiting for it to complete. A separate type, Stop, can be used to stop it explicitly. If it isn't stopped, then it will be killed once the dagger client shutsdown. This is intended for creating ephemeral services used by other tasks in the DAG, such as a DB against which tests can be run in different tasks. Start cannot output state and any state they create while running will be thrown away once the DAG finishes executing. The only exception is if they use a shared cache mount, in which case state will be applied to the cache mount and accessible by other Execs, async or not. There is currently an issue with Buildkit where if the dagger client exits ungracefully without running cleanups, then the container will leak and keep running in Buildkit. There is also no way for a subsequent client to query what containers are running and delete any leaked ones, so the only remedy in this case would be restarting buildkitd. This is an issue that needs to be fixed Buildkit-side. Signed-off-by: Erik Sipsma <[email protected]>
Yeah I like that, updated with it. I would actually argue that along these same lines |
jlongtine
left a comment
There was a problem hiding this comment.
LGTM! ![]()
I'd love to chat some more about networking (single node to start) with this sometime soon!
|
👋 arriving a bit late to the party here. I love this feature and it's a great work indeed, congrats @sipsma!. Looking at the conversation the following comment raised my attention:
I'll bring a past experience that probably @shykes @samalba and @aluzzardi remember from the What happens if my async task starts but it shortly exists due to a transitory error? Dagger is going to mark the action as completed but then my tests are going to fail (or hang forever) because the async task exited with an error without me knowing about it. I believe it's worth challenging this UX to see if we can do better than docker-compose this time to avoid going through the same service dependency/healthiness limbo we experienced with compose. |
|
I agree that healthchecks is an important part of the DX for this. We should take responsibility for it, and not consider the feature completed until that dimension is successful. I love this. In terms of implementation, I want to make sure we keep all our options open. In particular, the more can be done in pure CUE, as opposed to hardcoded in the engine, the better. I think compose was not able to fully solve the problem, precisely because it doesn't have the luxury of a programmable platform: the only way for docker healthchecks to work in every application, is to implement everything in the core. We have the luxury of not doing that. |
agree. I'll create an issue to track this. It'd be great to catalog / group it under the
+1. I haven't fully processed the current implementation yet, I'll take a close look tomorrow 🙏
good point. I'm eager to see how we could |
|
By the way, another dimension which I am equally excited about is networking, more specifically client side proxying. In theory you can already hack together a compose equivalent with the current version, but at at a cost which I consider to be too high: losing magical infrastructure independence. There is only one reliable portable way to expose a port from a Dagger container to the outside world, and that is through a client proxy. Implementing that will have major, MAJOR implications for Dagger as a platform. |
|
Yeah I agree healthchecks are an important higher-level construct. Right now you'd implement them as a separate task that has a dependency on the async exec starting successfully. Then, instead of having other tasks put their dependency directly on the I'd argue that this is the right approach vs. trying to put something specifically inside the |
Just to double check, do you mean that the dagger client (i.e. whatever is running |
I agree :) |
Yes 👍 |
This adds a new task type called AsyncExec which has a similar interface
as Exec, but unblocks once the exec has started rather than waiting for
it to complete. A separate type, StopAsyncExec, can be used to stop it
explicitly. If it isn't stopped, then it will be killed once the dagger
client shutsdown.
This is intended for creating ephemeral services used by other tasks in
the DAG, such as a DB against which tests can be run in different tasks.
AsyncExecs cannot output state and any state they create while running
will be thrown away once the DAG finishes executing. The only exception
is if they use a shared cache mount, in which case state will be applied
to the cache mount and accessible by other Execs, async or not.
There is currently an issue with Buildkit where if the dagger client
exits ungracefully without running cleanups, then the container will
leak and keep running in Buildkit. There is also no way for a subsequent
client to query what containers are running and delete any leaked ones,
so the only remedy in this case would be restarting buildkitd. This is
an issue that needs to be fixed Buildkit-side.
Signed-off-by: Erik Sipsma [email protected]