From abf373a3b604c487d2ec225c6d4607bfd0f34b94 Mon Sep 17 00:00:00 2001 From: Erik Sipsma Date: Wed, 24 Nov 2021 16:53:26 -0800 Subject: [PATCH] cache: Disable overlay diff for native snapshotter Before this change, test cases were running with an env var that forces the overlay differ to be on even when the native snapshotter was being used, which resulted in failures. Now, that env var is skipped when using the native snapshotter. Additionally, this includes a related change to skip even trying to use the overlay differ when the native snapshotter is in use. Previously, the blob creation code first tried to use the overlay differ and then failed and fell back to the double-walking differ. Now, it just jumps right to the double-walking differ when the native snapshotter is in use. Signed-off-by: Erik Sipsma --- cache/blobs.go | 2 +- util/testutil/integration/containerd.go | 4 ++++ util/testutil/integration/oci.go | 7 ++++++- util/testutil/integration/sandbox.go | 3 --- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/cache/blobs.go b/cache/blobs.go index 79ea3c71..ddb47f51 100644 --- a/cache/blobs.go +++ b/cache/blobs.go @@ -137,7 +137,7 @@ func computeBlobChain(ctx context.Context, sr *immutableRef, createIfNeeded bool case "overlayfs", "stargz": // overlayfs-based snapshotters should support overlay diff. so print warn log on failure. logWarnOnErr = true - case "fuse-overlayfs": + case "fuse-overlayfs", "native": // not supported with fuse-overlayfs snapshotter which doesn't provide overlayfs mounts. // TODO: add support for fuse-overlayfs enableOverlay = false diff --git a/util/testutil/integration/containerd.go b/util/testutil/integration/containerd.go index dc65932e..50c03c2c 100644 --- a/util/testutil/integration/containerd.go +++ b/util/testutil/integration/containerd.go @@ -9,6 +9,7 @@ import ( "os" "os/exec" "path/filepath" + "runtime" "strings" "time" @@ -148,6 +149,9 @@ disabled_plugins = ["cri"] "--containerd-worker-labels=org.mobyproject.buildkit.worker.sandbox=true", // Include use of --containerd-worker-labels to trigger https://github.com/moby/buildkit/pull/603 }, snBuildkitdArgs...) + if runtime.GOOS != "windows" && c.snapshotter != "native" { + c.extraEnv = append(c.extraEnv, "BUILDKIT_DEBUG_FORCE_OVERLAY_DIFF=true") + } buildkitdSock, stop, err := runBuildkitd(ctx, cfg, buildkitdArgs, cfg.Logs, 0, 0, c.extraEnv) if err != nil { printLogs(cfg.Logs, log.Println) diff --git a/util/testutil/integration/oci.go b/util/testutil/integration/oci.go index 7de99a95..ce71643c 100644 --- a/util/testutil/integration/oci.go +++ b/util/testutil/integration/oci.go @@ -5,6 +5,7 @@ import ( "fmt" "log" "os" + "runtime" "github.com/pkg/errors" "github.com/sirupsen/logrus" @@ -68,7 +69,11 @@ func (s *oci) New(ctx context.Context, cfg *BackendConfig) (Backend, func() erro buildkitdArgs = append([]string{"sudo", "-u", fmt.Sprintf("#%d", s.uid), "-i", "--", "exec", "rootlesskit"}, buildkitdArgs...) } - buildkitdSock, stop, err := runBuildkitd(ctx, cfg, buildkitdArgs, cfg.Logs, s.uid, s.gid, nil) + var extraEnv []string + if runtime.GOOS != "windows" && s.snapshotter != "native" { + extraEnv = append(extraEnv, "BUILDKIT_DEBUG_FORCE_OVERLAY_DIFF=true") + } + buildkitdSock, stop, err := runBuildkitd(ctx, cfg, buildkitdArgs, cfg.Logs, s.uid, s.gid, extraEnv) if err != nil { printLogs(cfg.Logs, log.Println) return nil, nil, err diff --git a/util/testutil/integration/sandbox.go b/util/testutil/integration/sandbox.go index df23f357..8367f928 100644 --- a/util/testutil/integration/sandbox.go +++ b/util/testutil/integration/sandbox.go @@ -182,9 +182,6 @@ func runBuildkitd(ctx context.Context, conf *BackendConfig, args []string, logs args = append(args, "--root", tmpdir, "--addr", address, "--debug") cmd := exec.Command(args[0], args[1:]...) cmd.Env = append(os.Environ(), "BUILDKIT_DEBUG_EXEC_OUTPUT=1", "BUILDKIT_DEBUG_PANIC_ON_ERROR=1", "TMPDIR="+filepath.Join(tmpdir, "tmp")) - if runtime.GOOS != "windows" { - cmd.Env = append(cmd.Env, "BUILDKIT_DEBUG_FORCE_OVERLAY_DIFF=true") - } cmd.Env = append(cmd.Env, extraEnv...) cmd.SysProcAttr = getSysProcAttr()