Repository navigation
Closed
Description
To reproduce on main (can also repro against v0.11.0 using the new modularized ci on main):
$ dagger call --source=. sdk go generate entries
sdk
(hangs here, even though the task is complete)
Dumping trace logs on the engine:
time="2024-04-08T11:58:34Z" level=trace msg="server removed" client_call_digest= client_hostname=daggerdoer client_id=jui8v1z5en9a42r1l9sncx1zp server_id=cl0so4twc5tpx6ggse1v4rpxa
time="2024-04-08T11:58:34Z" level=debug msg="session call done" client_call_digest= client_hostname=daggerdoer client_id=jui8v1z5en9a42r1l9sncx1zp register_client=true server_id=cl0so4twc5tpx6ggse1v4rpxa
time="2024-04-08T11:58:34Z" level=debug msg="exporting spans to pubsub" call=uvo90qb6cll202ijuzbgxa7ww spans=1
time="2024-04-08T11:58:34Z" level=debug msg="pubsub exporting span" call=uvo90qb6cll202ijuzbgxa7ww endTime="2024-04-08 11:58:34.317715668 +0000 UTC" id=6ce54437520d9481 span=moby.buildkit.v1.Control/Session status=Error trace=ad1f63c1d21669763c9995a867fa80ce
time="2024-04-08T11:58:34Z" level=debug msg="exporting spans to subscriber" spans=1 trace=ad1f63c1d21669763c9995a867fa80ce
time="2024-04-08T11:58:34Z" level=debug msg="waiting for spans" activeSpans=1 draining=true immediate=false trace=ad1f63c1d21669763c9995a867fa80ce
time="2024-04-08T11:58:34Z" level=debug msg="waiting for span" activeSpans=1 draining=true id=63b55c6f67dff984 immediate=false span=moby.buildkit.v1.Control/Session trace=ad1f63c1d21669763c9995a867fa80ce
The moby.buildkit.v1.Control/Session never seems to complete, so the client never seems to finish telemetry:
dagger/engine/client/client.go
Lines 471 to 473 in b583add
| if err := c.telemetry.Wait(); err != nil { | |
| rerr = errors.Join(rerr, fmt.Errorf("flush telemetry: %w", err)) | |
| } |
Not quite sure what's special about the sdk go generate job specifically, but it seems to consistently cause this hang on v0.11.0+. cc @vito, any ideas?
Metadata
Metadata
Assignees
Labels
No labels
Activity
jedevc commentedon Apr 8, 2024
Aha, I've found a reproducer - there appears to be something up with the
ExperimentalPrivilegedNestingoption being used in a dependent service.Threw together an integration test:
vito commentedon Apr 8, 2024
The telemetry draining is super conservative and waits for all in-flight spans to complete. My guess is that nesting starts a span corresponding to the nested session, but the process that spawned it just gets
kill -9ed from somewhere (e.g. ctx cancellation but not sure about the repro above) and is never able to cleanly end its child spans.For example, right now canceling/interrupting actually has to workaround this to avoid hanging because ctx cancellation just does a
kill -9, so if you poorly time that (and e.g.kill -9a Function that is running a child span) it'd lead to a hang. Instead we give interruption some kind of "immediate" flag that tells it not to wait for all spans.It's also possible we make the draining less conservative, but it's that way for a reason - showing unfinished spans in Cloud or the TUI is super confusing.
Maybe the long-term fix is to always implement "soft" cancellation, but that's hard because Buildkit doesn't expose that capability outside of the gateway API.
Another alternative could be "if a parent span exited, don't wait for its child spans" - but technically OpenTelemetry does not prescribe this behavior, for example you can have a parent span that spawns an async child span that outlives its parent. But still, maybe this would work best for us?
jedevc commentedon Apr 9, 2024
Bringing this out of the milestone, while technically this is a regression, this is fairly low priority IMO, since #7049 avoids this issue for us (we only hit it because of a misconfiguration in the first place).
sipsma commentedon May 17, 2024
Cross-posting this comment: #7387 (comment)
There's an integ test that repros hanging on OTEL draining easily and some
ExtraDebuglogs attachedstory(issue-125): bound Dagger Cloud telemetry drain + retry the hang
chore(ci): raise module-suite leg timeout from 6m to 12m