-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Enable WCOW custom frontends to communicate with BuildKit via named pipe bridge #5868
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
5804377
to
00a8147
Compare
00a8147
to
60d6695
Compare
c49d3ce
to
941a28b
Compare
47512e2
to
858e9ab
Compare
cb88c54
to
d43314a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reason stdio FDs would not work for wcow? It doesn't have any dependency on UNIX sockets, just that containers have stdin and stdout capability.
if v, ok := ctx.Value(appdefaults.ContextKeyCustomFrontend).(bool); ok && v { | ||
sid := func() string { | ||
for _, e := range meta.Env { | ||
if strings.HasPrefix(e, "BUILDKIT_SESSION_ID=") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make this local const
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also maybe BUILDKIT_FRONTEND_GRPC_PIPE_ID
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also maybe
BUILDKIT_FRONTEND_GRPC_PIPE_ID
got little bit lost here , did you switching BUILDKIT_SESSION_ID
with BUILDKIT_FRONTEND_GRPC_PIPE_ID
or naming const BUILDKIT_FRONTEND_GRPC_PIPE_ID
frontend/gateway/gateway.go
Outdated
@@ -514,11 +517,20 @@ func serveLLBBridgeForwarder(ctx context.Context, llbBridge frontend.FrontendLLB | |||
pb.RegisterLLBBridgeServer(server, lbf) | |||
|
|||
go func() { | |||
if isWindowsPlatform { | |||
listener = createNPipeListener(sid) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if sessionID should be used for this? SessionID can be controlled by the user, but this one looks like something that should be internal (like a private property on llbBridge maybe)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am using the session ID as a suffix to the named pipe to ensure uniqueness and avoid collisions during parallel builds. I’m not sure the idea of a private property on llbBridge guarantees uniqueness unless it generates something like a UUID per build, and it would still need to be passed as an environment variable for the container process to access. Open to your suggestions on a better approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I meant still some unique ID but something that can't be controlled from the client side and is purely internal in the llbBridge.
489fecc
to
1bf2b7f
Compare
I encountered the error The successful resolution with a named pipe without modifying the frontend code strongly indicates that STDIO is unreliable in WCOW buildkit custom frontend scenarios[I have to get better reasons why that is the case, but one possibility could be the container child process might not have inherited the STDOUT handle].
|
Why would this matter? Where do we open |
|
1bf2b7f
to
0f5b443
Compare
2b33214
to
5eafea6
Compare
Signed-off-by: Billy Owire <billyowire95@gmail.com>
5eafea6
to
21b4850
Compare
PR adds support for custom frontends in WCOW by enabling gRPC communication from the container child process to the BuildKit in host machine via a named pipe.
Currently, the custom frontend bridge uses stdio file descriptors (FDs), which work well for Linux container child processes and also work in Windows containers. However, they are not supported for communication between WCOW container 'child' processes and the host machine process. As a result, custom frontends running in Windows containers are unable to communicate with the host machine's BuildKit instance
This change:
\\.\pipe\buildkit-frontend-bridge
) specifically for WCOW custom frontend containers.Fixes #4892
Guide to test
STEP 1.
Compile frontend binary
You can use go code in this location: https://github.com/moby/buildkit/blob/master/frontend/dockerfile/cmd/dockerfile-frontend/main.go
use
go build -o ...
to createdockerfile-frontend.exe
STEP 2.
Build frontend image and push it your docker hub
The dockerfile contents to build the frontend image:
Can use this buildctl command to build frontend image
STEP 3.
Use the frontend image in your docker builds
say you have a dockerfile below, notice the use of #syntax to make use of your custom dockerfile frontend
yourdockerhuburl/dockerfrontend:latest
comes from the image you pushed in step 2