@@ -28,6 +28,7 @@ import (
28
28
"k8s.io/kubernetes/test/e2e/feature"
29
29
"k8s.io/kubernetes/test/e2e/framework"
30
30
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
31
+ e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper"
31
32
"k8s.io/kubernetes/test/e2e/nodefeature"
32
33
testutils "k8s.io/kubernetes/test/utils"
33
34
imageutils "k8s.io/kubernetes/test/utils/image"
@@ -50,6 +51,9 @@ var _ = SIGDescribe("ProcMount [LinuxOnly]", nodefeature.ProcMountType, nodefeat
50
51
f .NamespacePodSecurityLevel = admissionapi .LevelBaseline
51
52
52
53
f .It ("will fail to unmask proc mounts if not privileged" , func (ctx context.Context ) {
54
+ if ! supportsUserNS (ctx , f ) {
55
+ e2eskipper .Skipf ("runtime does not support user namespaces" )
56
+ }
53
57
pmt := v1 .UnmaskedProcMount
54
58
podClient := e2epod .NewPodClient (f )
55
59
_ , err := podClient .PodInterface .Create (ctx , & v1.Pod {
@@ -79,6 +83,9 @@ var _ = SIGDescribe("ProcMount [LinuxOnly]", nodefeature.ProcMountType, nodefeat
79
83
f .NamespacePodSecurityLevel = admissionapi .LevelPrivileged
80
84
81
85
f .It ("will unmask proc mounts if requested" , func (ctx context.Context ) {
86
+ if ! supportsUserNS (ctx , f ) {
87
+ e2eskipper .Skipf ("runtime does not support user namespaces" )
88
+ }
82
89
testProcMount (ctx , f , v1 .UnmaskedProcMount , gomega .Equal (1 ), gomega .BeZero ())
83
90
})
84
91
})
@@ -113,3 +120,17 @@ func testProcMount(ctx context.Context, f *framework.Framework, pmt v1.ProcMount
113
120
gomega .Expect (len (lines )).To (expectedLines )
114
121
gomega .Expect (strings .Count (output , "(ro" )).To (expectedReadOnly )
115
122
}
123
+
124
+ func supportsUserNS (ctx context.Context , f * framework.Framework ) bool {
125
+ nodeList , err := f .ClientSet .CoreV1 ().Nodes ().List (ctx , metav1.ListOptions {})
126
+ framework .ExpectNoError (err )
127
+ // Assuming that there is only one node, because this is a node e2e test.
128
+ gomega .Expect (nodeList .Items ).To (gomega .HaveLen (1 ))
129
+ node := nodeList .Items [0 ]
130
+ for _ , rc := range node .Status .RuntimeHandlers {
131
+ if rc .Name == "" && rc .Features != nil && * rc .Features .UserNamespaces {
132
+ return true
133
+ }
134
+ }
135
+ return false
136
+ }
0 commit comments