mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 07:47:56 +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"
|
admissionapi "k8s.io/pod-security-admission/api"
|
||||||
|
|
||||||
"k8s.io/kubernetes/test/e2e/framework"
|
"k8s.io/kubernetes/test/e2e/framework"
|
||||||
e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper"
|
|
||||||
"k8s.io/kubernetes/test/e2e/nodefeature"
|
"k8s.io/kubernetes/test/e2e/nodefeature"
|
||||||
e2enodekubelet "k8s.io/kubernetes/test/e2e_node/kubeletconfig"
|
e2enodekubelet "k8s.io/kubernetes/test/e2e_node/kubeletconfig"
|
||||||
|
|
||||||
@ -45,7 +44,7 @@ import (
|
|||||||
"github.com/onsi/gomega"
|
"github.com/onsi/gomega"
|
||||||
)
|
)
|
||||||
|
|
||||||
func setDesiredConfiguration(initialConfig *kubeletconfig.KubeletConfiguration) {
|
func setDesiredConfiguration(initialConfig *kubeletconfig.KubeletConfiguration, cgroupManager cm.CgroupManager) {
|
||||||
initialConfig.EnforceNodeAllocatable = []string{"pods", kubeReservedCgroup, systemReservedCgroup}
|
initialConfig.EnforceNodeAllocatable = []string{"pods", kubeReservedCgroup, systemReservedCgroup}
|
||||||
initialConfig.SystemReserved = map[string]string{
|
initialConfig.SystemReserved = map[string]string{
|
||||||
string(v1.ResourceCPU): "100m",
|
string(v1.ResourceCPU): "100m",
|
||||||
@ -62,6 +61,11 @@ func setDesiredConfiguration(initialConfig *kubeletconfig.KubeletConfiguration)
|
|||||||
initialConfig.CgroupsPerQOS = true
|
initialConfig.CgroupsPerQOS = true
|
||||||
initialConfig.KubeReservedCgroup = kubeReservedCgroup
|
initialConfig.KubeReservedCgroup = kubeReservedCgroup
|
||||||
initialConfig.SystemReservedCgroup = systemReservedCgroup
|
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() {
|
var _ = SIGDescribe("Node Container Manager", framework.WithSerial(), func() {
|
||||||
@ -172,15 +176,6 @@ func runTest(ctx context.Context, f *framework.Framework) error {
|
|||||||
return err
|
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.
|
// Create a cgroup manager object for manipulating cgroups.
|
||||||
cgroupManager := cm.NewCgroupManager(subsystems, oldCfg.CgroupDriver)
|
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 {
|
if err := createTemporaryCgroupsForReservation(cgroupManager); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
newCfg := oldCfg.DeepCopy()
|
newCfg := oldCfg.DeepCopy()
|
||||||
// Change existing kubelet configuration
|
// Change existing kubelet configuration
|
||||||
setDesiredConfiguration(newCfg)
|
setDesiredConfiguration(newCfg, cgroupManager)
|
||||||
// Set the new kubelet configuration.
|
// Set the new kubelet configuration.
|
||||||
// Update the Kubelet configuration.
|
// Update the Kubelet configuration.
|
||||||
ginkgo.By("Stopping the kubelet")
|
ginkgo.By("Stopping the kubelet")
|
||||||
@ -311,7 +307,7 @@ func runTest(ctx context.Context, f *framework.Framework) error {
|
|||||||
|
|
||||||
cgroupPath := ""
|
cgroupPath := ""
|
||||||
if currentConfig.CgroupDriver == "systemd" {
|
if currentConfig.CgroupDriver == "systemd" {
|
||||||
cgroupPath = cm.ParseSystemdToCgroupName(kubeReservedCgroup).ToSystemd()
|
cgroupPath = cm.NewCgroupName(cm.RootCgroupName, kubeReservedCgroup).ToSystemd()
|
||||||
} else {
|
} else {
|
||||||
cgroupPath = cgroupManager.Name(cm.NewCgroupName(cm.RootCgroupName, kubeReservedCgroup))
|
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" {
|
if currentConfig.CgroupDriver == "systemd" {
|
||||||
cgroupPath = cm.ParseSystemdToCgroupName(systemReservedCgroup).ToSystemd()
|
cgroupPath = cm.NewCgroupName(cm.RootCgroupName, systemReservedCgroup).ToSystemd()
|
||||||
} else {
|
} else {
|
||||||
cgroupPath = cgroupManager.Name(cm.NewCgroupName(cm.RootCgroupName, systemReservedCgroup))
|
cgroupPath = cgroupManager.Name(cm.NewCgroupName(cm.RootCgroupName, systemReservedCgroup))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user