From 6faf7e568807efbc4ea9c84989850d270946f746 Mon Sep 17 00:00:00 2001 From: Justin Chadwell Date: Tue, 20 Jun 2023 12:40:41 +0100 Subject: [PATCH] tests: set a dedicated buildx config dir for each worker This should help reduce any unexpected config conflict between workers. Signed-off-by: Justin Chadwell (cherry picked from commit 6f394a06919a5271f7423e9778889841a6550832) Signed-off-by: Sebastiaan van Stijn --- tests/integration.go | 1 + tests/workers/docker-container.go | 6 +++++- tests/workers/docker.go | 2 ++ tests/workers/remote.go | 2 ++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/integration.go b/tests/integration.go index 538cf6bd..bbb59c35 100644 --- a/tests/integration.go +++ b/tests/integration.go @@ -47,6 +47,7 @@ func buildxCmd(sb integration.Sandbox, opts ...cmdOpt) *exec.Cmd { if builder := sb.Address(); builder != "" { cmd.Args = append(cmd.Args, "--builder="+builder) + cmd.Env = append(cmd.Env, "BUILDX_CONFIG=/tmp/buildx-"+builder) } if context := sb.DockerAddress(); context != "" { cmd.Env = append(cmd.Env, "DOCKER_CONTEXT="+context) diff --git a/tests/workers/docker-container.go b/tests/workers/docker-container.go index b57c7e87..de6a78bd 100644 --- a/tests/workers/docker-container.go +++ b/tests/workers/docker-container.go @@ -50,7 +50,11 @@ func (w *containerWorker) New(ctx context.Context, cfg *integration.BackendConfi "--driver=docker-container", "--driver-opt=network=host", ) - cmd.Env = append(os.Environ(), "DOCKER_CONTEXT="+w.docker.DockerAddress()) + cmd.Env = append( + os.Environ(), + "BUILDX_CONFIG=/tmp/buildx-"+name, + "DOCKER_CONTEXT="+w.docker.DockerAddress(), + ) if err := cmd.Run(); err != nil { return nil, nil, errors.Wrapf(err, "failed to create buildx instance %s", name) } diff --git a/tests/workers/docker.go b/tests/workers/docker.go index 380190ac..3ba32940 100644 --- a/tests/workers/docker.go +++ b/tests/workers/docker.go @@ -2,6 +2,7 @@ package workers import ( "context" + "os" "os/exec" "github.com/moby/buildkit/identity" @@ -41,6 +42,7 @@ func (c dockerWorker) New(ctx context.Context, cfg *integration.BackendConfig) ( name, "--docker", "host="+bk.DockerAddress(), ) + cmd.Env = append(os.Environ(), "BUILDX_CONFIG=/tmp/buildx-"+name) if err := cmd.Run(); err != nil { return bk, cl, errors.Wrapf(err, "failed to create buildx instance %s", name) } diff --git a/tests/workers/remote.go b/tests/workers/remote.go index b2bd7570..e1d08ab8 100644 --- a/tests/workers/remote.go +++ b/tests/workers/remote.go @@ -2,6 +2,7 @@ package workers import ( "context" + "os" "os/exec" "github.com/moby/buildkit/identity" @@ -41,6 +42,7 @@ func (w remoteWorker) New(ctx context.Context, cfg *integration.BackendConfig) ( "--driver=remote", bk.Address(), ) + cmd.Env = append(os.Environ(), "BUILDX_CONFIG=/tmp/buildx-"+name) if err := cmd.Run(); err != nil { return nil, nil, errors.Wrapf(err, "failed to create buildx instance %s", name) }