mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 15:05:27 +00:00
e2e_node: enable and fix cgroups test for systemd
Signed-off-by: Peter Hunt <pehunt@redhat.com>
This commit is contained in:
parent
60c4c2b252
commit
dd2dcc0b0a
@ -37,7 +37,6 @@ import (
|
||||
admissionapi "k8s.io/pod-security-admission/api"
|
||||
|
||||
"k8s.io/kubernetes/test/e2e/framework"
|
||||
e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper"
|
||||
"k8s.io/kubernetes/test/e2e/nodefeature"
|
||||
e2enodekubelet "k8s.io/kubernetes/test/e2e_node/kubeletconfig"
|
||||
|
||||
@ -45,7 +44,7 @@ import (
|
||||
"github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
func setDesiredConfiguration(initialConfig *kubeletconfig.KubeletConfiguration) {
|
||||
func setDesiredConfiguration(initialConfig *kubeletconfig.KubeletConfiguration, cgroupManager cm.CgroupManager) {
|
||||
initialConfig.EnforceNodeAllocatable = []string{"pods", kubeReservedCgroup, systemReservedCgroup}
|
||||
initialConfig.SystemReserved = map[string]string{
|
||||
string(v1.ResourceCPU): "100m",
|
||||
@ -62,6 +61,11 @@ func setDesiredConfiguration(initialConfig *kubeletconfig.KubeletConfiguration)
|
||||
initialConfig.CgroupsPerQOS = true
|
||||
initialConfig.KubeReservedCgroup = kubeReservedCgroup
|
||||
initialConfig.SystemReservedCgroup = systemReservedCgroup
|
||||
|
||||
if initialConfig.CgroupDriver == "systemd" {
|
||||
initialConfig.KubeReservedCgroup = cm.NewCgroupName(cm.RootCgroupName, kubeReservedCgroup).ToSystemd()
|
||||
initialConfig.SystemReservedCgroup = cm.NewCgroupName(cm.RootCgroupName, systemReservedCgroup).ToSystemd()
|
||||
}
|
||||
}
|
||||
|
||||
var _ = SIGDescribe("Node Container Manager", framework.WithSerial(), func() {
|
||||
@ -172,15 +176,6 @@ func runTest(ctx context.Context, f *framework.Framework) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Test needs to be updated to make it run properly on systemd.
|
||||
// In its current state it will result in kubelet error since
|
||||
// kubeReservedCgroup and systemReservedCgroup are not configured
|
||||
// correctly for systemd.
|
||||
// See: https://github.com/kubernetes/kubernetes/issues/102394
|
||||
if oldCfg.CgroupDriver == "systemd" {
|
||||
e2eskipper.Skipf("unable to run test when using systemd as cgroup driver")
|
||||
}
|
||||
|
||||
// Create a cgroup manager object for manipulating cgroups.
|
||||
cgroupManager := cm.NewCgroupManager(subsystems, oldCfg.CgroupDriver)
|
||||
|
||||
@ -210,9 +205,10 @@ func runTest(ctx context.Context, f *framework.Framework) error {
|
||||
if err := createTemporaryCgroupsForReservation(cgroupManager); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
newCfg := oldCfg.DeepCopy()
|
||||
// Change existing kubelet configuration
|
||||
setDesiredConfiguration(newCfg)
|
||||
setDesiredConfiguration(newCfg, cgroupManager)
|
||||
// Set the new kubelet configuration.
|
||||
// Update the Kubelet configuration.
|
||||
ginkgo.By("Stopping the kubelet")
|
||||
@ -311,7 +307,7 @@ func runTest(ctx context.Context, f *framework.Framework) error {
|
||||
|
||||
cgroupPath := ""
|
||||
if currentConfig.CgroupDriver == "systemd" {
|
||||
cgroupPath = cm.ParseSystemdToCgroupName(kubeReservedCgroup).ToSystemd()
|
||||
cgroupPath = cm.NewCgroupName(cm.RootCgroupName, kubeReservedCgroup).ToSystemd()
|
||||
} else {
|
||||
cgroupPath = cgroupManager.Name(cm.NewCgroupName(cm.RootCgroupName, kubeReservedCgroup))
|
||||
}
|
||||
@ -339,7 +335,7 @@ func runTest(ctx context.Context, f *framework.Framework) error {
|
||||
}
|
||||
|
||||
if currentConfig.CgroupDriver == "systemd" {
|
||||
cgroupPath = cm.ParseSystemdToCgroupName(systemReservedCgroup).ToSystemd()
|
||||
cgroupPath = cm.NewCgroupName(cm.RootCgroupName, systemReservedCgroup).ToSystemd()
|
||||
} else {
|
||||
cgroupPath = cgroupManager.Name(cm.NewCgroupName(cm.RootCgroupName, systemReservedCgroup))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user