Repository navigation
Backport: services via gateway, minus API changes - #5764
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
971ddee to
43f278e
Compare
This comment was marked as resolved.
This comment was marked as resolved.
43f278e to
5689e6a
Compare
This comment was marked as outdated.
This comment was marked as outdated.
|
Sorry @vito, I should have given an heads up that I spent a bit of time today taking care of the Python bit. I'll replace it in a minute. |
|
@helderco All good, feel free to replace it! 🙏 |
|
@vito re various SDKs:
|
|
The reverts were from a GUI, weren't signed-off, I'm going to force push to fix. |
|
Yep, I will handle the follow up inconsistencies for rust, if the tests don't complain that is. |
c169a35 to
027fd3e
Compare
|
@vito what should be the behavior in |
|
@helderco That's a good question. It seems that we should only call So with that rule, it seems most correct to not call For Zenith/Dagger-in-Dagger, we can work with the above constraint by having it automatically do the equivalent of the In that case I think the current Go, NodeJS, and Elixir SDKs implementations are not right as they will unconditionally stop no matter what the internal connection type is. Thinking about it more, if we're now saying this only needs to happen only in the case where a |
Yes, a graceful shutdown. 👍 |
sipsma
left a comment
There was a problem hiding this comment.
Left some comments, saw after I started reviewing that you're making a few more updates so apologies if a few of the comments are more nit-picky than is helpful now :-)
Signed-off-by: Alex Suraci <[email protected]>
Ran into a few panics/cryptic errors here while switching services over to the gateway. I don't remember exactly if these were fixed (a lot happened between now and then) but it seems worth committing anyway. Also, change ResolveImageConfig to be a passthru along the way, for no real reason. Signed-off-by: Alex Suraci <[email protected]>
* Service is now a distinct type, but only used internally * Services now run via the gateway interface instead * (core.Container).Service returns a Service that runs the container * Services can be explicitly started and stopped (not exposed yet) * refactor ServiceBindings, merge with HostAliases * embed a Service instead of a ServiceID Signed-off-by: Alex Suraci <[email protected]>
027fd3e to
35fdd1d
Compare
|
Pushed a prospective switch to a new internal HTTP endpoint, |
51343c9 to
7808c25
Compare
This reverts commits c142c49 and 51429e5. Signed-off-by: Helder Correia <[email protected]>
The Python SDK has multiple types of connections which are decoupled from the client instance. It would be more natural to call `client.stop()` when automatically closing that connection but that's in a lower level. Both `dagger.Connection` (legacy) and `dagger.connection` (experimental) support automatic provisioning, so pushed the common client setup to the engine connection manager. The connect timeout was documented as 10.0 but set as 30.0 by mistake during development of the default client. Using the same value for stop to avoid adding more settings. It could be better documented but the timeout setting is in the middle of a change in format (see Config.__post_init__). This can all be revisited later. To simplify the use case of codegen starting out with a blank `gen.py` file, it's now required to run under an existing session like `dagger run`. Note that this type of connection doesn't setup a client and so it doesn't add the `client.stop` as well. Signed-off-by: Helder Correia <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
* Get: fix missing Unlock * Start: use a good old loop + label to fix case where multiple Starts are waiting, and the first Start fails. Signed-off-by: Alex Suraci <[email protected]>
use a loop; if multiple start attempts overlap we can just keep waiting Signed-off-by: Alex Suraci <[email protected]>
dd28a40 to
517eecc
Compare
TomChv
left a comment
There was a problem hiding this comment.
Changes looks, I need to try on my local host to verify if everything is okay.
Will the SDK clients have an update? I saw the old implementation and see that we now use shutdown but as far as I understand, this is supported to be called by the client?
Do I need to wait before my attempt to test the PR?
|
@TomChv Thanks for taking a look! SDKs no longer need updating - I'll minimize those comments to avoid confusion. This PR is ready for review + testing, but I'm going to add some unit tests for the extra-tricky service lifecycle synchronization since @sipsma noticed some bugs there. They're theoretically fixed now, but I would like to have higher confidence in it. |
also remove Service from RunningService; not needed Signed-off-by: Alex Suraci <[email protected]>
refactor stub service along the way Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
3390a1d to
4428189
Compare
|
Fully ready now! Backfilled unit tests for the tricky service lifecycle and did some follow-up cleanups. |
| // shutdown happens outside of c.closeMu, since it requires a connection | ||
| if err := c.shutdownServer(); err != nil { | ||
| rerr = errors.Join(rerr, fmt.Errorf("shutdown: %w", err)) | ||
| } |
There was a problem hiding this comment.
This solution is great!!! We don't need to deal with each SDK now. 👍
|
LGTM from the integration testing perspective. |
jpadams
left a comment
There was a problem hiding this comment.
From my perspective of testing this live, I've had no issues with this at all. Seems super solid to me.
|
@TomChv any blocker to you giving this the 👍 |
gerhard
left a comment
There was a problem hiding this comment.
This was a pleasure to read! Straightforward code, good tests & some nice refactorings along the way. While we don't have the new API yet - I was especially excited about not starting services when ops that require them are cached - everything else works as expected.
Before this PR, services wouldn't show as stopped in the interactive TUI (@jpadams mentioned it in the context of Cloud):
before-this-pr-service-in-interactive-tui.mp4
With the changes in this PR, services show as stopped:
after-this-pr-service-in-interactive-tui.mp4
Same command with dagger run --debug:
after-this-pr.mp4
@vito what would you like to add to the changelog, via changie new?
Signed-off-by: Alex Suraci <[email protected]>
|
@marcosnils @jpadams @gerhard Thanks so much for the thorough testing!
Added one! The best one-line summary I could come up with was "services: refactor to per-client instances that stop on client close." |




Fixes https://linear.app/dagger/issue/DEV-2436/services-in-cloud-are-always-left-under-running-starting-from-dagger
This is a halfway step to #5557 that hoists over its internal changes while keeping the existing API unchanged.