Skip to content

Commit 3b79268

Browse files
committed
e2e_node: Don't use userns in DefaultPocMount tests
When proc mount is set to default, it should mask /proc. The DefaultProcMount test was setting "hostUsers: false" which means to create a user namespaces. This was not causing issues before, because user namespaces was disabled by default and therefore the field was completely ignored. Now that userns is enabled by default, the test is failing as the runtime doesn't always have userns support. One option would be to filter for runtimes that do have userns support. But the default case (/proc is masked) for sure we want to test it without userns support, as it will be applied to all pods. To that end, we add a param "hostUsers bool" to testProcMount that will enable it or not. Then, both test cases that call this function set it accordingly: the default case sets it to true (no user namespace), and the unmasked case with a privileged pod sets it to false (use a user namespace), to verify the /proc mount is unmasked in this case. Signed-off-by: Rodrigo Campos <[email protected]>
1 parent 3725c6f commit 3b79268

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

test/e2e_node/proc_mount_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ var _ = SIGDescribe("DefaultProcMount [LinuxOnly]", framework.WithNodeConformanc
4141
f.NamespacePodSecurityLevel = admissionapi.LevelBaseline
4242

4343
ginkgo.It("will mask proc mounts by default", func(ctx context.Context) {
44-
testProcMount(ctx, f, v1.DefaultProcMount, gomega.BeNumerically(">", 1), gomega.BeNumerically(">", 0))
44+
testProcMount(ctx, f, v1.DefaultProcMount, true, gomega.BeNumerically(">", 1), gomega.BeNumerically(">", 0))
4545
})
4646
})
4747

@@ -85,11 +85,11 @@ var _ = SIGDescribe("ProcMount [LinuxOnly]", feature.ProcMountType, feature.User
8585
if !supportsUserNS(ctx, f) {
8686
e2eskipper.Skipf("runtime does not support user namespaces")
8787
}
88-
testProcMount(ctx, f, v1.UnmaskedProcMount, gomega.Equal(1), gomega.BeZero())
88+
testProcMount(ctx, f, v1.UnmaskedProcMount, false, gomega.Equal(1), gomega.BeZero())
8989
})
9090
})
9191

92-
func testProcMount(ctx context.Context, f *framework.Framework, pmt v1.ProcMountType, expectedLines gomegatypes.GomegaMatcher, expectedReadOnly gomegatypes.GomegaMatcher) {
92+
func testProcMount(ctx context.Context, f *framework.Framework, pmt v1.ProcMountType, hostUsers bool, expectedLines gomegatypes.GomegaMatcher, expectedReadOnly gomegatypes.GomegaMatcher) {
9393
ginkgo.By("creating a target pod")
9494
podClient := e2epod.NewPodClient(f)
9595
pod := podClient.CreateSync(ctx, &v1.Pod{
@@ -106,7 +106,7 @@ func testProcMount(ctx context.Context, f *framework.Framework, pmt v1.ProcMount
106106
},
107107
},
108108
},
109-
HostUsers: &falseVar,
109+
HostUsers: &hostUsers,
110110
},
111111
})
112112

0 commit comments

Comments
 (0)