Serve grpc.health.v1.Health on the build session so BuildKit does not drop it - #847
Open
punkpeye wants to merge 1 commit into
Open
Serve grpc.health.v1.Health on the build session so BuildKit does not drop it#847punkpeye wants to merge 1 commit into
punkpeye wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
BuildKit builds started through
docker.buildImage(..., { version: '2' })intermittently stall and never produce an image. Under concurrency it becomes the common case. The build hangs at the first vertex, usually[internal] load metadata for <base image>, and the daemon logs:Because the failure names the base image, it is easy to misread as a registry outage or a bad
FROM, but the registry is never reached.Cause
withSession()opens the gRPC session BuildKit uses for auth and the build context, and registers themoby.filesync.v1.Authservice on it. Recent BuildKit health-checks that session overgrpc.health.v1.Health/Checkand tears the session down after two consecutive failures (seemoby/buildkitsession/grpc.go:interval 5s,failureThreshold 2). Since the session serves no Health service, every check returnsUNIMPLEMENTED, so BuildKit drops the session ~10s in. A build that clears the session-dependent phase before then succeeds; one that does not stalls, which is why the failure rate rises with the number of in-flight builds.Fix
Register a minimal
grpc.health.v1.Healthservice on the session that answersSERVINGfor bothCheckandWatch. This is what a compliant BuildKit client is expected to provide. No API change; it only adds a service to the session's gRPC server.Adds
lib/proto/health.proto(the standard gRPC health protocol) and registers the service inlib/session.js, mirroring how the Auth service is loaded and added.Verification
Against a rootless Docker Engine 29.6.2 / BuildKit builder that reproduces the drop:
healthcheck failed fatally: Unimplementedand thenno active sessionfor the session's UUID, and the build hangs.FROM debian:bookworm-slim+RUNbuild completes end to end in ~13s, pastload metadata, producing an image.