You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Networking errors after calling Sync() on Containers that have dependent Services #6493
I have a pipeline with multiple Services and Containers being passed around. If a Container that has a dependent service is Sync()'ed, future calls to the Service will fail with something like:
lookup 5r4dg8qetp2iq.r4mh9kocl49fi.dagger.local on 10.87.0.1:53: no such host
Based on @kpenfound's report, this works on v0.9.6, but doesn't on v0.9.7. Did a git bisect, and isolated the issue to #6425 (cc @sipsma).
9bf9f7f303b6768efbba540376a0bd6eae6979a3 is the first bad commit
commit 9bf9f7f303b6768efbba540376a0bd6eae6979a3
Author: Erik Sipsma <[email protected]>
Date: Mon Jan 15 16:14:37 2024 -0800
services: key services by server id; auto start cli service flags (#6425)
Thanks for tracking it down @jedevc! The connection between that change and this issue is extremely non-apparent at first glance, gonna need to look into it. Have 10k other things spinning atm so may not be for a few days but will get back here ASAP.
Spent a little time looking into this, I think the root problem is that #6425 intentionally results in services being shared across a single session (rather than isolated to single clients), but we continue to unconditionally stop services when any client in the session shuts down here, specifically in such a way that we don't actually update the state of the service to be "not running".
Worked fine in previous assumptions of services being tied to the client (who cares about updating the state if it's all going away anyways) but doesn't make sense anymore. I made a naive change to just call ss.Detach on the service instead in that code, but that seems to result in everything taking forever to execute (maybe due to the detach grace period?). Reached timebox for today on this, so to be continued.
The timing still seems wrong, when closing a client, we shouldn't close all the services on that server IMO. So it no longer gets left in an invalid state - but I think what happens is we spin up the service, then stop it, and then start it again.
Oh true. I should not declare victory while bleary-eyed.
This is tricky because the intent behind the shutdown is for it to happen synchronously as the client goes away so we don't see any services left in a running state from the event logs (e.g. in Cloud cc @marcosnils).
Perhaps we could do a detach like behavior, but at the server-level? Although I really wanted to avoid the last client from blocking on it, since that made the code so much neater (I guess there are legitimate reasons to do this though).
Yah, either of those options sound totally reasonable 🎉 I'll happily pick this up, rework my test to detect the multiple stop case, and try and find a fix.
(re-assigning to myself, but if you still want it @sipsma, feel free to steal it back 😆)
To clarify, I meant that we'd do both of those (detach when non-main-caller, force stop when main caller). But yes sounds good on you taking it from here, bandwidth is at a premium right now :-) thank you!
Sneaking this into v0.10.x just as a way to not forget about it - seems like we still need to figure this out, since it's kinda working but super janky that it restarts services, which is hard to notice
Activity
kpenfound commentedon Jan 24, 2024
Runnable example: https://github.com/kpenfound/example-voting-app/blob/daggerize/ci/main.go#L21-L25
jpadams commentedon Jan 24, 2024
Conversation: https://discord.com/channels/707636530424053791/1120503349599543376/1199329512203235349
sagikazarmark commentedon Jan 26, 2024
Same problem here: sagikazarmark/daggerverse#42
jedevc commentedon Jan 29, 2024
Based on @kpenfound's report, this works on v0.9.6, but doesn't on v0.9.7. Did a git bisect, and isolated the issue to #6425 (cc @sipsma).
sipsma commentedon Jan 29, 2024
Thanks for tracking it down @jedevc! The connection between that change and this issue is extremely non-apparent at first glance, gonna need to look into it. Have 10k other things spinning atm so may not be for a few days but will get back here ASAP.
sipsma commentedon Jan 30, 2024
Spent a little time looking into this, I think the root problem is that #6425 intentionally results in services being shared across a single session (rather than isolated to single clients), but we continue to unconditionally stop services when any client in the session shuts down here, specifically in such a way that we don't actually update the state of the service to be "not running".
Worked fine in previous assumptions of services being tied to the client (who cares about updating the state if it's all going away anyways) but doesn't make sense anymore. I made a naive change to just call
ss.Detachon the service instead in that code, but that seems to result in everything taking forever to execute (maybe due to the detach grace period?). Reached timebox for today on this, so to be continued.cc @vito
jedevc commentedon Jan 30, 2024
Got a test that seems to produce the desired issue on v0.9.7, but can't seem to repro on
mainfor whatever reason.jedevc commentedon Jan 30, 2024
It's weird, because I definitely would've expected this to continue to fail.
jedevc commentedon Jan 30, 2024
This is changed in #6354 - so maybe it's that
vito commentedon Jan 30, 2024
Yep that seems to be the case - specifically we now call
stopon the services tracker which deletes it from the maps 🎉https://github.com/dagger/dagger/pull/6354/files#diff-1ebb5e1bc419d06e30aafaf4b05f75270d16d82924c0afc6b8a2f3332d4bcd92R330
jedevc commentedon Jan 30, 2024
The timing still seems wrong, when closing a client, we shouldn't close all the services on that server IMO. So it no longer gets left in an invalid state - but I think what happens is we spin up the service, then stop it, and then start it again.
vito commentedon Jan 30, 2024
Oh true. I should not declare victory while bleary-eyed.
This is tricky because the intent behind the shutdown is for it to happen synchronously as the client goes away so we don't see any services left in a running state from the event logs (e.g. in Cloud cc @marcosnils).
jedevc commentedon Jan 30, 2024
Perhaps we could do a detach like behavior, but at the server-level? Although I really wanted to avoid the last client from blocking on it, since that made the code so much neater (I guess there are legitimate reasons to do this though).
nipuna-perera commentedon Jan 31, 2024
I get a similar error even without calling
sync(). Basically trying to attach a docker daemon as a sidecar. Similar to this - https://github.com/kpenfound/dagger-modules/blob/main/dockerd/main.gosipsma commentedon Jan 31, 2024
Yeah @jedevc after running again w/ your fix I can't repro with Kyle's voting app example anymore either 🎉
To address the remaining weirdness around stopping too often, could we:
StopClientServiceswhen it's coming from a non-main-caller (i.e. a module function call)?
jedevc commentedon Jan 31, 2024
Yah, either of those options sound totally reasonable 🎉 I'll happily pick this up, rework my test to detect the multiple stop case, and try and find a fix.
(re-assigning to myself, but if you still want it @sipsma, feel free to steal it back 😆)
sipsma commentedon Jan 31, 2024
To clarify, I meant that we'd do both of those (detach when non-main-caller, force stop when main caller). But yes sounds good on you taking it from here, bandwidth is at a premium right now :-) thank you!
kpenfound commentedon Feb 8, 2024
Confirmed things are working for my case in 0.9.8!
vito commentedon Mar 1, 2024
Sneaking this into v0.10.x just as a way to not forget about it - seems like we still need to figure this out, since it's kinda working but super janky that it restarts services, which is hard to notice
synchronously detach services on main client exit
Switch from Progrock to OpenTelemetry (dagger#6835)
fix(test): remove Sync() call on service-bound container in UI tests