Skip to content

Commit 09d3e20

Browse files
committed
Allow running test in usernamespace
Debian has started building packages with usernamespaces to disable network access and similar isolation features. The containerd package executes a unit test that fails in that scenario, see https://bugs.debian.org/1070411 The code contains a conditional on whether it is running in usernamepsace. This commit expands the unit test to cover this behavior; it was previously untested. The easiest way to reproduce this issue is to prefix the test invocaiton with 'unshare -nr go test [...]' Signed-off-by: Reinhard Tartler <[email protected]>
1 parent 4a18adc commit 09d3e20

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

internal/cri/server/podsandbox/sandbox_run_linux_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import (
3333
"github.com/containerd/containerd/v2/internal/cri/annotations"
3434
"github.com/containerd/containerd/v2/internal/cri/opts"
3535
ostesting "github.com/containerd/containerd/v2/pkg/os/testing"
36+
"github.com/containerd/containerd/v2/pkg/userns"
3637
)
3738

3839
func getRunPodSandboxTestData() (*runtime.PodSandboxConfig, *imagespec.ImageConfig, func(*testing.T, string, *runtimespec.Spec)) {
@@ -142,7 +143,10 @@ func TestLinuxSandboxContainerSpec(t *testing.T) {
142143
Type: runtimespec.IPCNamespace,
143144
})
144145
assert.Contains(t, spec.Linux.Sysctl["net.ipv4.ip_unprivileged_port_start"], "0")
145-
assert.Contains(t, spec.Linux.Sysctl["net.ipv4.ping_group_range"], "0 2147483647")
146+
if !userns.RunningInUserNS() {
147+
assert.Contains(t, spec.Linux.Sysctl["net.ipv4.ping_group_range"], "0 2147483647")
148+
}
149+
146150
},
147151
},
148152
{

0 commit comments

Comments
 (0)