Skip to content

Commit 754017b

Browse files
author
Kubernetes Submit Queue
authored
Merge pull request kubernetes#56105 from balajismaniam/enable-cpuman-only-when-not-skipped
Automatic merge from submit-queue (batch tested with PRs 55340, 55329, 56168, 56170, 56105). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Enable cpu manager only if the node e2e test is not skipped. **What this PR does / why we need it**: This PR enables cpu manager in Kubelet only if the node e2e tests are not skipped. This change fixes the failures seen in https://k8s-testgrid.appspot.com/sig-node-kubelet#kubelet-serial-gce-e2e. Fixes kubernetes#56144
2 parents 943d372 + 16e0f12 commit 754017b

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

test/e2e_node/cpu_manager_test.go

+13-8
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@ func enableCPUManagerInKubelet(f *framework.Framework) (oldCfg *kubeletconfig.Ku
156156
// The Kubelet panics if either kube-reserved or system-reserved is not set
157157
// when CPU Manager is enabled. Set cpu in kube-reserved > 0 so that
158158
// kubelet doesn't panic.
159+
if newCfg.KubeReserved == nil {
160+
newCfg.KubeReserved = map[string]string{}
161+
}
162+
159163
if _, ok := newCfg.KubeReserved["cpu"]; !ok {
160164
newCfg.KubeReserved["cpu"] = "200m"
161165
}
@@ -183,15 +187,16 @@ func runCPUManagerTests(f *framework.Framework) {
183187
var pod, pod1, pod2 *v1.Pod
184188

185189
It("should assign CPUs as expected based on the Pod spec", func() {
186-
oldCfg = enableCPUManagerInKubelet(f)
187-
188190
cpuCap, cpuAlloc, cpuRes = getLocalNodeCPUDetails(f)
189191

190-
// Skip CPU Manager tests if the number of allocatable CPUs < 1.
191-
if cpuAlloc < 1 {
192-
framework.Skipf("Skipping CPU Manager tests since the number of allocatable CPUs < 1")
192+
// Skip CPU Manager tests altogether if the CPU capacity < 2.
193+
if cpuCap < 2 {
194+
framework.Skipf("Skipping CPU Manager tests since the CPU capacity < 2")
193195
}
194196

197+
// Enable CPU Manager in the kubelet.
198+
oldCfg = enableCPUManagerInKubelet(f)
199+
195200
By("running a non-Gu pod")
196201
ctnAttrs = []ctnAttribute{
197202
{
@@ -286,9 +291,9 @@ func runCPUManagerTests(f *framework.Framework) {
286291
waitForContainerRemoval(fmt.Sprintf("%s_%s", pod1.Spec.Containers[0].Name, pod1.Name))
287292
waitForContainerRemoval(fmt.Sprintf("%s_%s", pod2.Spec.Containers[0].Name, pod2.Name))
288293

289-
// Skip rest of the tests if the number of allocatable CPUs < 2.
290-
if cpuAlloc < 2 {
291-
framework.Skipf("Skipping rest of the CPU Manager tests since the number of allocatable CPUs < 2")
294+
// Skip rest of the tests if CPU capacity < 3.
295+
if cpuCap < 3 {
296+
framework.Skipf("Skipping rest of the CPU Manager tests since CPU capacity < 3")
292297
}
293298

294299
By("running a Gu pod requesting multiple CPUs")

0 commit comments

Comments
 (0)