Skip to content

Commit dd2dcc0

Browse files
committed
e2e_node: enable and fix cgroups test for systemd
Signed-off-by: Peter Hunt <[email protected]>
1 parent 60c4c2b commit dd2dcc0

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

test/e2e_node/node_container_manager_test.go

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,14 @@ import (
3737
admissionapi "k8s.io/pod-security-admission/api"
3838

3939
"k8s.io/kubernetes/test/e2e/framework"
40-
e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper"
4140
"k8s.io/kubernetes/test/e2e/nodefeature"
4241
e2enodekubelet "k8s.io/kubernetes/test/e2e_node/kubeletconfig"
4342

4443
"github.com/onsi/ginkgo/v2"
4544
"github.com/onsi/gomega"
4645
)
4746

48-
func setDesiredConfiguration(initialConfig *kubeletconfig.KubeletConfiguration) {
47+
func setDesiredConfiguration(initialConfig *kubeletconfig.KubeletConfiguration, cgroupManager cm.CgroupManager) {
4948
initialConfig.EnforceNodeAllocatable = []string{"pods", kubeReservedCgroup, systemReservedCgroup}
5049
initialConfig.SystemReserved = map[string]string{
5150
string(v1.ResourceCPU): "100m",
@@ -62,6 +61,11 @@ func setDesiredConfiguration(initialConfig *kubeletconfig.KubeletConfiguration)
6261
initialConfig.CgroupsPerQOS = true
6362
initialConfig.KubeReservedCgroup = kubeReservedCgroup
6463
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+
}
6569
}
6670

6771
var _ = SIGDescribe("Node Container Manager", framework.WithSerial(), func() {
@@ -172,15 +176,6 @@ func runTest(ctx context.Context, f *framework.Framework) error {
172176
return err
173177
}
174178

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-
184179
// Create a cgroup manager object for manipulating cgroups.
185180
cgroupManager := cm.NewCgroupManager(subsystems, oldCfg.CgroupDriver)
186181

@@ -210,9 +205,10 @@ func runTest(ctx context.Context, f *framework.Framework) error {
210205
if err := createTemporaryCgroupsForReservation(cgroupManager); err != nil {
211206
return err
212207
}
208+
213209
newCfg := oldCfg.DeepCopy()
214210
// Change existing kubelet configuration
215-
setDesiredConfiguration(newCfg)
211+
setDesiredConfiguration(newCfg, cgroupManager)
216212
// Set the new kubelet configuration.
217213
// Update the Kubelet configuration.
218214
ginkgo.By("Stopping the kubelet")
@@ -311,7 +307,7 @@ func runTest(ctx context.Context, f *framework.Framework) error {
311307

312308
cgroupPath := ""
313309
if currentConfig.CgroupDriver == "systemd" {
314-
cgroupPath = cm.ParseSystemdToCgroupName(kubeReservedCgroup).ToSystemd()
310+
cgroupPath = cm.NewCgroupName(cm.RootCgroupName, kubeReservedCgroup).ToSystemd()
315311
} else {
316312
cgroupPath = cgroupManager.Name(cm.NewCgroupName(cm.RootCgroupName, kubeReservedCgroup))
317313
}
@@ -339,7 +335,7 @@ func runTest(ctx context.Context, f *framework.Framework) error {
339335
}
340336

341337
if currentConfig.CgroupDriver == "systemd" {
342-
cgroupPath = cm.ParseSystemdToCgroupName(systemReservedCgroup).ToSystemd()
338+
cgroupPath = cm.NewCgroupName(cm.RootCgroupName, systemReservedCgroup).ToSystemd()
343339
} else {
344340
cgroupPath = cgroupManager.Name(cm.NewCgroupName(cm.RootCgroupName, systemReservedCgroup))
345341
}

0 commit comments

Comments
 (0)