Skip to content

Commit

Permalink
Implement llb.Symlink
Browse files Browse the repository at this point in the history
* Add file.symlink.create capability and wire it up
* Run codegen for new FileActionSymlink Message
* Add Symlink test
* Add user/group ownership and timestamps to symlink
 ** Symlinks have user/group ownership that are independent of those of the
    target file; in linux, the ownership of the symlink itself is only
    checked when the link resides in a directory with the sticky bit set and
    the link is the subject of removal or renaming. The sticky bit prevents
    files in the directory from being deleted or renamed by non-owners
    (members of the group that owns the file may not delete the file; the
    user must own the file).

    In addition to user/group restrictions, linux symlinks have timestamps
    that are independent of the timestamps on the target file.
* Expose symlink options to `llb` package
* Add symlink integration test
* Use tar exporter for tests
 ** Using the local exporter causes the files to be exported with the
    permissions of the user who does the exporting, instead of retaining
    their file permissions from within the container.

    Using the tar exporter instead preserves the permissions until they can
    be checked.
* Change symlink fields to `oldpath` and `newpath`
 ** Also run `make generated-files`
* Fix typo
* Add doc strings to exported `llb` identifiers
* Remove `requiresLinux` from integration test
* Revert "Remove `requiresLinux` from integration test"
* Add fixes to please the linter

Signed-off-by: Peter Engelbert <[email protected]>
  • Loading branch information
pmengelbert committed Nov 21, 2024
1 parent c3baf4c commit ac0ccbf
Show file tree
Hide file tree
Showing 13 changed files with 1,007 additions and 194 deletions.
87 changes: 87 additions & 0 deletions client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ var allTests = []func(t *testing.T, sb integration.Sandbox){
testLayerLimitOnMounts,
testFrontendVerifyPlatforms,
testRunValidExitCodes,
testFileOpSymlink,
}

func TestIntegration(t *testing.T) {
Expand Down Expand Up @@ -2409,6 +2410,92 @@ func testOCILayoutPlatformSource(t *testing.T, sb integration.Sandbox) {
}
}

