@@ -37,15 +37,14 @@ import (
37
37
admissionapi "k8s.io/pod-security-admission/api"
38
38
39
39
"k8s.io/kubernetes/test/e2e/framework"
40
- e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper"
41
40
"k8s.io/kubernetes/test/e2e/nodefeature"
42
41
e2enodekubelet "k8s.io/kubernetes/test/e2e_node/kubeletconfig"
43
42
44
43
"github.com/onsi/ginkgo/v2"
45
44
"github.com/onsi/gomega"
46
45
)
47
46
48
- func setDesiredConfiguration (initialConfig * kubeletconfig.KubeletConfiguration ) {
47
+ func setDesiredConfiguration (initialConfig * kubeletconfig.KubeletConfiguration , cgroupManager cm. CgroupManager ) {
49
48
initialConfig .EnforceNodeAllocatable = []string {"pods" , kubeReservedCgroup , systemReservedCgroup }
50
49
initialConfig .SystemReserved = map [string ]string {
51
50
string (v1 .ResourceCPU ): "100m" ,
@@ -62,6 +61,11 @@ func setDesiredConfiguration(initialConfig *kubeletconfig.KubeletConfiguration)
62
61
initialConfig .CgroupsPerQOS = true
63
62
initialConfig .KubeReservedCgroup = kubeReservedCgroup
64
63
initialConfig .SystemReservedCgroup = systemReservedCgroup
64
+
65
+ if initialConfig .CgroupDriver == "systemd" {
66
+ initialConfig .KubeReservedCgroup = cm .NewCgroupName (cm .RootCgroupName , kubeReservedCgroup ).ToSystemd ()
67
+ initialConfig .SystemReservedCgroup = cm .NewCgroupName (cm .RootCgroupName , systemReservedCgroup ).ToSystemd ()
68
+ }
65
69
}
66
70
67
71
var _ = SIGDescribe ("Node Container Manager" , framework .WithSerial (), func () {
@@ -116,8 +120,9 @@ func getAllocatableLimits(cpu, memory, pids string, capacity v1.ResourceList) (*
116
120
}
117
121
118
122
const (
119
- kubeReservedCgroup = "kube-reserved"
120
- systemReservedCgroup = "system-reserved"
123
+ kubeReservedCgroup = "kube-reserved"
124
+ systemReservedCgroup = "system-reserved"
125
+ nodeAllocatableCgroup = "kubepods"
121
126
)
122
127
123
128
func createIfNotExists (cm cm.CgroupManager , cgroupConfig * cm.CgroupConfig ) error {
@@ -172,15 +177,6 @@ func runTest(ctx context.Context, f *framework.Framework) error {
172
177
return err
173
178
}
174
179
175
- // Test needs to be updated to make it run properly on systemd.
176
- // In its current state it will result in kubelet error since
177
- // kubeReservedCgroup and systemReservedCgroup are not configured
178
- // correctly for systemd.
179
- // See: https://github.com/kubernetes/kubernetes/issues/102394
180
- if oldCfg .CgroupDriver == "systemd" {
181
- e2eskipper .Skipf ("unable to run test when using systemd as cgroup driver" )
182
- }
183
-
184
180
// Create a cgroup manager object for manipulating cgroups.
185
181
cgroupManager := cm .NewCgroupManager (subsystems , oldCfg .CgroupDriver )
186
182
@@ -210,9 +206,10 @@ func runTest(ctx context.Context, f *framework.Framework) error {
210
206
if err := createTemporaryCgroupsForReservation (cgroupManager ); err != nil {
211
207
return err
212
208
}
209
+
213
210
newCfg := oldCfg .DeepCopy ()
214
211
// Change existing kubelet configuration
215
- setDesiredConfiguration (newCfg )
212
+ setDesiredConfiguration (newCfg , cgroupManager )
216
213
// Set the new kubelet configuration.
217
214
// Update the Kubelet configuration.
218
215
ginkgo .By ("Stopping the kubelet" )
@@ -223,6 +220,18 @@ func runTest(ctx context.Context, f *framework.Framework) error {
223
220
return kubeletHealthCheck (kubeletHealthCheckURL )
224
221
}, time .Minute , time .Second ).Should (gomega .BeFalse ())
225
222
223
+ expectedNAPodCgroup := cm .NewCgroupName (cm .RootCgroupName , nodeAllocatableCgroup )
224
+
225
+ // Cleanup from the previous kubelet, to verify the new one creates it correctly
226
+ if err := cgroupManager .Destroy (& cm.CgroupConfig {
227
+ Name : cm .NewCgroupName (expectedNAPodCgroup ),
228
+ }); err != nil {
229
+ return err
230
+ }
231
+ if cgroupManager .Exists (expectedNAPodCgroup ) {
232
+ return fmt .Errorf ("Expected Node Allocatable Cgroup %q not to exist" , expectedNAPodCgroup )
233
+ }
234
+
226
235
framework .ExpectNoError (e2enodekubelet .WriteKubeletConfigFile (newCfg ))
227
236
228
237
ginkgo .By ("Starting the kubelet" )
@@ -239,10 +248,8 @@ func runTest(ctx context.Context, f *framework.Framework) error {
239
248
// Set new config and current config.
240
249
currentConfig := newCfg
241
250
242
- expectedNAPodCgroup := cm .ParseCgroupfsToCgroupName (currentConfig .CgroupRoot )
243
- expectedNAPodCgroup = cm .NewCgroupName (expectedNAPodCgroup , "kubepods" )
244
251
if ! cgroupManager .Exists (expectedNAPodCgroup ) {
245
- return fmt .Errorf ("Expected Node Allocatable Cgroup %q does not exist" , expectedNAPodCgroup )
252
+ return fmt .Errorf ("Expected Node Allocatable Cgroup %q to exist" , expectedNAPodCgroup )
246
253
}
247
254
248
255
memoryLimitFile := "memory.limit_in_bytes"
@@ -260,9 +267,9 @@ func runTest(ctx context.Context, f *framework.Framework) error {
260
267
if len (nodeList .Items ) != 1 {
261
268
return fmt .Errorf ("Unexpected number of node objects for node e2e. Expects only one node: %+v" , nodeList )
262
269
}
263
- cgroupName := "kubepods"
270
+ cgroupName := nodeAllocatableCgroup
264
271
if currentConfig .CgroupDriver == "systemd" {
265
- cgroupName = "kubepods .slice"
272
+ cgroupName = nodeAllocatableCgroup + " .slice"
266
273
}
267
274
268
275
node := nodeList .Items [0 ]
@@ -311,7 +318,7 @@ func runTest(ctx context.Context, f *framework.Framework) error {
311
318
312
319
cgroupPath := ""
313
320
if currentConfig .CgroupDriver == "systemd" {
314
- cgroupPath = cm .ParseSystemdToCgroupName ( kubeReservedCgroup ).ToSystemd ()
321
+ cgroupPath = cm .NewCgroupName ( cm . RootCgroupName , kubeReservedCgroup ).ToSystemd ()
315
322
} else {
316
323
cgroupPath = cgroupManager .Name (cm .NewCgroupName (cm .RootCgroupName , kubeReservedCgroup ))
317
324
}
@@ -339,7 +346,7 @@ func runTest(ctx context.Context, f *framework.Framework) error {
339
346
}
340
347
341
348
if currentConfig .CgroupDriver == "systemd" {
342
- cgroupPath = cm .ParseSystemdToCgroupName ( systemReservedCgroup ).ToSystemd ()
349
+ cgroupPath = cm .NewCgroupName ( cm . RootCgroupName , systemReservedCgroup ).ToSystemd ()
343
350
} else {
344
351
cgroupPath = cgroupManager .Name (cm .NewCgroupName (cm .RootCgroupName , systemReservedCgroup ))
345
352
}
0 commit comments