Skip to content
This repository was archived by the owner on Apr 24, 2025. It is now read-only.

Commit faa28f8

Browse files
committed
Workaround flaky save
Signed-off-by: apostasie <[email protected]>
1 parent 4022057 commit faa28f8

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

cmd/nerdctl/container_run_linux_test.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,20 @@ import (
4242

4343
func TestRunCustomRootfs(t *testing.T) {
4444
testutil.DockerIncompatible(t)
45-
base := testutil.NewBase(t)
45+
// FIXME: root issue is undiagnosed and this is very likely a containerd bug
46+
// It appears that in certain conditions, the proxy content store info method will fail on the layer of the image
47+
// Search for func (pcs *proxyContentStore) ReaderAt(ctx context.Context, desc ocispec.Descriptor) (content.ReaderAt, error) {
48+
// Note that:
49+
// - the problem is still here with containerd and nerdctl v2
50+
// - it seems to affect images that are tagged multiple times, or that share a layer with another image
51+
// - this test is not parallelized - but the fact that namespacing it solves the problem suggest that something
52+
// happening in the default namespace BEFORE this test is run is SOMETIMES setting conditions that will make this fail
53+
// Possible suspects would be concurrent pulls somehow effing things up w. namespaces.
54+
base := testutil.NewBaseWithNamespace(t, testutil.Identifier(t))
4655
rootfs := prepareCustomRootfs(base, testutil.AlpineImage)
56+
t.Cleanup(func() {
57+
base.Cmd("namespace", "remove", testutil.Identifier(t)).Run()
58+
})
4759
defer os.RemoveAll(rootfs)
4860
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")
4961
base.Cmd("run", "--rm", "--entrypoint", "/bin/echo", "--rootfs", rootfs, "echo", "foo").AssertOutExactly("echo foo\n")

cmd/nerdctl/image_save_linux_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ import (
3232
)
3333

3434
func TestSave(t *testing.T) {
35-
base := testutil.NewBase(t)
35+
// See detailed comment in TestRunCustomRootfs for why we need a separate namespace.
36+
base := testutil.NewBaseWithNamespace(t, testutil.Identifier(t))
37+
t.Cleanup(func() {
38+
base.Cmd("namespace", "remove", testutil.Identifier(t)).Run()
39+
})
3640
base.Cmd("pull", testutil.AlpineImage).AssertOK()
3741
archiveTarPath := filepath.Join(t.TempDir(), "a.tar")
3842
base.Cmd("save", "-o", archiveTarPath, testutil.AlpineImage).AssertOK()

cmd/nerdctl/image_save_test.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ import (
2525
)
2626

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

4448
func TestSaveByIdWithDifferentNames(t *testing.T) {
45-
base := testutil.NewBase(t)
49+
// See detailed comment in TestRunCustomRootfs for why we need a separate namespace.
50+
base := testutil.NewBaseWithNamespace(t, testutil.Identifier(t))
51+
t.Cleanup(func() {
52+
base.Cmd("namespace", "remove", testutil.Identifier(t)).Run()
53+
})
4654
base.Cmd("pull", testutil.CommonImage).AssertOK()
4755
inspect := base.InspectImage(testutil.CommonImage)
4856
var id string

0 commit comments

Comments
 (0)