Skip to content

Commit

Permalink
build: fix localstate for remote context
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <[email protected]>
  • Loading branch information
crazy-max committed Jun 28, 2024
1 parent d4b112a commit 42f1086
Show file tree
Hide file tree
Showing 5 changed files with 142 additions and 24 deletions.
43 changes: 22 additions & 21 deletions build/localstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,32 @@ func saveLocalState(so *client.SolveOpt, target string, opts Options, node build
if so.Ref == "" {
return nil
}
lp := opts.Inputs.ContextPath
dp := opts.Inputs.DockerfilePath
if lp != "" || dp != "" {
if lp != "" {
lp, err = filepath.Abs(lp)
if err != nil {
return err
}
var lp, dp string
if opts.Inputs.ContextPath != "" && !IsRemoteURL(opts.Inputs.ContextPath) {
lp, err = filepath.Abs(opts.Inputs.ContextPath)
if err != nil {
return err
}
if dp != "" {
dp, err = filepath.Abs(dp)
}
if opts.Inputs.DockerfilePath != "" {
if !IsRemoteURL(opts.Inputs.ContextPath) {
dp, err = filepath.Abs(opts.Inputs.DockerfilePath)
if err != nil {
return err
}
} else {
dp = opts.Inputs.DockerfilePath
}
l, err := localstate.New(configDir)
if err != nil {
return err
}
return l.SaveRef(node.Builder, node.Name, so.Ref, localstate.State{
Target: target,
LocalPath: lp,
DockerfilePath: dp,
GroupRef: opts.GroupRef,
})
}
return nil
l, err := localstate.New(configDir)
if err != nil {
return err
}
return l.SaveRef(node.Builder, node.Name, so.Ref, localstate.State{
Context: opts.Inputs.ContextPath,
Target: target,
LocalPath: lp,
DockerfilePath: dp,
GroupRef: opts.GroupRef,
})
}
8 changes: 6 additions & 2 deletions localstate/localstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ const (
)

type State struct {
// Context is the build context
Context string
// Target is the name of the invoked target (default if empty)
Target string
// LocalPath is the absolute path to the context
// LocalPath is the absolute path to the context or empty if context is
// remote
LocalPath string
// DockerfilePath is the absolute path to the Dockerfile
// DockerfilePath is the absolute path to the Dockerfile or relative if
// context is remote
DockerfilePath string
// GroupRef is the ref of the state group that this ref belongs to
GroupRef string `json:",omitempty"`
Expand Down
4 changes: 4 additions & 0 deletions localstate/localstate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ var (

testStateRefID = "32n3ffqrxjw41ok5zxd2qhume"
testStateRef = State{
Context: ".",
Target: "default",
LocalPath: "/home/foo/github.com/docker/docker-bake-action",
DockerfilePath: "/home/foo/github.com/docker/docker-bake-action/dev.Dockerfile",
Expand All @@ -75,6 +76,7 @@ var (

testStateGroupRef1ID = "hx2qf1w11qvz1x3k471c5i8xw"
testStateGroupRef1 = State{
Context: ".",
Target: "format",
LocalPath: "/home/foo/github.com/docker/docker-bake-action",
DockerfilePath: "/home/foo/github.com/docker/docker-bake-action/dev.Dockerfile",
Expand All @@ -83,6 +85,7 @@ var (

testStateGroupRef2ID = "968zj0g03jmlx0s8qslnvh6rl"
testStateGroupRef2 = State{
Context: ".",
Target: "build",
LocalPath: "/home/foo/github.com/docker/docker-bake-action",
DockerfilePath: "/home/foo/github.com/docker/docker-bake-action/dev.Dockerfile",
Expand All @@ -91,6 +94,7 @@ var (

testStateGroupRef3ID = "naf44f9i1710lf7y12lv5hb1z"
testStateGroupRef3 = State{
Context: ".",
Target: "vendor-update",
LocalPath: "/home/foo/github.com/docker/docker-bake-action",
DockerfilePath: "/home/foo/github.com/docker/docker-bake-action/dev.Dockerfile",
Expand Down
102 changes: 102 additions & 0 deletions tests/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/containerd/containerd/platforms"
"github.com/containerd/continuity/fs/fstest"
"github.com/creack/pty"
"github.com/docker/buildx/localstate"
"github.com/docker/buildx/util/gitutil"
"github.com/moby/buildkit/client"
"github.com/moby/buildkit/frontend/subrequests/lint"
Expand Down Expand Up @@ -44,6 +45,8 @@ var buildTests = []func(t *testing.T, sb integration.Sandbox){
testBuild,
testBuildStdin,
testBuildRemote,
testBuildLocalState,
testBuildLocalStateRemote,
testImageIDOutput,
testBuildLocalExport,
testBuildRegistryExport,
Expand Down Expand Up @@ -122,6 +125,105 @@ COPY foo /foo
require.FileExists(t, filepath.Join(dirDest, "foo"))
}

func testBuildLocalState(t *testing.T, sb integration.Sandbox) {
dockerfile := []byte(`
FROM busybox:latest AS base
COPY foo /etc/foo
RUN cp /etc/foo /etc/bar
FROM scratch
COPY --from=base /etc/bar /bar
`)
dir := tmpdir(
t,
fstest.CreateFile("build.Dockerfile", dockerfile, 0600),
fstest.CreateFile("foo", []byte("foo"), 0600),
)

out, err := buildCmd(sb, withDir(dir), withArgs(
"-f", "build.Dockerfile",
"--metadata-file", filepath.Join(dir, "md.json"),
".",
))
require.NoError(t, err, out)

dt, err := os.ReadFile(filepath.Join(dir, "md.json"))
require.NoError(t, err)

type mdT struct {
BuildRef string `json:"buildx.build.ref"`
}
var md mdT
err = json.Unmarshal(dt, &md)
require.NoError(t, err)

ls, err := localstate.New(buildxConfig(sb))
require.NoError(t, err)

refParts := strings.Split(md.BuildRef, "/")
require.Len(t, refParts, 3)

ref, err := ls.ReadRef(refParts[0], refParts[1], refParts[2])
require.NoError(t, err)
require.NotNil(t, ref)
require.Equal(t, dir, ref.Context)

Check failure on line 169 in tests/build.go

View workflow job for this annotation

GitHub Actions / test-integration (master, docker-container, ./tests)

Failed: tests/TestIntegration/TestBuildLocalState/worker=docker-container

=== RUN TestIntegration/TestBuildLocalState/worker=docker-container === PAUSE TestIntegration/TestBuildLocalState/worker=docker-container === CONT TestIntegration/TestBuildLocalState/worker=docker-container build.go:169: Error Trace: /src/tests/build.go:169 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:96 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:211 Error: Not equal: expected: "/tmp/TestIntegrationTestBuildLocalStateworker=docker-container2463554833/001" actual : "." Diff: --- Expected +++ Actual @@ -1 +1 @@ -/tmp/TestIntegrationTestBuildLocalStateworker=docker-container2463554833/001 +. Test: TestIntegration/TestBuildLocalState/worker=docker-container --- FAIL: TestIntegration/TestBuildLocalState/worker=docker-container (1.62s)

Check failure on line 169 in tests/build.go

View workflow job for this annotation

GitHub Actions / test-integration (master, remote, ./tests)

Failed: tests/TestIntegration/TestBuildLocalState/worker=remote

=== RUN TestIntegration/TestBuildLocalState/worker=remote === PAUSE TestIntegration/TestBuildLocalState/worker=remote === CONT TestIntegration/TestBuildLocalState/worker=remote build.go:169: Error Trace: /src/tests/build.go:169 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:96 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:211 Error: Not equal: expected: "/tmp/TestIntegrationTestBuildLocalStateworker=remote3895042742/001" actual : "." Diff: --- Expected +++ Actual @@ -1 +1 @@ -/tmp/TestIntegrationTestBuildLocalStateworker=remote3895042742/001 +. Test: TestIntegration/TestBuildLocalState/worker=remote sandbox.go:133: stdout: /usr/bin/buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --config=/tmp/bktest_config2543364460/buildkitd.toml --root /tmp/bktest_buildkitd3589085917 --addr unix:///tmp/bktest_buildkitd3589085917/buildkitd.sock --debug sandbox.go:133: stderr: /usr/bin/buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --config=/tmp/bktest_config2543364460/buildkitd.toml --root /tmp/bktest_buildkitd3589085917 --addr unix:///tmp/bktest_buildkitd3589085917/buildkitd.sock --debug sandbox.go:136: > StartCmd 2024-06-28 09:54:30.065565428 +0000 UTC m=+9.245099294 /usr/bin/buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --config=/tmp/bktest_config2543364460/buildkitd.toml --root /tmp/bktest_buildkitd3589085917 --addr unix:///tmp/bktest_buildkitd3589085917/buildkitd.sock --debug sandbox.go:136: time="2024-06-28T09:54:30Z" level=warning msg="failed to get disk size: no such file or directory" sandbox.go:136: time="2024-06-28T09:54:30Z" level=warning msg="failed to get disk size: no such file or directory" sandbox.go:136: time="2024-06-28T09:54:30Z" level=info msg="auto snapshotter: using overlayfs" sandbox.go:136: time="2024-06-28T09:54:30Z" level=warning msg="using host network as the default" sandbox.go:136: time="2024-06-28T09:54:30Z" level=info msg="found worker \"k2n792dll2qjgddikxwkto31i\", labels=map[org.mobyproject.buildkit.worker.executor:oci org.mobyproject.buildkit.worker.hostname:fbac1793e438 org.mobyproject.buildkit.worker.network:host org.mobyproject.buildkit.worker.oci.process-mode:sandbox org.mobyproject.buildkit.worker.sandbox:true org.mobyproject.buildkit.worker.selinux.enabled:false org.mobyproject.buildkit.worker.snapshotter:overlayfs], platforms=[linux/amd64 linux/amd64/v2 linux/amd64/v3 linux/arm64 linux/riscv64 linux/ppc64le linux/s390x linux/386 linux/mips64le linux/mips64 linux/arm/v7 linux/arm/v6]" sandbox.go:136: time="2024-06-28T09:54:30Z" level=info msg="found 1 workers, default=\"k2n792dll2qjgddikxwkto31i\"" sandbox.go:136: time="2024-06-28T09:54:30Z" level=warning msg="currently, only the default worker can be used." sandbox.go:136: time="2024-06-28T09:54:30Z" level=info msg="running server on /tmp/bktest_buildkitd3589085917/buildkitd.sock" sandbox.go:136: time="2024-06-28T09:54:30Z" level=debug msg="session started" sandbox.go:136: time="2024-06-28T09:54:30Z" level=debug msg="session finished: <nil>" sandbox.go:136: time="2024-06-28T09:54:30Z" level=debug msg="session started" sandbox.go:136: time="2024-06-28T09:54:30Z" level=debug msg="new ref for local: fp7av754j5achmtfjqt6kxx98" span="[internal] load build definition from build.Dockerfile" sandbox.go:136: time="2024-06-28T09:54:30Z" level=debug msg="diffcopy took: 4.020667ms" span="[internal] load build definition from build.Dockerfile" sandbox.go:136: time="2024-06-28

Check failure on line 169 in tests/build.go

View workflow job for this annotation

GitHub Actions / test-integration (latest, docker-container, ./tests)

Failed: tests/TestIntegration/TestBuildLocalState/worker=docker-container

=== RUN TestIntegration/TestBuildLocalState/worker=docker-container === PAUSE TestIntegration/TestBuildLocalState/worker=docker-container === CONT TestIntegration/TestBuildLocalState/worker=docker-container build.go:169: Error Trace: /src/tests/build.go:169 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:96 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:211 Error: Not equal: expected: "/tmp/TestIntegrationTestBuildLocalStateworker=docker-container18694963/001" actual : "." Diff: --- Expected +++ Actual @@ -1 +1 @@ -/tmp/TestIntegrationTestBuildLocalStateworker=docker-container18694963/001 +. Test: TestIntegration/TestBuildLocalState/worker=docker-container --- FAIL: TestIntegration/TestBuildLocalState/worker=docker-container (1.72s)

Check failure on line 169 in tests/build.go

View workflow job for this annotation

GitHub Actions / test-integration (latest, remote, ./tests)

Failed: tests/TestIntegration/TestBuildLocalState/worker=remote

=== RUN TestIntegration/TestBuildLocalState/worker=remote === PAUSE TestIntegration/TestBuildLocalState/worker=remote === CONT TestIntegration/TestBuildLocalState/worker=remote build.go:169: Error Trace: /src/tests/build.go:169 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:96 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:211 Error: Not equal: expected: "/tmp/TestIntegrationTestBuildLocalStateworker=remote363017159/001" actual : "." Diff: --- Expected +++ Actual @@ -1 +1 @@ -/tmp/TestIntegrationTestBuildLocalStateworker=remote363017159/001 +. Test: TestIntegration/TestBuildLocalState/worker=remote sandbox.go:133: stdout: /usr/bin/buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --config=/tmp/bktest_config34329097/buildkitd.toml --root /tmp/bktest_buildkitd3686090767 --addr unix:///tmp/bktest_buildkitd3686090767/buildkitd.sock --debug sandbox.go:133: stderr: /usr/bin/buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --config=/tmp/bktest_config34329097/buildkitd.toml --root /tmp/bktest_buildkitd3686090767 --addr unix:///tmp/bktest_buildkitd3686090767/buildkitd.sock --debug sandbox.go:136: > StartCmd 2024-06-28 09:54:26.952662982 +0000 UTC m=+9.658888876 /usr/bin/buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --config=/tmp/bktest_config34329097/buildkitd.toml --root /tmp/bktest_buildkitd3686090767 --addr unix:///tmp/bktest_buildkitd3686090767/buildkitd.sock --debug sandbox.go:136: time="2024-06-28T09:54:27Z" level=warning msg="failed to get disk size: no such file or directory" sandbox.go:136: time="2024-06-28T09:54:27Z" level=warning msg="failed to get disk size: no such file or directory" sandbox.go:136: time="2024-06-28T09:54:27Z" level=info msg="auto snapshotter: using overlayfs" sandbox.go:136: time="2024-06-28T09:54:27Z" level=warning msg="using host network as the default" sandbox.go:136: time="2024-06-28T09:54:27Z" level=info msg="found worker \"z9g80lmo1cegjp96275n4hzai\", labels=map[org.mobyproject.buildkit.worker.executor:oci org.mobyproject.buildkit.worker.hostname:c557414d2644 org.mobyproject.buildkit.worker.network:host org.mobyproject.buildkit.worker.oci.process-mode:sandbox org.mobyproject.buildkit.worker.sandbox:true org.mobyproject.buildkit.worker.selinux.enabled:false org.mobyproject.buildkit.worker.snapshotter:overlayfs], platforms=[linux/amd64 linux/amd64/v2 linux/amd64/v3 linux/arm64 linux/riscv64 linux/ppc64le linux/s390x linux/386 linux/mips64le linux/mips64 linux/arm/v7 linux/arm/v6]" sandbox.go:136: time="2024-06-28T09:54:27Z" level=info msg="found 1 workers, default=\"z9g80lmo1cegjp96275n4hzai\"" sandbox.go:136: time="2024-06-28T09:54:27Z" level=warning msg="currently, only the default worker can be used." sandbox.go:136: time="2024-06-28T09:54:27Z" level=info msg="running server on /tmp/bktest_buildkitd3686090767/buildkitd.sock" sandbox.go:136: time="2024-06-28T09:54:27Z" level=debug msg="session started" sandbox.go:136: time="2024-06-28T09:54:27Z" level=debug msg="session finished: <nil>" sandbox.go:136: time="2024-06-28T09:54:27Z" level=debug msg="session started" sandbox.go:136: time="2024-06-28T09:54:27Z" level=debug msg="new ref for local: criqg0p2yfupfiyqjrc10fh3q" span="[internal] load build definition from build.Dockerfile" sandbox.go:136: time="2024-06-28T09:54:27Z" level=debug msg="diffcopy took: 5.76853ms" span="[internal] load build definition from build.Dockerfile" sandbox.go:136: time="2024-06-28T09:54:27

Check failure on line 169 in tests/build.go

View workflow job for this annotation

GitHub Actions / test-integration (buildx-stable-1, docker-container, ./tests)

Failed: tests/TestIntegration/TestBuildLocalState/worker=docker-container

=== RUN TestIntegration/TestBuildLocalState/worker=docker-container === PAUSE TestIntegration/TestBuildLocalState/worker=docker-container === CONT TestIntegration/TestBuildLocalState/worker=docker-container build.go:169: Error Trace: /src/tests/build.go:169 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:96 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:211 Error: Not equal: expected: "/tmp/TestIntegrationTestBuildLocalStateworker=docker-container1414386338/001" actual : "." Diff: --- Expected +++ Actual @@ -1 +1 @@ -/tmp/TestIntegrationTestBuildLocalStateworker=docker-container1414386338/001 +. Test: TestIntegration/TestBuildLocalState/worker=docker-container --- FAIL: TestIntegration/TestBuildLocalState/worker=docker-container (1.64s)

Check failure on line 169 in tests/build.go

View workflow job for this annotation

GitHub Actions / test-integration (buildx-stable-1, remote, ./tests)

Failed: tests/TestIntegration/TestBuildLocalState/worker=remote

=== RUN TestIntegration/TestBuildLocalState/worker=remote === PAUSE TestIntegration/TestBuildLocalState/worker=remote === CONT TestIntegration/TestBuildLocalState/worker=remote build.go:169: Error Trace: /src/tests/build.go:169 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:96 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:211 Error: Not equal: expected: "/tmp/TestIntegrationTestBuildLocalStateworker=remote2028215633/001" actual : "." Diff: --- Expected +++ Actual @@ -1 +1 @@ -/tmp/TestIntegrationTestBuildLocalStateworker=remote2028215633/001 +. Test: TestIntegration/TestBuildLocalState/worker=remote sandbox.go:133: stdout: /usr/bin/buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --config=/tmp/bktest_config693826141/buildkitd.toml --root /tmp/bktest_buildkitd2120095499 --addr unix:///tmp/bktest_buildkitd2120095499/buildkitd.sock --debug sandbox.go:133: stderr: /usr/bin/buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --config=/tmp/bktest_config693826141/buildkitd.toml --root /tmp/bktest_buildkitd2120095499 --addr unix:///tmp/bktest_buildkitd2120095499/buildkitd.sock --debug sandbox.go:136: > StartCmd 2024-06-28 09:54:29.347587736 +0000 UTC m=+11.649266571 /usr/bin/buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --config=/tmp/bktest_config693826141/buildkitd.toml --root /tmp/bktest_buildkitd2120095499 --addr unix:///tmp/bktest_buildkitd2120095499/buildkitd.sock --debug sandbox.go:136: time="2024-06-28T09:54:29Z" level=warning msg="failed to get disk size: no such file or directory" sandbox.go:136: time="2024-06-28T09:54:29Z" level=warning msg="failed to get disk size: no such file or directory" sandbox.go:136: time="2024-06-28T09:54:29Z" level=info msg="auto snapshotter: using overlayfs" sandbox.go:136: time="2024-06-28T09:54:29Z" level=warning msg="using host network as the default" sandbox.go:136: time="2024-06-28T09:54:29Z" level=info msg="found worker \"bwtfglizpqo05llrb5n96w8pb\", labels=map[org.mobyproject.buildkit.worker.executor:oci org.mobyproject.buildkit.worker.hostname:1c1107ce87d5 org.mobyproject.buildkit.worker.network:host org.mobyproject.buildkit.worker.oci.process-mode:sandbox org.mobyproject.buildkit.worker.sandbox:true org.mobyproject.buildkit.worker.selinux.enabled:false org.mobyproject.buildkit.worker.snapshotter:overlayfs], platforms=[linux/amd64 linux/amd64/v2 linux/amd64/v3 linux/arm64 linux/riscv64 linux/ppc64le linux/s390x linux/386 linux/mips64le linux/mips64 linux/arm/v7 linux/arm/v6]" sandbox.go:136: time="2024-06-28T09:54:29Z" level=info msg="found 1 workers, default=\"bwtfglizpqo05llrb5n96w8pb\"" sandbox.go:136: time="2024-06-28T09:54:29Z" level=warning msg="currently, only the default worker can be used." sandbox.go:136: time="2024-06-28T09:54:29Z" level=info msg="running server on /tmp/bktest_buildkitd2120095499/buildkitd.sock" sandbox.go:136: time="2024-06-28T09:54:29Z" level=debug msg="session started" sandbox.go:136: time="2024-06-28T09:54:29Z" level=debug msg="session finished: <nil>" sandbox.go:136: time="2024-06-28T09:54:29Z" level=debug msg="session started" sandbox.go:136: time="2024-06-28T09:54:29Z" level=debug msg="new ref for local: 2dvn1ab6nyh8dqzkfzgo3944y" span="[internal] load build definition from build.Dockerfile" sandbox.go:136: time="2024-06-28T09:54:29Z" level=debug msg="diffcopy took: 2.345065ms" span="[internal] load build definition from build.Dockerfile" sandbox.go:136: time="2024-06-28T0

Check failure on line 169 in tests/build.go

View workflow job for this annotation

GitHub Actions / test-integration (v0.14.1, docker-container, ./tests)

Failed: tests/TestIntegration/TestBuildLocalState/worker=docker-container

=== RUN TestIntegration/TestBuildLocalState/worker=docker-container === PAUSE TestIntegration/TestBuildLocalState/worker=docker-container === CONT TestIntegration/TestBuildLocalState/worker=docker-container build.go:169: Error Trace: /src/tests/build.go:169 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:96 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:211 Error: Not equal: expected: "/tmp/TestIntegrationTestBuildLocalStateworker=docker-container2204175454/001" actual : "." Diff: --- Expected +++ Actual @@ -1 +1 @@ -/tmp/TestIntegrationTestBuildLocalStateworker=docker-container2204175454/001 +. Test: TestIntegration/TestBuildLocalState/worker=docker-container --- FAIL: TestIntegration/TestBuildLocalState/worker=docker-container (1.75s)

Check failure on line 169 in tests/build.go

View workflow job for this annotation

GitHub Actions / test-integration (v0.14.1, remote, ./tests)

Failed: tests/TestIntegration/TestBuildLocalState/worker=remote

=== RUN TestIntegration/TestBuildLocalState/worker=remote === PAUSE TestIntegration/TestBuildLocalState/worker=remote === CONT TestIntegration/TestBuildLocalState/worker=remote build.go:169: Error Trace: /src/tests/build.go:169 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:96 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:211 Error: Not equal: expected: "/tmp/TestIntegrationTestBuildLocalStateworker=remote2603441835/001" actual : "." Diff: --- Expected +++ Actual @@ -1 +1 @@ -/tmp/TestIntegrationTestBuildLocalStateworker=remote2603441835/001 +. Test: TestIntegration/TestBuildLocalState/worker=remote sandbox.go:133: stderr: /usr/bin/buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --config=/tmp/bktest_config1939783631/buildkitd.toml --root /tmp/bktest_buildkitd2828329644 --addr unix:///tmp/bktest_buildkitd2828329644/buildkitd.sock --debug sandbox.go:136: > StartCmd 2024-06-28 09:54:32.272138202 +0000 UTC m=+10.091812799 /usr/bin/buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --config=/tmp/bktest_config1939783631/buildkitd.toml --root /tmp/bktest_buildkitd2828329644 --addr unix:///tmp/bktest_buildkitd2828329644/buildkitd.sock --debug sandbox.go:136: time="2024-06-28T09:54:32Z" level=warning msg="failed to get disk size: no such file or directory" sandbox.go:136: time="2024-06-28T09:54:32Z" level=warning msg="failed to get disk size: no such file or directory" sandbox.go:136: time="2024-06-28T09:54:32Z" level=info msg="auto snapshotter: using overlayfs" sandbox.go:136: time="2024-06-28T09:54:32Z" level=warning msg="using host network as the default" sandbox.go:136: time="2024-06-28T09:54:32Z" level=info msg="found worker \"vug06vlg4wrxqqoa9w87gv57i\", labels=map[org.mobyproject.buildkit.worker.executor:oci org.mobyproject.buildkit.worker.hostname:c0a8214e0278 org.mobyproject.buildkit.worker.network:host org.mobyproject.buildkit.worker.oci.process-mode:sandbox org.mobyproject.buildkit.worker.sandbox:true org.mobyproject.buildkit.worker.selinux.enabled:false org.mobyproject.buildkit.worker.snapshotter:overlayfs], platforms=[linux/amd64 linux/amd64/v2 linux/amd64/v3 linux/arm64 linux/riscv64 linux/ppc64le linux/s390x linux/386 linux/mips64le linux/mips64 linux/arm/v7 linux/arm/v6]" sandbox.go:136: time="2024-06-28T09:54:32Z" level=info msg="found 1 workers, default=\"vug06vlg4wrxqqoa9w87gv57i\"" sandbox.go:136: time="2024-06-28T09:54:32Z" level=warning msg="currently, only the default worker can be used." sandbox.go:136: time="2024-06-28T09:54:32Z" level=info msg="running server on /tmp/bktest_buildkitd2828329644/buildkitd.sock" sandbox.go:136: time="2024-06-28T09:54:32Z" level=debug msg="session started" sandbox.go:136: time="2024-06-28T09:54:32Z" level=debug msg="session finished: <nil>" sandbox.go:136: time="2024-06-28T09:54:32Z" level=debug msg="session started" sandbox.go:136: time="2024-06-28T09:54:32Z" level=debug msg="new ref for local: 6bmljosqlojigqnk55yeryp1x" span="[internal] load build definition from build.Dockerfile" sandbox.go:136: time="2024-06-28T09:54:32Z" level=debug msg="diffcopy took: 3.013129ms" span="[internal] load build definition from build.Dockerfile" sandbox.go:136: time="2024-06-28T09:54:32Z" level=debug msg="saved 6bmljosqlojigqnk55yeryp1x as dockerfile:dockerfile:" span="[internal] load build definition from build.Dockerfile" sandbox.go:136: time="2024-06-28T09:54:32Z" level=debug msg="checked for cached auth handler namespace" cached=false key="docker.io/library/busybox::pull" name=docker.io/library/busybo

Check failure on line 169 in tests/build.go

View workflow job for this annotation

GitHub Actions / test-integration (v0.13.2, docker-container, ./tests)

Failed: tests/TestIntegration/TestBuildLocalState/worker=docker-container

=== RUN TestIntegration/TestBuildLocalState/worker=docker-container === PAUSE TestIntegration/TestBuildLocalState/worker=docker-container === CONT TestIntegration/TestBuildLocalState/worker=docker-container build.go:169: Error Trace: /src/tests/build.go:169 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:96 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:211 Error: Not equal: expected: "/tmp/TestIntegrationTestBuildLocalStateworker=docker-container2560042015/001" actual : "." Diff: --- Expected +++ Actual @@ -1 +1 @@ -/tmp/TestIntegrationTestBuildLocalStateworker=docker-container2560042015/001 +. Test: TestIntegration/TestBuildLocalState/worker=docker-container --- FAIL: TestIntegration/TestBuildLocalState/worker=docker-container (1.71s)

Check failure on line 169 in tests/build.go

View workflow job for this annotation

GitHub Actions / test-integration (v0.13.2, remote, ./tests)

Failed: tests/TestIntegration/TestBuildLocalState/worker=remote

=== RUN TestIntegration/TestBuildLocalState/worker=remote === PAUSE TestIntegration/TestBuildLocalState/worker=remote === CONT TestIntegration/TestBuildLocalState/worker=remote build.go:169: Error Trace: /src/tests/build.go:169 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:96 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:211 Error: Not equal: expected: "/tmp/TestIntegrationTestBuildLocalStateworker=remote3681746361/001" actual : "." Diff: --- Expected +++ Actual @@ -1 +1 @@ -/tmp/TestIntegrationTestBuildLocalStateworker=remote3681746361/001 +. Test: TestIntegration/TestBuildLocalState/worker=remote sandbox.go:133: stdout: /usr/bin/buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --config=/tmp/bktest_config1688433645/buildkitd.toml --root /tmp/bktest_buildkitd3503602817 --addr unix:///tmp/bktest_buildkitd3503602817/buildkitd.sock --debug sandbox.go:133: stderr: /usr/bin/buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --config=/tmp/bktest_config1688433645/buildkitd.toml --root /tmp/bktest_buildkitd3503602817 --addr unix:///tmp/bktest_buildkitd3503602817/buildkitd.sock --debug sandbox.go:136: > StartCmd 2024-06-28 09:54:29.940671962 +0000 UTC m=+13.628423616 /usr/bin/buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --config=/tmp/bktest_config1688433645/buildkitd.toml --root /tmp/bktest_buildkitd3503602817 --addr unix:///tmp/bktest_buildkitd3503602817/buildkitd.sock --debug sandbox.go:136: time="2024-06-28T09:54:30Z" level=warning msg="failed to get disk size: no such file or directory" sandbox.go:136: time="2024-06-28T09:54:30Z" level=warning msg="failed to get disk size: no such file or directory" sandbox.go:136: time="2024-06-28T09:54:30Z" level=info msg="auto snapshotter: using overlayfs" sandbox.go:136: time="2024-06-28T09:54:30Z" level=warning msg="using host network as the default" sandbox.go:136: time="2024-06-28T09:54:30Z" level=info msg="found worker \"j3c9ag8bodcmdghlnguzuk6jy\", labels=map[org.mobyproject.buildkit.worker.executor:oci org.mobyproject.buildkit.worker.hostname:d689815a9ae3 org.mobyproject.buildkit.worker.network:host org.mobyproject.buildkit.worker.oci.process-mode:sandbox org.mobyproject.buildkit.worker.sandbox:true org.mobyproject.buildkit.worker.selinux.enabled:false org.mobyproject.buildkit.worker.snapshotter:overlayfs], platforms=[linux/amd64 linux/amd64/v2 linux/amd64/v3 linux/arm64 linux/riscv64 linux/ppc64le linux/s390x linux/386 linux/mips64le linux/mips64 linux/arm/v7 linux/arm/v6]" sandbox.go:136: time="2024-06-28T09:54:30Z" level=info msg="found 1 workers, default=\"j3c9ag8bodcmdghlnguzuk6jy\"" sandbox.go:136: time="2024-06-28T09:54:30Z" level=warning msg="currently, only the default worker can be used." sandbox.go:136: time="2024-06-28T09:54:30Z" level=info msg="running server on /tmp/bktest_buildkitd3503602817/buildkitd.sock" sandbox.go:136: time="2024-06-28T09:54:30Z" level=debug msg="session started" spanID=85da1562a2191d9d traceID=ad7927c9005ea6af104dabc9bd3e67a2 sandbox.go:136: time="2024-06-28T09:54:30Z" level=debug msg="session finished: <nil>" spanID=85da1562a2191d9d traceID=ad7927c9005ea6af104dabc9bd3e67a2 sandbox.go:136: time="2024-06-28T09:54:30Z" level=debug msg="session started" spanID=639534c3ef7138c6 traceID=ad7927c9005ea6af104dabc9bd3e67a2 sandbox.go:136: time="2024-06-28T09:54:30Z" level=debug msg="new ref for local: y5kizccy49njxr737bh5ofhhb" span="[internal] load build definition from build.Docker

Check failure on line 169 in tests/build.go

View workflow job for this annotation

GitHub Actions / test-integration (v0.12.5, docker-container, ./tests)

Failed: tests/TestIntegration/TestBuildLocalState/worker=docker-container

=== RUN TestIntegration/TestBuildLocalState/worker=docker-container === PAUSE TestIntegration/TestBuildLocalState/worker=docker-container === CONT TestIntegration/TestBuildLocalState/worker=docker-container build.go:169: Error Trace: /src/tests/build.go:169 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:96 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:211 Error: Not equal: expected: "/tmp/TestIntegrationTestBuildLocalStateworker=docker-container2234487894/001" actual : "." Diff: --- Expected +++ Actual @@ -1 +1 @@ -/tmp/TestIntegrationTestBuildLocalStateworker=docker-container2234487894/001 +. Test: TestIntegration/TestBuildLocalState/worker=docker-container --- FAIL: TestIntegration/TestBuildLocalState/worker=docker-container (1.70s)

Check failure on line 169 in tests/build.go

View workflow job for this annotation

GitHub Actions / test-integration (v0.12.5, remote, ./tests)

Failed: tests/TestIntegration/TestBuildLocalState/worker=remote

=== RUN TestIntegration/TestBuildLocalState/worker=remote === PAUSE TestIntegration/TestBuildLocalState/worker=remote === CONT TestIntegration/TestBuildLocalState/worker=remote build.go:169: Error Trace: /src/tests/build.go:169 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:96 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:211 Error: Not equal: expected: "/tmp/TestIntegrationTestBuildLocalStateworker=remote3811068192/001" actual : "." Diff: --- Expected +++ Actual @@ -1 +1 @@ -/tmp/TestIntegrationTestBuildLocalStateworker=remote3811068192/001 +. Test: TestIntegration/TestBuildLocalState/worker=remote sandbox.go:133: stderr: /usr/bin/buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --config=/tmp/bktest_config1322907857/buildkitd.toml --root /tmp/bktest_buildkitd647291232 --addr unix:///tmp/bktest_buildkitd647291232/buildkitd.sock --debug sandbox.go:136: > StartCmd 2024-06-28 09:55:08.204806848 +0000 UTC m=+16.887819805 /usr/bin/buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --config=/tmp/bktest_config1322907857/buildkitd.toml --root /tmp/bktest_buildkitd647291232 --addr unix:///tmp/bktest_buildkitd647291232/buildkitd.sock --debug sandbox.go:136: time="2024-06-28T09:55:08Z" level=info msg="auto snapshotter: using overlayfs" sandbox.go:136: time="2024-06-28T09:55:08Z" level=warning msg="using host network as the default" sandbox.go:136: time="2024-06-28T09:55:08Z" level=info msg="found worker \"apw629rc70m982zpvsp94vf8x\", labels=map[org.mobyproject.buildkit.worker.executor:oci org.mobyproject.buildkit.worker.hostname:caf84a36c07d org.mobyproject.buildkit.worker.network:host org.mobyproject.buildkit.worker.oci.process-mode:sandbox org.mobyproject.buildkit.worker.sandbox:true org.mobyproject.buildkit.worker.selinux.enabled:false org.mobyproject.buildkit.worker.snapshotter:overlayfs], platforms=[linux/amd64 linux/amd64/v2 linux/amd64/v3 linux/arm64 linux/riscv64 linux/ppc64le linux/s390x linux/386 linux/mips64le linux/mips64 linux/arm/v7 linux/arm/v6]" sandbox.go:136: time="2024-06-28T09:55:08Z" level=info msg="found 1 workers, default=\"apw629rc70m982zpvsp94vf8x\"" sandbox.go:136: time="2024-06-28T09:55:08Z" level=warning msg="currently, only the default worker can be used." sandbox.go:136: time="2024-06-28T09:55:08Z" level=info msg="running server on /tmp/bktest_buildkitd647291232/buildkitd.sock" sandbox.go:136: time="2024-06-28T09:55:08Z" level=debug msg="session started" spanID=3bf58a039e257541 traceID=46a23d7642b2fd60fc79c89e1e6450d0 sandbox.go:136: time="2024-06-28T09:55:08Z" level=debug msg="session finished: <nil>" spanID=3bf58a039e257541 traceID=46a23d7642b2fd60fc79c89e1e6450d0 sandbox.go:136: time="2024-06-28T09:55:08Z" level=debug msg="session started" spanID=6d480cab7ddf78e8 traceID=46a23d7642b2fd60fc79c89e1e6450d0 sandbox.go:136: time="2024-06-28T09:55:08Z" level=debug msg="new ref for local: c5qxg5c2r0l8fhj4cvs5flp7x" span="[internal] load build definition from build.Dockerfile" spanID=894b6a0b16c25560 traceID=46a23d7642b2fd60fc79c89e1e6450d0 sandbox.go:136: time="2024-06-28T09:55:08Z" level=debug msg="diffcopy took: 2.69823ms" span="[internal] load build definition from build.Dockerfile" spanID=859469b069a54b2c traceID=46a23d7642b2fd60fc79c89e1e6450d0 sandbox.go:136: time="2024-06-28T09:55:08Z" level=debug msg="saved c5qxg5c2r0l8fhj4cvs5flp7x as dockerfile:dockerfile:" span="[internal] load build definition from build.Dockerfile" spanID=894b6a0b16c25560 traceID=46a23d7642b2fd60fc79c89e1e6450d0 sandbox.go:136: time="2024-06-28T09:55

Check failure on line 169 in tests/build.go

View workflow job for this annotation

GitHub Actions / test-integration (docker, ./tests)

Failed: tests/TestIntegration/TestBuildLocalState/worker=docker

=== RUN TestIntegration/TestBuildLocalState/worker=docker === PAUSE TestIntegration/TestBuildLocalState/worker=docker === CONT TestIntegration/TestBuildLocalState/worker=docker build.go:169: Error Trace: /src/tests/build.go:169 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:96 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:211 Error: Not equal: expected: "/tmp/TestIntegrationTestBuildLocalStateworker=docker1090788270/001" actual : "." Diff: --- Expected +++ Actual @@ -1 +1 @@ -/tmp/TestIntegrationTestBuildLocalStateworker=docker1090788270/001 +. Test: TestIntegration/TestBuildLocalState/worker=docker sandbox.go:133: stdout: /usr/bin/dockerd sandbox.go:133: stderr: /usr/bin/dockerd sandbox.go:136: > startCmd 2024-06-28 09:57:11.056849264 +0000 UTC m=+171.111890837 /usr/bin/dockerd --data-root /tmp/integration486599283/dd1a9w31okgqs/root --exec-root /tmp/dxr/dd1a9w31okgqs --pidfile /tmp/integration486599283/dd1a9w31okgqs/docker.pid --containerd-namespace dd1a9w31okgqs --containerd-plugins-namespace dd1a9w31okgqsp --host unix:///tmp/docker-integration/dd1a9w31okgqs.sock --config-file /tmp/integration486599283/daemon.json --userland-proxy=false --tls=false --debug sandbox.go:136: time="2024-06-28T09:57:11.076924193Z" level=info msg="Starting up" sandbox.go:136: time="2024-06-28T09:57:11.078028460Z" level=warning msg="could not change group /tmp/docker-integration/dd1a9w31okgqs.sock to docker: group docker not found" sandbox.go:136: time="2024-06-28T09:57:11.078152693Z" level=debug msg="Listener created for HTTP on unix (/tmp/docker-integration/dd1a9w31okgqs.sock)" sandbox.go:136: time="2024-06-28T09:57:11.078173302Z" level=info msg="containerd not running, starting managed containerd" sandbox.go:136: time="2024-06-28T09:57:11.078710504Z" level=info msg="started new containerd process" address=/tmp/dxr/dd1a9w31okgqs/containerd/containerd.sock module=libcontainerd pid=22802 sandbox.go:136: time="2024-06-28T09:57:11.079028681Z" level=debug msg="created containerd monitoring client" address=/tmp/dxr/dd1a9w31okgqs/containerd/containerd.sock module=libcontainerd sandbox.go:136: time="2024-06-28T09:57:11.079204158Z" level=debug msg="2024/06/28 09:57:11 WARNING: [core] [Channel #1 SubChannel #2] grpc: addrConn.createTransport failed to connect to {Addr: \"/tmp/dxr/dd1a9w31okgqs/containerd/containerd.sock\", ServerName: \"localhost\", Attributes: {\"<%!p(networktype.keyType=grpc.internal.transport.networktype)>\": \"unix\" }, }. Err: connection error: desc = \"transport: Error while dialing: dial unix /tmp/dxr/dd1a9w31okgqs/containerd/containerd.sock: connect: no such file or directory\"" library=grpc sandbox.go:136: time="2024-06-28T09:57:11.092131199Z" level=info msg="starting containerd" revision=ae71819c4f5e67bb4d5ae76a6b735f29cc25774e version=v1.7.18 sandbox.go:136: time="2024-06-28T09:57:11.104964907Z" level=info msg="loading plugin \"io.containerd.event.v1.exchange\"..." type=io.containerd.event.v1 sandbox.go:136: time="2024-06-28T09:57:11.104987740Z" level=info msg="loading plugin \"io.containerd.internal.v1.opt\"..." type=io.containerd.internal.v1 sandbox.go:136: time="2024-06-28T09:57:11.105018908Z" level=info msg="loading plugin \"io.containerd.warning.v1.deprecations\"..." type=io.containerd.warning.v1 sandbox.go:136: time="2024-06-28T09:57:11.105036622Z" level=info msg="loading plugin \"io.containerd.snapshotter.v1.blockfile\"..." type=io.containerd.snapshotter.v1 sandbox.go:136: time="2024-06-28T09:57:11.105106603Z" level=info msg="skip loading plugin \"io.containerd.snapshotter.v1.blockfile\"..." error="no scratch file generator: skip plugin" type=io.containerd.snapshotter.v1 sandbox.go:136: time="2024-06-28T09:57

Check failure on line 169 in tests/build.go

View workflow job for this annotation

GitHub Actions / test-integration (docker+containerd, ./tests)

Failed: tests/TestIntegration/TestBuildLocalState/worker=docker+containerd

=== RUN TestIntegration/TestBuildLocalState/worker=docker+containerd === PAUSE TestIntegration/TestBuildLocalState/worker=docker+containerd === CONT TestIntegration/TestBuildLocalState/worker=docker+containerd build.go:169: Error Trace: /src/tests/build.go:169 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:96 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:211 Error: Not equal: expected: "/tmp/TestIntegrationTestBuildLocalStateworker=docker+containerd820319738/001" actual : "." Diff: --- Expected +++ Actual @@ -1 +1 @@ -/tmp/TestIntegrationTestBuildLocalStateworker=docker+containerd820319738/001 +. Test: TestIntegration/TestBuildLocalState/worker=docker+containerd sandbox.go:133: stdout: /usr/bin/dockerd sandbox.go:133: stderr: /usr/bin/dockerd sandbox.go:136: > startCmd 2024-06-28 09:57:01.258394327 +0000 UTC m=+167.736716963 /usr/bin/dockerd --data-root /tmp/integration2827781252/d4jghzjwf12j3/root --exec-root /tmp/dxr/d4jghzjwf12j3 --pidfile /tmp/integration2827781252/d4jghzjwf12j3/docker.pid --containerd-namespace d4jghzjwf12j3 --containerd-plugins-namespace d4jghzjwf12j3p --host unix:///tmp/docker-integration/d4jghzjwf12j3.sock --config-file /tmp/integration2827781252/daemon.json --userland-proxy=false --tls=false --debug sandbox.go:136: time="2024-06-28T09:57:01.278190771Z" level=info msg="Starting up" sandbox.go:136: time="2024-06-28T09:57:01.279159055Z" level=warning msg="could not change group /tmp/docker-integration/d4jghzjwf12j3.sock to docker: group docker not found" sandbox.go:136: time="2024-06-28T09:57:01.279274239Z" level=debug msg="Listener created for HTTP on unix (/tmp/docker-integration/d4jghzjwf12j3.sock)" sandbox.go:136: time="2024-06-28T09:57:01.279298404Z" level=info msg="containerd not running, starting managed containerd" sandbox.go:136: time="2024-06-28T09:57:01.279823062Z" level=info msg="started new containerd process" address=/tmp/dxr/d4jghzjwf12j3/containerd/containerd.sock module=libcontainerd pid=22500 sandbox.go:136: time="2024-06-28T09:57:01.280148920Z" level=debug msg="created containerd monitoring client" address=/tmp/dxr/d4jghzjwf12j3/containerd/containerd.sock module=libcontainerd sandbox.go:136: time="2024-06-28T09:57:01.280317704Z" level=debug msg="2024/06/28 09:57:01 WARNING: [core] [Channel #1 SubChannel #2] grpc: addrConn.createTransport failed to connect to {Addr: \"/tmp/dxr/d4jghzjwf12j3/containerd/containerd.sock\", ServerName: \"localhost\", Attributes: {\"<%!p(networktype.keyType=grpc.internal.transport.networktype)>\": \"unix\" }, }. Err: connection error: desc = \"transport: Error while dialing: dial unix /tmp/dxr/d4jghzjwf12j3/containerd/containerd.sock: connect: no such file or directory\"" library=grpc sandbox.go:136: time="2024-06-28T09:57:01.291800310Z" level=info msg="starting containerd" revision=ae71819c4f5e67bb4d5ae76a6b735f29cc25774e version=v1.7.18 sandbox.go:136: time="2024-06-28T09:57:01.304917653Z" level=info msg="loading plugin \"io.containerd.event.v1.exchange\"..." type=io.containerd.event.v1 sandbox.go:136: time="2024-06-28T09:57:01.304946337Z" level=info msg="loading plugin \"io.containerd.internal.v1.opt\"..." type=io.containerd.internal.v1 sandbox.go:136: time="2024-06-28T09:57:01.304976613Z" level=info msg="loading plugin \"io.containerd.warning.v1.deprecations\"..." type=io.containerd.warning.v1 sandbox.go:136: time="2024-06-28T09:57:01.304999035Z" level=info msg="loading plugin \"io.containerd.snapshotter.v1.blockfile\"..." type=io.containerd.snapshotter.v1 sandbox.go:136: time="2024-06-28T09:57:01.305072722Z" level=info msg="skip loading plugin \"io.containerd.snapshotter.v1.blockfile\"..." error="no scratch file generator: skip plugin" type=io.c
require.DirExists(t, ref.LocalPath)
require.FileExists(t, ref.DockerfilePath)
}

func testBuildLocalStateRemote(t *testing.T, sb integration.Sandbox) {
dockerfile := []byte(`
FROM busybox:latest
COPY foo /foo
`)
dir := tmpdir(
t,
fstest.CreateFile("build.Dockerfile", dockerfile, 0600),
fstest.CreateFile("foo", []byte("foo"), 0600),
)
dirDest := t.TempDir()

git, err := gitutil.New(gitutil.WithWorkingDir(dir))
require.NoError(t, err)

gitutil.GitInit(git, t)
gitutil.GitAdd(git, t, "build.Dockerfile", "foo")
gitutil.GitCommit(git, t, "initial commit")
addr := gitutil.GitServeHTTP(git, t)

out, err := buildCmd(sb, withDir(dir), withArgs(
"-f", "build.Dockerfile",
"--metadata-file", filepath.Join(dirDest, "md.json"),
"--output", "type=local,dest="+dirDest,
addr,
))
require.NoError(t, err, out)
require.FileExists(t, filepath.Join(dirDest, "foo"))

dt, err := os.ReadFile(filepath.Join(dirDest, "md.json"))
require.NoError(t, err)

type mdT struct {
BuildRef string `json:"buildx.build.ref"`
}
var md mdT
err = json.Unmarshal(dt, &md)
require.NoError(t, err)

ls, err := localstate.New(buildxConfig(sb))
require.NoError(t, err)

refParts := strings.Split(md.BuildRef, "/")
require.Len(t, refParts, 3)

ref, err := ls.ReadRef(refParts[0], refParts[1], refParts[2])
require.NoError(t, err)
require.NotNil(t, ref)
require.Equal(t, addr, ref.Context)
require.Empty(t, ref.LocalPath)
require.Equal(t, "build.Dockerfile", ref.DockerfilePath)
}

func testBuildLocalExport(t *testing.T, sb integration.Sandbox) {
dir := createTestProject(t)
out, err := buildCmd(sb, withArgs(fmt.Sprintf("--output=type=local,dest=%s/result", dir), dir))
Expand Down
9 changes: 8 additions & 1 deletion tests/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func buildxCmd(sb integration.Sandbox, opts ...cmdOpt) *exec.Cmd {

if builder := sb.Address(); builder != "" {
cmd.Env = append(cmd.Env,
"BUILDX_CONFIG=/tmp/buildx-"+builder,
"BUILDX_CONFIG="+buildxConfig(sb),
"BUILDX_BUILDER="+builder,
)
}
Expand Down Expand Up @@ -86,6 +86,13 @@ func dockerCmd(sb integration.Sandbox, opts ...cmdOpt) *exec.Cmd {
return cmd
}

func buildxConfig(sb integration.Sandbox) string {
if builder := sb.Address(); builder != "" {
return "/tmp/buildx-" + builder
}
return ""
}

func isMobyWorker(sb integration.Sandbox) bool {
name, hasFeature := driverName(sb.Name())
return name == "docker" && !hasFeature
Expand Down

0 comments on commit 42f1086

Please sign in to comment.