func testFileOpSymlink(t *testing.T, sb integration.Sandbox) {
requiresLinux(t)

const (
fileOwner = 7777
fileGroup = 8888
linkOwner = 1111
linkGroup = 2222

dummyTimestamp = 42
)

dummyTime := time.Unix(dummyTimestamp, 0)

c, err := New(sb.Context(), sb.Address())
require.NoError(t, err)
defer c.Close()

st := llb.Scratch().
File(llb.Mkdir("/foo", 0700).Mkfile("bar", 0600, []byte("contents"), llb.ChownOpt{
User: &llb.UserOpt{
UID: fileOwner,
},
Group: &llb.UserOpt{
UID: fileGroup,
},
})).
File(llb.Symlink("bar", "/baz", llb.WithCreatedTime(dummyTime), llb.ChownOpt{
User: &llb.UserOpt{
UID: linkOwner,
},
Group: &llb.UserOpt{
UID: linkGroup,
},
}))

def, err := st.Marshal(sb.Context())
require.NoError(t, err)

destDir := t.TempDir()

out := filepath.Join(destDir, "out.tar")
outW, err := os.Create(out)
require.NoError(t, err)
defer outW.Close()

_, err = c.Solve(sb.Context(), def, SolveOpt{
Exports: []ExportEntry{
{
Type: ExporterTar,
Output: fixedWriteCloser(outW),
},
},
}, nil)
require.NoError(t, err)

dt, err := os.ReadFile(out)
require.NoError(t, err)
m, err := testutil.ReadTarToMap(dt, false)
require.NoError(t, err)

entry, ok := m["bar"]
require.True(t, ok)

dt = entry.Data
header := entry.Header
require.NoError(t, err)

require.Equal(t, []byte("contents"), dt)
require.Equal(t, fileOwner, header.Uid)
require.Equal(t, fileGroup, header.Gid)

entry, ok = m["baz"]
dt = entry.Data
header = entry.Header
require.NoError(t, err)
require.Equal(t, []byte("contents"), dt)

Check failure on line 2489 in client/client_test.go

View workflow job for this annotation

GitHub Actions / test / run (containerd, ./client ./cmd/buildctl ./worker/containerd ./solver ./frontend, integration)

Failed: client/TestIntegration/TestFileOpSymlink/worker=containerd

=== RUN TestIntegration/TestFileOpSymlink/worker=containerd === PAUSE TestIntegration/TestFileOpSymlink/worker=containerd === CONT TestIntegration/TestFileOpSymlink/worker=containerd client_test.go:2489: Error Trace: /src/client/client_test.go:2489 /src/util/testutil/integration/run.go:97 /src/util/testutil/integration/run.go:211 Error: Not equal: expected: []byte{0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73} actual : []byte(nil) Diff: --- Expected +++ Actual @@ -1,4 +1,2 @@ -([]uint8) (len=8) { - 00000000 63 6f 6e 74 65 6e 74 73 |contents| -} +([]uint8) <nil> Test: TestIntegration/TestFileOpSymlink/worker=containerd sandbox.go:135: stdout: /usr/bin/containerd --config /tmp/bktest_containerd3582566657/config.toml sandbox.go:135: stderr: /usr/bin/containerd --config /tmp/bktest_containerd3582566657/config.toml sandbox.go:138: > StartCmd 2024-11-21 21:21:19.425688458 +0000 UTC m=+227.118375600 /usr/bin/containerd --config /tmp/bktest_containerd3582566657/config.toml sandbox.go:138: time="2024-11-21T21:21:19.446551302Z" level=info msg="starting containerd" revision= version=2.0.0+unknown sandbox.go:138: time="2024-11-21T21:21:19.456481130Z" level=warning msg="Configuration migrated from version 2, use `containerd config migrate` to avoid migration" t="2.644µs" sandbox.go:138: time="2024-11-21T21:21:19.456509172Z" level=info msg="loading plugin" id=io.containerd.image-verifier.v1.bindir type=io.containerd.image-verifier.v1 sandbox.go:138: time="2024-11-21T21:21:19.456532576Z" level=info msg="loading plugin" id=io.containerd.internal.v1.opt type=io.containerd.internal.v1 sandbox.go:138: time="2024-11-21T21:21:19.456588079Z" level=info msg="loading plugin" id=io.containerd.warning.v1.deprecations type=io.containerd.warning.v1 sandbox.go:138: time="2024-11-21T21:21:19.456610270Z" level=info msg="loading plugin" id=io.containerd.content.v1.content type=io.containerd.content.v1 sandbox.go:138: time="2024-11-21T21:21:19.456650365Z" level=info msg="loading plugin" id=io.containerd.snapshotter.v1.blockfile type=io.containerd.snapshotter.v1 sandbox.go:138: time="2024-11-21T21:21:19.456750351Z" level=info msg="skip loading plugin" error="no scratch file generator: skip plugin" id=io.containerd.snapshotter.v1.blockfile type=io.containerd.snapshotter.v1 sandbox.go:138: time="2024-11-21T21:21:19.456767032Z" level=info msg="loading plugin" id=io.containerd.snapshotter.v1.devmapper type=io.containerd.snapshotter.v1 sandbox.go:138: time="2024-11-21T21:21:19.456788321Z" level=info msg="skip loading plugin" error="devmapper not configured: skip plugin" id=io.containerd.snapshotter.v1.devmapper type=io.containerd.snapshotter.v1 sandbox.go:138: time="2024-11-21T21:21:19.456803660Z" level=info msg="loading plugin" id=io.containerd.snapshotter.v1.native type=io.containerd.snapshotter.v1 sandbox.go:138: time="2024-11-21T21:21:19.456888878Z" level=info msg="loading plugin" id=io.containerd.snapshotter.v1.overlayfs type=io.containerd.snapshotter.v1 sandbox.go:138: time="2024-11-21T21:21:19.457145856Z" level=info msg="loading plugin" id=io.containerd.snapshotter.v1.zfs type=io.containerd.snapshotter.v1 sandbox.go:138: time="2024-11-21T21:21:19.457190209Z" level=info msg="skip loading plugin" error="lstat /tmp/bktest_containerd3582566657/root/io.containerd.snapshotter.v1.zfs: no such file or directory: skip plugin" id=io.containerd.snapshotter.v1.zfs type=io.containerd.snapshotter.v1 sandbox.go:138: time="2024-11-21T21:21:19.457221116Z" level=info msg="loading plugin" id=io.containerd.event.v1.exchange type=io.containerd.event.v1 sandbox.go:138: time="2024-11-21T21:21:19.457252134Z" level

Check failure on line 2489 in client/client_test.go

View workflow job for this annotation

GitHub Actions / test / run (containerd-rootless, ./client ./cmd/buildctl ./worker/containerd ./solver ./frontend, integr...

Failed: client/TestIntegration/TestFileOpSymlink/worker=containerd-rootless

=== RUN TestIntegration/TestFileOpSymlink/worker=containerd-rootless === PAUSE TestIntegration/TestFileOpSymlink/worker=containerd-rootless === CONT TestIntegration/TestFileOpSymlink/worker=containerd-rootless client_test.go:2489: Error Trace: /src/client/client_test.go:2489 /src/util/testutil/integration/run.go:97 /src/util/testutil/integration/run.go:211 Error: Not equal: expected: []byte{0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73} actual : []byte(nil) Diff: --- Expected +++ Actual @@ -1,4 +1,2 @@ -([]uint8) (len=8) { - 00000000 63 6f 6e 74 65 6e 74 73 |contents| -} +([]uint8) <nil> Test: TestIntegration/TestFileOpSymlink/worker=containerd-rootless sandbox.go:135: stdout: /usr/bin/sudo -u #1000 -i CONTAINERD_ROOTLESS_ROOTLESSKIT_STATE_DIR=/tmp/bktest_containerd718016833/rootlesskit-containerd CONTAINERD_ROOTLESS_ROOTLESSKIT_NET=host CONTAINERD_ROOTLESS_ROOTLESSKIT_PORT_DRIVER=none CONTAINERD_ROOTLESS_ROOTLESSKIT_FLAGS=--mtu=0 containerd-rootless.sh -c /tmp/bktest_containerd718016833/config.toml sandbox.go:135: stderr: /usr/bin/sudo -u #1000 -i CONTAINERD_ROOTLESS_ROOTLESSKIT_STATE_DIR=/tmp/bktest_containerd718016833/rootlesskit-containerd CONTAINERD_ROOTLESS_ROOTLESSKIT_NET=host CONTAINERD_ROOTLESS_ROOTLESSKIT_PORT_DRIVER=none CONTAINERD_ROOTLESS_ROOTLESSKIT_FLAGS=--mtu=0 containerd-rootless.sh -c /tmp/bktest_containerd718016833/config.toml sandbox.go:138: > StartCmd 2024-11-21 21:23:12.988463732 +0000 UTC m=+299.517016814 /usr/bin/sudo -u #1000 -i CONTAINERD_ROOTLESS_ROOTLESSKIT_STATE_DIR=/tmp/bktest_containerd718016833/rootlesskit-containerd CONTAINERD_ROOTLESS_ROOTLESSKIT_NET=host CONTAINERD_ROOTLESS_ROOTLESSKIT_PORT_DRIVER=none CONTAINERD_ROOTLESS_ROOTLESSKIT_FLAGS=--mtu=0 containerd-rootless.sh -c /tmp/bktest_containerd718016833/config.toml sandbox.go:138: time="2024-11-21T21:23:13.055326465Z" level=info msg="starting containerd" revision= version=2.0.0+unknown sandbox.go:138: time="2024-11-21T21:23:13.064878111Z" level=warning msg="Configuration migrated from version 2, use `containerd config migrate` to avoid migration" t="3.146µs" sandbox.go:138: time="2024-11-21T21:23:13.064937774Z" level=info msg="loading plugin" id=io.containerd.image-verifier.v1.bindir type=io.containerd.image-verifier.v1 sandbox.go:138: time="2024-11-21T21:23:13.064977678Z" level=info msg="loading plugin" id=io.containerd.internal.v1.opt type=io.containerd.internal.v1 sandbox.go:138: time="2024-11-21T21:23:13.065039114Z" level=warning msg="failed to load plugin" error="mkdir /opt/containerd: permission denied" id=io.containerd.internal.v1.opt type=io.containerd.internal.v1 sandbox.go:138: time="2024-11-21T21:23:13.065100619Z" level=info msg="loading plugin" id=io.containerd.warning.v1.deprecations type=io.containerd.warning.v1 sandbox.go:138: time="2024-11-21T21:23:13.065161033Z" level=info msg="loading plugin" id=io.containerd.content.v1.content type=io.containerd.content.v1 sandbox.go:138: time="2024-11-21T21:23:13.065218190Z" level=info msg="loading plugin" id=io.containerd.snapshotter.v1.blockfile type=io.containerd.snapshotter.v1 sandbox.go:138: time="2024-11-21T21:23:13.065329699Z" level=info msg="skip loading plugin" error="no scratch file generator: skip plugin" id=io.containerd.snapshotter.v1.blockfile type=io.containerd.snapshotter.v1 sandbox.go:138: time="2024-11-21T21:23:13.065372870Z" level=info msg="loading plugin" id=io.containerd.snapshotter.v1.devmapper type=io.containerd.snapshotter.v1 sandbox.go:138: time="2024-11-21T21:23:13.065412735Z" level=info msg="skip loading plugin" error="devmapper not configured: skip plugin" id=io.containerd.snapshotter.v1.devmapper type=io.contain

Check failure on line 2489 in client/client_test.go

View workflow job for this annotation

GitHub Actions / test / run (containerd-1.6, ./client ./cmd/buildctl ./worker/containerd ./solver ./frontend, integration)

Failed: client/TestIntegration/TestFileOpSymlink/worker=containerd-1.6

=== RUN TestIntegration/TestFileOpSymlink/worker=containerd-1.6 === PAUSE TestIntegration/TestFileOpSymlink/worker=containerd-1.6 === CONT TestIntegration/TestFileOpSymlink/worker=containerd-1.6 client_test.go:2489: Error Trace: /src/client/client_test.go:2489 /src/util/testutil/integration/run.go:97 /src/util/testutil/integration/run.go:211 Error: Not equal: expected: []byte{0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73} actual : []byte(nil) Diff: --- Expected +++ Actual @@ -1,4 +1,2 @@ -([]uint8) (len=8) { - 00000000 63 6f 6e 74 65 6e 74 73 |contents| -} +([]uint8) <nil> Test: TestIntegration/TestFileOpSymlink/worker=containerd-1.6 sandbox.go:135: stderr: /opt/containerd-alt-16/bin/containerd --config /tmp/bktest_containerd2409304663/config.toml sandbox.go:138: > StartCmd 2024-11-21 21:19:25.150612998 +0000 UTC m=+96.439473983 /opt/containerd-alt-16/bin/containerd --config /tmp/bktest_containerd2409304663/config.toml sandbox.go:138: time="2024-11-21T21:19:25.188813329Z" level=info msg="starting containerd" revision=88c3d9bc5b5a193f40b7c14fa996d23532d6f956 version=v1.6.36 sandbox.go:138: time="2024-11-21T21:19:25.212560015Z" level=info msg="loading plugin \"io.containerd.content.v1.content\"..." type=io.containerd.content.v1 sandbox.go:138: time="2024-11-21T21:19:25.212720607Z" level=info msg="loading plugin \"io.containerd.snapshotter.v1.devmapper\"..." type=io.containerd.snapshotter.v1 sandbox.go:138: time="2024-11-21T21:19:25.212752307Z" level=warning msg="failed to load plugin io.containerd.snapshotter.v1.devmapper" error="devmapper not configured" sandbox.go:138: time="2024-11-21T21:19:25.212771443Z" level=info msg="loading plugin \"io.containerd.snapshotter.v1.native\"..." type=io.containerd.snapshotter.v1 sandbox.go:138: time="2024-11-21T21:19:25.212866993Z" level=info msg="loading plugin \"io.containerd.snapshotter.v1.overlayfs\"..." type=io.containerd.snapshotter.v1 sandbox.go:138: time="2024-11-21T21:19:25.213157360Z" level=info msg="loading plugin \"io.containerd.snapshotter.v1.aufs\"..." type=io.containerd.snapshotter.v1 sandbox.go:138: time="2024-11-21T21:19:25.214203647Z" level=info msg="skip loading plugin \"io.containerd.snapshotter.v1.aufs\"..." error="aufs is not supported (modprobe aufs failed: exit status 1 \"modprobe: can't change directory to '/lib/modules': No such file or directory\\n\"): skip plugin" type=io.containerd.snapshotter.v1 sandbox.go:138: time="2024-11-21T21:19:25.214233293Z" level=info msg="loading plugin \"io.containerd.snapshotter.v1.zfs\"..." type=io.containerd.snapshotter.v1 sandbox.go:138: time="2024-11-21T21:19:25.214613057Z" level=info msg="skip loading plugin \"io.containerd.snapshotter.v1.zfs\"..." error="path /tmp/bktest_containerd2409304663/root/io.containerd.snapshotter.v1.zfs must be a zfs filesystem to be used with the zfs snapshotter: skip plugin" type=io.containerd.snapshotter.v1 sandbox.go:138: time="2024-11-21T21:19:25.214647322Z" level=info msg="loading plugin \"io.containerd.metadata.v1.bolt\"..." type=io.containerd.metadata.v1 sandbox.go:138: time="2024-11-21T21:19:25.214727412Z" level=warning msg="could not use snapshotter devmapper in metadata plugin" error="devmapper not configured" sandbox.go:138: time="2024-11-21T21:19:25.214756267Z" level=info msg="metadata content store policy set" policy=shared sandbox.go:138: time="2024-11-21T21:19:25.220029071Z" level=info msg="loading plugin \"io.containerd.differ.v1.walking\"..." type=io.containerd.differ.v1 sandbox.go:138: time="2024-11-21T21:19:25.220058186Z" level=info msg="loading plugin \"io.containerd.event.v1.exchange\"..." type=io.containerd.event.v1 s

Check failure on line 2489 in client/client_test.go

View workflow job for this annotation

GitHub Actions / test / run (containerd-1.7, ./client ./cmd/buildctl ./worker/containerd ./solver ./frontend, integration)

Failed: client/TestIntegration/TestFileOpSymlink/worker=containerd-1.7

=== RUN TestIntegration/TestFileOpSymlink/worker=containerd-1.7 === PAUSE TestIntegration/TestFileOpSymlink/worker=containerd-1.7 === CONT TestIntegration/TestFileOpSymlink/worker=containerd-1.7 client_test.go:2489: Error Trace: /src/client/client_test.go:2489 /src/util/testutil/integration/run.go:97 /src/util/testutil/integration/run.go:211 Error: Not equal: expected: []byte{0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73} actual : []byte(nil) Diff: --- Expected +++ Actual @@ -1,4 +1,2 @@ -([]uint8) (len=8) { - 00000000 63 6f 6e 74 65 6e 74 73 |contents| -} +([]uint8) <nil> Test: TestIntegration/TestFileOpSymlink/worker=containerd-1.7 sandbox.go:135: stdout: /opt/containerd-alt-17/bin/containerd --config /tmp/bktest_containerd2393208322/config.toml sandbox.go:135: stderr: /opt/containerd-alt-17/bin/containerd --config /tmp/bktest_containerd2393208322/config.toml sandbox.go:138: > StartCmd 2024-11-21 21:21:38.419072193 +0000 UTC m=+238.543722509 /opt/containerd-alt-17/bin/containerd --config /tmp/bktest_containerd2393208322/config.toml sandbox.go:138: time="2024-11-21T21:21:38.451745572Z" level=info msg="starting containerd" revision=57f17b0a6295a39009d861b89e3b3b87b005ca27 version=v1.7.23 sandbox.go:138: time="2024-11-21T21:21:38.484436682Z" level=info msg="loading plugin \"io.containerd.event.v1.exchange\"..." type=io.containerd.event.v1 sandbox.go:138: time="2024-11-21T21:21:38.484526339Z" level=info msg="loading plugin \"io.containerd.internal.v1.opt\"..." type=io.containerd.internal.v1 sandbox.go:138: time="2024-11-21T21:21:38.484576442Z" level=info msg="loading plugin \"io.containerd.warning.v1.deprecations\"..." type=io.containerd.warning.v1 sandbox.go:138: time="2024-11-21T21:21:38.484598093Z" level=info msg="loading plugin \"io.containerd.snapshotter.v1.blockfile\"..." type=io.containerd.snapshotter.v1 sandbox.go:138: time="2024-11-21T21:21:38.484691847Z" 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:138: time="2024-11-21T21:21:38.484709700Z" level=info msg="loading plugin \"io.containerd.snapshotter.v1.devmapper\"..." type=io.containerd.snapshotter.v1 sandbox.go:138: time="2024-11-21T21:21:38.484726381Z" level=info msg="skip loading plugin \"io.containerd.snapshotter.v1.devmapper\"..." error="devmapper not configured: skip plugin" type=io.containerd.snapshotter.v1 sandbox.go:138: time="2024-11-21T21:21:38.484738173Z" level=info msg="loading plugin \"io.containerd.snapshotter.v1.native\"..." type=io.containerd.snapshotter.v1 sandbox.go:138: time="2024-11-21T21:21:38.485804700Z" level=info msg="loading plugin \"io.containerd.snapshotter.v1.overlayfs\"..." type=io.containerd.snapshotter.v1 sandbox.go:138: time="2024-11-21T21:21:38.486709365Z" level=info msg="loading plugin \"io.containerd.snapshotter.v1.aufs\"..." type=io.containerd.snapshotter.v1 sandbox.go:138: time="2024-11-21T21:21:38.488464835Z" level=info msg="skip loading plugin \"io.containerd.snapshotter.v1.aufs\"..." error="aufs is not supported (modprobe aufs failed: exit status 1 \"modprobe: can't change directory to '/lib/modules': No such file or directory\\n\"): skip plugin" type=io.containerd.snapshotter.v1 sandbox.go:138: time="2024-11-21T21:21:38.488485002Z" level=info msg="loading plugin \"io.containerd.snapshotter.v1.zfs\"..." type=io.containerd.snapshotter.v1 sandbox.go:138: time="2024-11-21T21:21:38.488704491Z" level=info msg="skip loading plugin \"io.containerd.snapshotter.v1.zfs\"..." error="path /tmp/bktest_containerd2393208322/root/io.containerd.snapshotter.v1

Check failure on line 2489 in client/client_test.go

View workflow job for this annotation

GitHub Actions / test / run (containerd-snapshotter-stargz, ./client ./cmd/buildctl ./worker/containerd ./solver ./fronte...

Failed: client/TestIntegration/TestFileOpSymlink/worker=containerd-snapshotter-stargz

=== RUN TestIntegration/TestFileOpSymlink/worker=containerd-snapshotter-stargz === PAUSE TestIntegration/TestFileOpSymlink/worker=containerd-snapshotter-stargz === CONT TestIntegration/TestFileOpSymlink/worker=containerd-snapshotter-stargz client_test.go:2489: Error Trace: /src/client/client_test.go:2489 /src/util/testutil/integration/run.go:97 /src/util/testutil/integration/run.go:211 Error: Not equal: expected: []byte{0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73} actual : []byte(nil) Diff: --- Expected +++ Actual @@ -1,4 +1,2 @@ -([]uint8) (len=8) { - 00000000 63 6f 6e 74 65 6e 74 73 |contents| -} +([]uint8) <nil> Test: TestIntegration/TestFileOpSymlink/worker=containerd-snapshotter-stargz sandbox.go:135: stdout: /usr/bin/containerd --config /tmp/bktest_containerd1967411701/config.toml sandbox.go:135: stderr: /usr/bin/containerd --config /tmp/bktest_containerd1967411701/config.toml sandbox.go:138: > StartCmd 2024-11-21 21:22:50.827878517 +0000 UTC m=+298.422588895 /usr/bin/containerd --config /tmp/bktest_containerd1967411701/config.toml sandbox.go:138: time="2024-11-21T21:22:50.844128530Z" level=info msg="starting containerd" revision= version=2.0.0+unknown sandbox.go:138: time="2024-11-21T21:22:50.852115786Z" level=warning msg="Configuration migrated from version 2, use `containerd config migrate` to avoid migration" t="2.464µs" sandbox.go:138: time="2024-11-21T21:22:50.852138719Z" level=info msg="loading plugin" id=io.containerd.image-verifier.v1.bindir type=io.containerd.image-verifier.v1 sandbox.go:138: time="2024-11-21T21:22:50.852156271Z" level=info msg="loading plugin" id=io.containerd.internal.v1.opt type=io.containerd.internal.v1 sandbox.go:138: time="2024-11-21T21:22:50.852196727Z" level=info msg="loading plugin" id=io.containerd.warning.v1.deprecations type=io.containerd.warning.v1 sandbox.go:138: time="2024-11-21T21:22:50.852208820Z" level=info msg="loading plugin" id=io.containerd.content.v1.content type=io.containerd.content.v1 sandbox.go:138: time="2024-11-21T21:22:50.852232374Z" level=info msg="loading plugin" id=io.containerd.snapshotter.v1.blockfile type=io.containerd.snapshotter.v1 sandbox.go:138: time="2024-11-21T21:22:50.852296524Z" level=info msg="skip loading plugin" error="no scratch file generator: skip plugin" id=io.containerd.snapshotter.v1.blockfile type=io.containerd.snapshotter.v1 sandbox.go:138: time="2024-11-21T21:22:50.852307845Z" level=info msg="loading plugin" id=io.containerd.snapshotter.v1.devmapper type=io.containerd.snapshotter.v1 sandbox.go:138: time="2024-11-21T21:22:50.852324386Z" level=info msg="skip loading plugin" error="devmapper not configured: skip plugin" id=io.containerd.snapshotter.v1.devmapper type=io.containerd.snapshotter.v1 sandbox.go:138: time="2024-11-21T21:22:50.852333012Z" level=info msg="loading plugin" id=io.containerd.snapshotter.v1.native type=io.containerd.snapshotter.v1 sandbox.go:138: time="2024-11-21T21:22:50.852417700Z" level=info msg="loading plugin" id=io.containerd.snapshotter.v1.overlayfs type=io.containerd.snapshotter.v1 sandbox.go:138: time="2024-11-21T21:22:50.852635197Z" level=info msg="loading plugin" id=io.containerd.snapshotter.v1.zfs type=io.containerd.snapshotter.v1 sandbox.go:138: time="2024-11-21T21:22:50.852677867Z" level=info msg="skip loading plugin" error="lstat /tmp/bktest_containerd1967411701/root/io.containerd.snapshotter.v1.zfs: no such file or directory: skip plugin" id=io.containerd.snapshotter.v1.zfs type=io.containerd.snapshotter.v1 sandbox.go:138: time="2024-11-21T21:22:50.852692604Z" level=info msg="loading plugin" id=io.containerd.event.v1.exchange type=io.contain

Check failure on line 2489 in client/client_test.go

View workflow job for this annotation

GitHub Actions / test / run (oci, ./client ./cmd/buildctl ./worker/containerd ./solver ./frontend, integration)

Failed: client/TestIntegration/TestFileOpSymlink/worker=oci

=== RUN TestIntegration/TestFileOpSymlink/worker=oci === PAUSE TestIntegration/TestFileOpSymlink/worker=oci === CONT TestIntegration/TestFileOpSymlink/worker=oci client_test.go:2489: Error Trace: /src/client/client_test.go:2489 /src/util/testutil/integration/run.go:97 /src/util/testutil/integration/run.go:211 Error: Not equal: expected: []byte{0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73} actual : []byte(nil) Diff: --- Expected +++ Actual @@ -1,4 +1,2 @@ -([]uint8) (len=8) { - 00000000 63 6f 6e 74 65 6e 74 73 |contents| -} +([]uint8) <nil> Test: TestIntegration/TestFileOpSymlink/worker=oci sandbox.go:135: 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_config3315460788/buildkitd.toml --root /tmp/bktest_buildkitd2722993241 --addr unix:///tmp/bktest_buildkitd2722993241/buildkitd.sock --debug sandbox.go:138: > StartCmd 2024-11-21 21:19:21.341197367 +0000 UTC m=+106.728866833 /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_config3315460788/buildkitd.toml --root /tmp/bktest_buildkitd2722993241 --addr unix:///tmp/bktest_buildkitd2722993241/buildkitd.sock --debug sandbox.go:138: time="2024-11-21T21:19:21Z" level=info msg="auto snapshotter: using overlayfs" sandbox.go:138: time="2024-11-21T21:19:21Z" level=debug msg="could not read \"/tmp/bktest_buildkitd2722993241/net/cni\" for cleanup: open /tmp/bktest_buildkitd2722993241/net/cni: no such file or directory" sandbox.go:138: time="2024-11-21T21:19:21Z" level=debug msg="creating new network namespace nus1rdmbwnrcbeuwi6nx5vadt" sandbox.go:138: time="2024-11-21T21:19:21Z" level=debug msg="finished creating network namespace nus1rdmbwnrcbeuwi6nx5vadt" sandbox.go:138: time="2024-11-21T21:19:21Z" level=debug msg="finished setting up network namespace nus1rdmbwnrcbeuwi6nx5vadt" sandbox.go:138: time="2024-11-21T21:19:21Z" level=info msg="found worker \"cny6brasjzul9z9nblbcaid4c\", labels=map[org.mobyproject.buildkit.worker.executor:oci org.mobyproject.buildkit.worker.hostname:9f6d44eb1eda org.mobyproject.buildkit.worker.network:cni 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/arm/v7 linux/arm/v6]" sandbox.go:138: time="2024-11-21T21:19:21Z" level=info msg="found 1 workers, default=\"cny6brasjzul9z9nblbcaid4c\"" sandbox.go:138: time="2024-11-21T21:19:21Z" level=warning msg="currently, only the default worker can be used." sandbox.go:138: time="2024-11-21T21:19:21Z" level=info msg="running server on /tmp/bktest_buildkitd2722993241/buildkitd.sock" sandbox.go:138: time="2024-11-21T21:19:21Z" level=debug msg="resolve exporter tar with map[]" spanID=5dc2cc1445356546 traceID=a11740cf876dc9bd74c88b52bf5363d0 sandbox.go:138: time="2024-11-21T21:19:21Z" level=debug msg="session started" spanID=5f287ea40ea919a6 traceID=36e2c9fe39cc1f6299afda51b95e94b5 sandbox.go:138: time="2024-11-21T21:19:21Z" level=debug msg="session finished: <nil>" spanID=5f287ea40ea919a6 traceID=36e2c9fe39cc1f6299afda51b95e94b5 sandbox.go:135: 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_config3315460788/buildkitd.t

Check failure on line 2489 in client/client_test.go

View workflow job for this annotation

GitHub Actions / test / run (oci-rootless, ./client ./cmd/buildctl ./worker/containerd ./solver ./frontend, integration)

Failed: client/TestIntegration/TestFileOpSymlink/worker=oci-rootless

=== RUN TestIntegration/TestFileOpSymlink/worker=oci-rootless === PAUSE TestIntegration/TestFileOpSymlink/worker=oci-rootless === CONT TestIntegration/TestFileOpSymlink/worker=oci-rootless client_test.go:2489: Error Trace: /src/client/client_test.go:2489 /src/util/testutil/integration/run.go:97 /src/util/testutil/integration/run.go:211 Error: Not equal: expected: []byte{0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73} actual : []byte(nil) Diff: --- Expected +++ Actual @@ -1,4 +1,2 @@ -([]uint8) (len=8) { - 00000000 63 6f 6e 74 65 6e 74 73 |contents| -} +([]uint8) <nil> Test: TestIntegration/TestFileOpSymlink/worker=oci-rootless sandbox.go:135: stdout: /usr/bin/sudo -u #1000 -i -- exec rootlesskit buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --config=/tmp/bktest_config92055370/buildkitd.toml --root /tmp/bktest_buildkitd3247219376 --addr unix:///tmp/bktest_buildkitd3247219376/buildkitd.sock --debug sandbox.go:135: stderr: /usr/bin/sudo -u #1000 -i -- exec rootlesskit buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --config=/tmp/bktest_config92055370/buildkitd.toml --root /tmp/bktest_buildkitd3247219376 --addr unix:///tmp/bktest_buildkitd3247219376/buildkitd.sock --debug sandbox.go:138: > StartCmd 2024-11-21 21:19:23.416278298 +0000 UTC m=+104.372207095 /usr/bin/sudo -u #1000 -i -- exec rootlesskit buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --config=/tmp/bktest_config92055370/buildkitd.toml --root /tmp/bktest_buildkitd3247219376 --addr unix:///tmp/bktest_buildkitd3247219376/buildkitd.sock --debug sandbox.go:138: warning: GOCOVERDIR not set, no coverage data emitted sandbox.go:138: time="2024-11-21T21:19:23Z" level=info msg="auto snapshotter: using overlayfs" sandbox.go:138: time="2024-11-21T21:19:23Z" level=debug msg="running in rootless mode" sandbox.go:138: time="2024-11-21T21:19:23Z" level=info msg="found worker \"pp2cdscl2hc5m2zmxlb2a04qf\", labels=map[org.mobyproject.buildkit.worker.executor:oci org.mobyproject.buildkit.worker.hostname:c2d0228fbdc6 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/arm/v7 linux/arm/v6]" sandbox.go:138: time="2024-11-21T21:19:23Z" level=info msg="found 1 workers, default=\"pp2cdscl2hc5m2zmxlb2a04qf\"" sandbox.go:138: time="2024-11-21T21:19:23Z" level=warning msg="currently, only the default worker can be used." sandbox.go:138: time="2024-11-21T21:19:23Z" level=info msg="running server on /tmp/bktest_buildkitd3247219376/buildkitd.sock" sandbox.go:138: time="2024-11-21T21:19:23Z" level=debug msg="resolve exporter tar with map[]" spanID=8148bab85e68d0a4 traceID=0c6d3c31b622200903e9dce307770e3c sandbox.go:138: time="2024-11-21T21:19:23Z" level=debug msg="session started" spanID=83131c9cd68599f1 traceID=f98cdaf5855c9f38f094a34f939c93e6 sandbox.go:138: time="2024-11-21T21:19:23Z" level=debug msg="session finished: <nil>" spanID=83131c9cd68599f1 traceID=f98cdaf5855c9f38f094a34f939c93e6 --- FAIL: TestIntegration/TestFileOpSymlink/worker=oci-rootless (0.57s)

Check failure on line 2489 in client/client_test.go

View workflow job for this annotation

GitHub Actions / test / run (oci-rootless-slirp4netns-detachnetns, ./client ./cmd/buildctl ./worker/containerd ./solver ....

Failed: client/TestIntegration/TestFileOpSymlink/worker=oci-rootless-slirp4netns-detachnetns

=== RUN TestIntegration/TestFileOpSymlink/worker=oci-rootless-slirp4netns-detachnetns === PAUSE TestIntegration/TestFileOpSymlink/worker=oci-rootless-slirp4netns-detachnetns === CONT TestIntegration/TestFileOpSymlink/worker=oci-rootless-slirp4netns-detachnetns client_test.go:2489: Error Trace: /src/client/client_test.go:2489 /src/util/testutil/integration/run.go:97 /src/util/testutil/integration/run.go:211 Error: Not equal: expected: []byte{0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73} actual : []byte(nil) Diff: --- Expected +++ Actual @@ -1,4 +1,2 @@ -([]uint8) (len=8) { - 00000000 63 6f 6e 74 65 6e 74 73 |contents| -} +([]uint8) <nil> Test: TestIntegration/TestFileOpSymlink/worker=oci-rootless-slirp4netns-detachnetns sandbox.go:135: stderr: /usr/bin/sudo -u #1000 -i -- exec rootlesskit --net=slirp4netns --copy-up=/etc --disable-host-loopback --detach-netns buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --config=/tmp/bktest_config1052394383/buildkitd.toml --root /tmp/bktest_buildkitd992512536 --addr unix:///tmp/bktest_buildkitd992512536/buildkitd.sock --debug sandbox.go:138: > StartCmd 2024-11-21 21:19:16.704944676 +0000 UTC m=+102.004479722 /usr/bin/sudo -u #1000 -i -- exec rootlesskit --net=slirp4netns --copy-up=/etc --disable-host-loopback --detach-netns buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --config=/tmp/bktest_config1052394383/buildkitd.toml --root /tmp/bktest_buildkitd992512536 --addr unix:///tmp/bktest_buildkitd992512536/buildkitd.sock --debug sandbox.go:138: warning: GOCOVERDIR not set, no coverage data emitted sandbox.go:138: time="2024-11-21T21:19:16Z" level=info msg="auto snapshotter: using overlayfs" sandbox.go:138: time="2024-11-21T21:19:16Z" level=debug msg="running in rootless mode" sandbox.go:138: time="2024-11-21T21:19:16Z" level=info msg="found worker \"1fppoazrul1tiy8ge79xhcdgd\", labels=map[org.mobyproject.buildkit.worker.executor:oci org.mobyproject.buildkit.worker.hostname:8d1c22a4ec3c 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/arm/v7 linux/arm/v6]" sandbox.go:138: time="2024-11-21T21:19:16Z" level=info msg="found 1 workers, default=\"1fppoazrul1tiy8ge79xhcdgd\"" sandbox.go:138: time="2024-11-21T21:19:16Z" level=warning msg="currently, only the default worker can be used." sandbox.go:138: time="2024-11-21T21:19:16Z" level=info msg="running server on /tmp/bktest_buildkitd992512536/buildkitd.sock" sandbox.go:138: time="2024-11-21T21:19:16Z" level=debug msg="session started" spanID=36bab4a4e4682f50 traceID=a5dcb0c5e953062bb086739ae8b33f79 sandbox.go:138: time="2024-11-21T21:19:16Z" level=debug msg="resolve exporter tar with map[]" spanID=143d9efb77c8810b traceID=3e0a93f4f91dd36433be21c3e836e63e sandbox.go:138: time="2024-11-21T21:19:16Z" level=debug msg="session finished: <nil>" spanID=36bab4a4e4682f50 traceID=a5dcb0c5e953062bb086739ae8b33f79 sandbox.go:135: stdout: /usr/bin/sudo -u #1000 -i -- exec rootlesskit --net=slirp4netns --copy-up=/etc --disable-host-loopback --detach-netns buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --config=/tmp/bktest

Check failure on line 2489 in client/client_test.go

View workflow job for this annotation

GitHub Actions / test / run (oci-snapshotter-stargz, ./client ./cmd/buildctl ./worker/containerd ./solver ./frontend, int...

Failed: client/TestIntegration/TestFileOpSymlink/worker=oci-snapshotter-stargz

=== RUN TestIntegration/TestFileOpSymlink/worker=oci-snapshotter-stargz === PAUSE TestIntegration/TestFileOpSymlink/worker=oci-snapshotter-stargz === CONT TestIntegration/TestFileOpSymlink/worker=oci-snapshotter-stargz client_test.go:2489: Error Trace: /src/client/client_test.go:2489 /src/util/testutil/integration/run.go:97 /src/util/testutil/integration/run.go:211 Error: Not equal: expected: []byte{0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73} actual : []byte(nil) Diff: --- Expected +++ Actual @@ -1,4 +1,2 @@ -([]uint8) (len=8) { - 00000000 63 6f 6e 74 65 6e 74 73 |contents| -} +([]uint8) <nil> Test: TestIntegration/TestFileOpSymlink/worker=oci-snapshotter-stargz sandbox.go:135: stdout: /usr/bin/buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --oci-worker-snapshotter=stargz --config=/tmp/bktest_config2597284162/buildkitd.toml --root /tmp/bktest_buildkitd3215845014 --addr unix:///tmp/bktest_buildkitd3215845014/buildkitd.sock --debug sandbox.go:135: stderr: /usr/bin/buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --oci-worker-snapshotter=stargz --config=/tmp/bktest_config2597284162/buildkitd.toml --root /tmp/bktest_buildkitd3215845014 --addr unix:///tmp/bktest_buildkitd3215845014/buildkitd.sock --debug sandbox.go:138: > StartCmd 2024-11-21 21:19:22.708269717 +0000 UTC m=+110.986129561 /usr/bin/buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --oci-worker-snapshotter=stargz --config=/tmp/bktest_config2597284162/buildkitd.toml --root /tmp/bktest_buildkitd3215845014 --addr unix:///tmp/bktest_buildkitd3215845014/buildkitd.sock --debug sandbox.go:138: time="2024-11-21T21:19:22Z" level=debug msg="could not read \"/tmp/bktest_buildkitd3215845014/net/cni\" for cleanup: open /tmp/bktest_buildkitd3215845014/net/cni: no such file or directory" sandbox.go:138: time="2024-11-21T21:19:22Z" level=debug msg="creating new network namespace o0o2xv1b5p95bhvlrtcenusul" sandbox.go:138: time="2024-11-21T21:19:22Z" level=debug msg="finished creating network namespace o0o2xv1b5p95bhvlrtcenusul" sandbox.go:138: time="2024-11-21T21:19:22Z" level=debug msg="finished setting up network namespace o0o2xv1b5p95bhvlrtcenusul" sandbox.go:138: time="2024-11-21T21:19:22Z" level=info msg="found worker \"tjofq1b8124wr7dbaprlfl64f\", labels=map[org.mobyproject.buildkit.worker.executor:oci org.mobyproject.buildkit.worker.hostname:717803c949bc org.mobyproject.buildkit.worker.network:cni 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:stargz], platforms=[linux/amd64 linux/amd64/v2 linux/amd64/v3 linux/arm64 linux/riscv64 linux/ppc64le linux/s390x linux/386 linux/arm/v7 linux/arm/v6]" sandbox.go:138: time="2024-11-21T21:19:22Z" level=info msg="found 1 workers, default=\"tjofq1b8124wr7dbaprlfl64f\"" sandbox.go:138: time="2024-11-21T21:19:22Z" level=warning msg="currently, only the default worker can be used." sandbox.go:138: time="2024-11-21T21:19:22Z" level=info msg="running server on /tmp/bktest_buildkitd3215845014/buildkitd.sock" sandbox.go:138: time="2024-11-21T21:19:22Z" level=debug msg="session started" spanID=11a509477118df0b traceID=917a2718252894001f7e75375b011a8c sandbox.go:138: time="2024-11-21T21:19:22Z" level=debug msg="resolve exporter tar with map[]" spanID=609e431fb4f374bb traceID=485765

Check failure on line 2489 in client/client_test.go

View workflow job for this annotation

GitHub Actions / test / run (./client, oci, nydus, integration)

Failed: client/TestIntegration/TestFileOpSymlink/worker=oci

=== RUN TestIntegration/TestFileOpSymlink/worker=oci === PAUSE TestIntegration/TestFileOpSymlink/worker=oci === CONT TestIntegration/TestFileOpSymlink/worker=oci client_test.go:2489: Error Trace: /src/client/client_test.go:2489 /src/util/testutil/integration/run.go:97 /src/util/testutil/integration/run.go:211 Error: Not equal: expected: []byte{0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73} actual : []byte(nil) Diff: --- Expected +++ Actual @@ -1,4 +1,2 @@ -([]uint8) (len=8) { - 00000000 63 6f 6e 74 65 6e 74 73 |contents| -} +([]uint8) <nil> Test: TestIntegration/TestFileOpSymlink/worker=oci sandbox.go:135: 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_config2269514254/buildkitd.toml --root /tmp/bktest_buildkitd1288025739 --addr unix:///tmp/bktest_buildkitd1288025739/buildkitd.sock --debug sandbox.go:135: 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_config2269514254/buildkitd.toml --root /tmp/bktest_buildkitd1288025739 --addr unix:///tmp/bktest_buildkitd1288025739/buildkitd.sock --debug sandbox.go:138: > StartCmd 2024-11-21 21:19:11.088170711 +0000 UTC m=+89.455000820 /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_config2269514254/buildkitd.toml --root /tmp/bktest_buildkitd1288025739 --addr unix:///tmp/bktest_buildkitd1288025739/buildkitd.sock --debug sandbox.go:138: time="2024-11-21T21:19:11Z" level=info msg="auto snapshotter: using overlayfs" sandbox.go:138: time="2024-11-21T21:19:11Z" level=debug msg="could not read \"/tmp/bktest_buildkitd1288025739/net/cni\" for cleanup: open /tmp/bktest_buildkitd1288025739/net/cni: no such file or directory" sandbox.go:138: time="2024-11-21T21:19:11Z" level=debug msg="creating new network namespace u4gnw2fp7wfdify7cmdj9am4o" sandbox.go:138: time="2024-11-21T21:19:11Z" level=debug msg="finished creating network namespace u4gnw2fp7wfdify7cmdj9am4o" sandbox.go:138: time="2024-11-21T21:19:11Z" level=debug msg="finished setting up network namespace u4gnw2fp7wfdify7cmdj9am4o" sandbox.go:138: time="2024-11-21T21:19:11Z" level=info msg="found worker \"zjh4akowxe8cmfygfkf4dg8yc\", labels=map[org.mobyproject.buildkit.worker.executor:oci org.mobyproject.buildkit.worker.hostname:cea0f58b6fa6 org.mobyproject.buildkit.worker.network:cni 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/arm/v7 linux/arm/v6]" sandbox.go:138: time="2024-11-21T21:19:11Z" level=info msg="found 1 workers, default=\"zjh4akowxe8cmfygfkf4dg8yc\"" sandbox.go:138: time="2024-11-21T21:19:11Z" level=warning msg="currently, only the default worker can be used." sandbox.go:138: time="2024-11-21T21:19:11Z" level=info msg="running server on /tmp/bktest_buildkitd1288025739/buildkitd.sock" sandbox.go:138: time="2024-11-21T21:19:11Z" level=debug msg="session started" spanID=36d4e3bc4ec60518 traceID=e82089e7a52333eda36d714a718cbac5 sandbox.go:138: time="2024-11-21T21:19:11Z" level=debug msg="resolve exporter tar with map[]" spanID=857ec8a8c058e4e5 traceID=212d3f42af22fa2b263de4c6c532f5b7 sandbox.go:138: time="2024-11-21T21:19:1

// make sure it was chowned properly
require.Equal(t, true, ok)
require.Equal(t, linkOwner, header.Uid)
require.Equal(t, linkGroup, header.Gid)

require.Equal(t, dummyTime, header.ModTime)
}

func testFileOpRmWildcard(t *testing.T, sb integration.Sandbox) {
requiresLinux(t)
c, err := New(sb.Context(), sb.Address())
Expand Down
67 changes: 67 additions & 0 deletions client/llb/fileop.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ func (fa *FileAction) Mkfile(p string, m os.FileMode, dt []byte, opt ...MkfileOp
return a
}

// Symlink creates a symlink at `newpath` that points to `oldpath`
func (fa *FileAction) Symlink(oldpath, newpath string, opt ...SymlinkOption) *FileAction {
a := Symlink(oldpath, newpath, opt...)
a.prev = fa
return a
}

func (fa *FileAction) Rm(p string, opt ...RmOption) *FileAction {
a := Rm(p, opt...)
a.prev = fa
Expand Down Expand Up @@ -193,6 +200,7 @@ type ChownOption interface {
MkdirOption
MkfileOption
CopyOption
SymlinkOption
}

type mkdirOptionFunc func(*MkdirInfo)
Expand Down Expand Up @@ -290,6 +298,10 @@ func (co ChownOpt) SetCopyOption(mi *CopyInfo) {
mi.ChownOpt = &co
}

func (co ChownOpt) SetSymlinkOption(si *SymlinkInfo) {
si.ChownOpt = &co
}

func (co *ChownOpt) marshal(base pb.InputIndex) *pb.ChownOpt {
if co == nil {
return nil
Expand Down Expand Up @@ -337,6 +349,57 @@ func Mkfile(p string, m os.FileMode, dt []byte, opts ...MkfileOption) *FileActio
}
}

// SymlinkInfo is the modifiable options used to create symlinks
type SymlinkInfo struct {
ChownOpt *ChownOpt
CreatedTime *time.Time
}

func (si *SymlinkInfo) SetSymlinkOption(si2 *SymlinkInfo) {
*si2 = *si
}

type SymlinkOption interface {
SetSymlinkOption(*SymlinkInfo)
}

// Symlink creates a symlink at `newpath` that points to `oldpath`
func Symlink(oldpath, newpath string, opts ...SymlinkOption) *FileAction {
var si SymlinkInfo
for _, o := range opts {
o.SetSymlinkOption(&si)
}

return &FileAction{
action: &fileActionSymlink{
oldpath: oldpath,
newpath: newpath,
info: si,
},
}
}

type fileActionSymlink struct {
oldpath string
newpath string
info SymlinkInfo
}

func (s *fileActionSymlink) addCaps(f *FileOp) {
addCap(&f.constraints, pb.CapFileSymlinkCreate)
}

func (s *fileActionSymlink) toProtoAction(_ context.Context, _ string, base pb.InputIndex) (pb.IsFileAction, error) {
return &pb.FileAction_Symlink{
Symlink: &pb.FileActionSymlink{
Oldpath: s.oldpath,
Newpath: s.newpath,
Owner: s.info.ChownOpt.marshal(base),
Timestamp: marshalTime(s.info.CreatedTime),
},
}, nil
}

type MkfileOption interface {
SetMkfileOption(*MkfileInfo)
}
Expand Down Expand Up @@ -606,6 +669,10 @@ func (c CreatedTime) SetMkfileOption(mi *MkfileInfo) {
mi.CreatedTime = (*time.Time)(&c)
}

func (c CreatedTime) SetSymlinkOption(si *SymlinkInfo) {
si.CreatedTime = (*time.Time)(&c)
}

func (c CreatedTime) SetCopyOption(mi *CopyInfo) {
mi.CreatedTime = (*time.Time)(&c)
}
Expand Down
35 changes: 35 additions & 0 deletions client/llb/fileop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,41 @@ func TestFileMkfile(t *testing.T) {
require.Equal(t, int64(-1), mkdir.Timestamp)
}

func TestFileSymlink(t *testing.T) {
t.Parallel()

st := Scratch().
File(Mkfile("/foo", 0700, []byte("data"))).
File(Symlink("foo", "/bar"))
def, err := st.Marshal(context.TODO())

require.NoError(t, err)

m, arr := parseDef(t, def.Def)
require.Equal(t, 3, len(arr))

dgst, idx := last(t, arr)
require.Equal(t, 0, idx)
require.Equal(t, m[dgst], arr[1])

f := arr[1].Op.(*pb.Op_File).File
require.Equal(t, 1, len(arr[1].Inputs))
require.Equal(t, m[arr[1].Inputs[0].Digest], arr[0])
require.Equal(t, 0, int(arr[1].Inputs[0].Index))

require.Equal(t, 1, len(f.Actions))

action := f.Actions[0]
require.Equal(t, 0, int(action.Input))
require.Equal(t, -1, int(action.SecondaryInput))
require.Equal(t, 0, int(action.Output))

symlink := action.Action.(*pb.FileAction_Symlink).Symlink

require.Equal(t, "foo", symlink.Oldpath)
require.Equal(t, "/bar", symlink.Newpath)
}

func TestFileRm(t *testing.T) {
t.Parallel()

Expand Down
2 changes: 2 additions & 0 deletions cmd/buildctl/debug/dumpllb.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ func attr(dgst digest.Digest, op *pb.Op) (string, string) {
name = fmt.Sprintf("mkdir{path=%s}", act.Mkdir.Path)
case *pb.FileAction_Rm:
name = fmt.Sprintf("rm{path=%s}", act.Rm.Path)
case *pb.FileAction_Symlink:
name = fmt.Sprintf("symlink{oldpath=%s, newpath=%s}", act.Symlink.Oldpath, act.Symlink.Newpath)
}

names = append(names, name)
Expand Down
55 changes: 55 additions & 0 deletions solver/llbsolver/file/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,40 @@ func mkdir(d string, action *pb.FileActionMkDir, user *copy.User, idmap *idtools
return nil
}

func symlink(d string, action *pb.FileActionSymlink, user *copy.User, idmap *idtools.IdentityMapping) (err error) {
defer func() {
var osErr *os.PathError
if errors.As(err, &osErr) {
// remove system root from error path if present
osErr.Path = strings.TrimPrefix(osErr.Path, d)
}
}()

newpath, err := fs.RootPath(d, filepath.Join("/", action.Newpath))
if err != nil {
return errors.WithStack(err)
}

ch, err := mapUserToChowner(user, idmap)
if err != nil {
return err
}

if err := os.Symlink(action.Oldpath, newpath); err != nil {
return errors.WithStack(err)
}

if err := copy.Chown(newpath, nil, ch); err != nil {
return errors.WithStack(err)
}

if err := copy.Utimes(newpath, timestampToTime(action.Timestamp)); err != nil {
return errors.WithStack(err)
}

return nil
}

func mkfile(d string, action *pb.FileActionMkFile, user *copy.User, idmap *idtools.IdentityMapping) (err error) {
defer func() {
var osErr *os.PathError
Expand Down Expand Up @@ -304,6 +338,27 @@ func (fb *Backend) Mkfile(ctx context.Context, m, user, group fileoptypes.Mount,
return mkfile(dir, action, u, mnt.m.IdentityMapping())
}

func (fb *Backend) Symlink(ctx context.Context, m, user, group fileoptypes.Mount, action *pb.FileActionSymlink) error {
mnt, ok := m.(*Mount)
if !ok {
return errors.Errorf("invalid mount type %T", m)
}

lm := snapshot.LocalMounter(mnt.m)
dir, err := lm.Mount()
if err != nil {
return err
}
defer lm.Unmount()

u, err := fb.readUserWrapper(action.Owner, user, group)
if err != nil {
return err
}

return symlink(dir, action, u, mnt.m.IdentityMapping())
}

func (fb *Backend) Rm(ctx context.Context, m fileoptypes.Mount, action *pb.FileActionRm) error {
mnt, ok := m.(*Mount)
if !ok {
Expand Down
15 changes: 15 additions & 0 deletions solver/llbsolver/ops/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ func (f *fileOp) CacheMap(ctx context.Context, g session.Group, index int) (*sol
if err != nil {
return nil, false, err
}
case *pb.FileAction_Symlink:
p := a.Symlink.CloneVT()
markInvalid(action.Input)
dt, err = json.Marshal(p)
if err != nil {
return nil, false, err
}
case *pb.FileAction_Rm:
p := a.Rm.CloneVT()
markInvalid(action.Input)
Expand Down Expand Up @@ -586,6 +593,14 @@ func (s *FileOpSolver) getInput(ctx context.Context, idx int, inputs []fileoptyp
if err := s.b.Mkdir(ctx, inpMount, user, group, a.Mkdir); err != nil {
return input{}, err
}
case *pb.FileAction_Symlink:
user, group, err := loadOwner(ctx, a.Symlink.Owner)
if err != nil {
return input{}, err
}
if err := s.b.Symlink(ctx, inpMount, user, group, a.Symlink); err != nil {
return input{}, err
}
case *pb.FileAction_Mkfile:
user, group, err := loadOwner(ctx, a.Mkfile.Owner)
if err != nil {
Expand Down
8 changes: 8 additions & 0 deletions solver/llbsolver/ops/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,7 @@ type mod struct {
rm *pb.FileActionRm
mkfile *pb.FileActionMkFile
copy *pb.FileActionCopy
symlink *pb.FileActionSymlink
copySrc []mod
}

Expand Down Expand Up @@ -643,6 +644,13 @@ func (b *testFileBackend) Mkfile(_ context.Context, m, user, group fileoptypes.M
return nil
}

func (b *testFileBackend) Symlink(_ context.Context, m, user, group fileoptypes.Mount, a *pb.FileActionSymlink) error {
mm := m.(*testMount)
mm.id += "-symlink"
mm.chain = append(mm.chain, mod{symlink: a})
return nil
}

func (b *testFileBackend) Rm(_ context.Context, m fileoptypes.Mount, a *pb.FileActionRm) error {
mm := m.(*testMount)
mm.id += "-rm"
Expand Down
1 change: 1 addition & 0 deletions solver/llbsolver/ops/fileoptypes/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Mount interface {

type Backend interface {
Mkdir(context.Context, Mount, Mount, Mount, *pb.FileActionMkDir) error
Symlink(context.Context, Mount, Mount, Mount, *pb.FileActionSymlink) error
Mkfile(context.Context, Mount, Mount, Mount, *pb.FileActionMkFile) error
Rm(context.Context, Mount, *pb.FileActionRm) error
Copy(context.Context, Mount, Mount, Mount, Mount, *pb.FileActionCopy) error
Expand Down
2 changes: 2 additions & 0 deletions solver/llbsolver/vertex.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,8 @@ func fileOpName(actions []*pb.FileAction) string {
names = append(names, fmt.Sprintf("mkdir %s", a.Mkdir.Path))
case *pb.FileAction_Mkfile:
names = append(names, fmt.Sprintf("mkfile %s", a.Mkfile.Path))
case *pb.FileAction_Symlink:
names = append(names, fmt.Sprintf("symlink %s -> %s", a.Symlink.Newpath, a.Symlink.Oldpath))
case *pb.FileAction_Rm:
names = append(names, fmt.Sprintf("rm %s", a.Rm.Path))
case *pb.FileAction_Copy:
Expand Down
Loading

0 comments on commit ac0ccbf

Please sign in to comment.