moby / buildkit

concurrent, cache-efficient, and Dockerfile-agnostic builder toolkit
https://github.com/moby/moby/issues/34227
Apache License 2.0
7.83k stars 1.09k forks source link

Traces can be skipped when pulling down history records #5089

Open tonistiigi opened 5 days ago

tonistiigi commented 5 days ago

When history record is saved after build completed, the OpenTelemetry trace is not saved initially and instead there is a 3 second sleep https://github.com/moby/buildkit/blob/v0.14.1/solver/llbsolver/solver.go#L402 before this process starts in the background. This is because clients can report their own traces concurrently and not all traces may have arrived yet (actually they never have as the solve request from the client itself is also being traced).

This is problematic to github actions that export the history in the post step. If less than 3 second passes between build and post-step then the opentelemetry trace is skipped and missing from the export.

There should be some way to tell buildkit that no more traces are coming from client and it can finish up storing the trace. This would be an extra request client can do after it has confirmed that it has completed all the build-related work. The daemon needs to then block until it has completed saving the trace and only return after it is ready.