Skip to content

Commit

Permalink
Merge pull request #3179 from apostasie/dev-die-flake-die
Browse files Browse the repository at this point in the history
Workaround flaky save
  • Loading branch information
AkihiroSuda authored Jul 5, 2024
2 parents d6a77ed + faa28f8 commit bc24aa9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
14 changes: 13 additions & 1 deletion cmd/nerdctl/container_run_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,20 @@ import (

func TestRunCustomRootfs(t *testing.T) {
testutil.DockerIncompatible(t)
base := testutil.NewBase(t)
// FIXME: root issue is undiagnosed and this is very likely a containerd bug
// It appears that in certain conditions, the proxy content store info method will fail on the layer of the image
// Search for func (pcs *proxyContentStore) ReaderAt(ctx context.Context, desc ocispec.Descriptor) (content.ReaderAt, error) {
// Note that:
// - the problem is still here with containerd and nerdctl v2
// - it seems to affect images that are tagged multiple times, or that share a layer with another image
// - this test is not parallelized - but the fact that namespacing it solves the problem suggest that something
// happening in the default namespace BEFORE this test is run is SOMETIMES setting conditions that will make this fail
// Possible suspects would be concurrent pulls somehow effing things up w. namespaces.
base := testutil.NewBaseWithNamespace(t, testutil.Identifier(t))
rootfs := prepareCustomRootfs(base, testutil.AlpineImage)
t.Cleanup(func() {
base.Cmd("namespace", "remove", testutil.Identifier(t)).Run()
})
defer os.RemoveAll(rootfs)
base.Cmd("run", "--rm", "--rootfs", rootfs, "/bin/cat", "/proc/self/environ").AssertOutContains("PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin")
base.Cmd("run", "--rm", "--entrypoint", "/bin/echo", "--rootfs", rootfs, "echo", "foo").AssertOutExactly("echo foo\n")
Expand Down
6 changes: 5 additions & 1 deletion cmd/nerdctl/image_save_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ import (
)

func TestSave(t *testing.T) {
base := testutil.NewBase(t)
// See detailed comment in TestRunCustomRootfs for why we need a separate namespace.
base := testutil.NewBaseWithNamespace(t, testutil.Identifier(t))
t.Cleanup(func() {
base.Cmd("namespace", "remove", testutil.Identifier(t)).Run()
})
base.Cmd("pull", testutil.AlpineImage).AssertOK()
archiveTarPath := filepath.Join(t.TempDir(), "a.tar")
base.Cmd("save", "-o", archiveTarPath, testutil.AlpineImage).AssertOK()
Expand Down
12 changes: 10 additions & 2 deletions cmd/nerdctl/image_save_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ import (
)

func TestSaveById(t *testing.T) {
base := testutil.NewBase(t)
// See detailed comment in TestRunCustomRootfs for why we need a separate namespace.
base := testutil.NewBaseWithNamespace(t, testutil.Identifier(t))
t.Cleanup(func() {
base.Cmd("namespace", "remove", testutil.Identifier(t)).Run()
})
base.Cmd("pull", testutil.CommonImage).AssertOK()
inspect := base.InspectImage(testutil.CommonImage)
var id string
Expand All @@ -42,7 +46,11 @@ func TestSaveById(t *testing.T) {
}

func TestSaveByIdWithDifferentNames(t *testing.T) {
base := testutil.NewBase(t)
// See detailed comment in TestRunCustomRootfs for why we need a separate namespace.
base := testutil.NewBaseWithNamespace(t, testutil.Identifier(t))
t.Cleanup(func() {
base.Cmd("namespace", "remove", testutil.Identifier(t)).Run()
})
base.Cmd("pull", testutil.CommonImage).AssertOK()
inspect := base.InspectImage(testutil.CommonImage)
var id string
Expand Down

0 comments on commit bc24aa9

Please sign in to comment.