This commit fixes more issues where vertex progress updates were using
the same ID and incorrectly deduplicating with each other. A previous
commit addressed this in solver/jobs.go but the same problem existed
elsewhere.
The update results in a random ID being used for vertex start/stop
events as it is the simplest approach that works everywhere in a
consistent pattern.
Signed-off-by: Erik Sipsma <erik@sipsma.dev>
A panic was encountered where writes to progress status hit a nil
writer. While not easy to reproduce, this commit fixes a likely culprit.
The use of atomics in the controller was not safe against a race such as
the following:
1. One goroutine calls Start, incrementing count but not yet setting
writer.
2. A second goroutine calls Start, increments count again but sees that
count >1 and thus doesn't try to set writer.
3. The second goroutine then calls Status, assuming the writer has been
set, but the first goroutine still hasn't set the writer yet, causing
a nil pointer exception.
This commit fixes that issue by just using a mutex instead of atomics.
It also adds a nil check for the writer just to be safe against panics
due to unknown issues in the future as missing a status update is much
better than buildkitd crashing.
Signed-off-by: Erik Sipsma <erik@sipsma.dev>
This allows clients to specify that LLB states should be grouped in
progress output under a custom name. Status updates for all vertexes in
the group will show up under a single vertex in the output.
The intended use cases are for Dockerfile COPY's that use MergeOp as a
backend and for grouping some other internal vertexes during frontend
builds.
Signed-off-by: Erik Sipsma <erik@sipsma.dev>