Skip to content

Commit 11e8169

Browse files
authored
Merge pull request kubernetes#120569 from ffromani/cpumanager-extra-logs
enhance the cpumanager logs
2 parents d14b0b0 + 0a9b177 commit 11e8169

File tree

2 files changed

+23
-19
lines changed

2 files changed

+23
-19
lines changed

pkg/kubelet/cm/cpumanager/cpu_manager.go

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -380,24 +380,28 @@ func (m *manager) removeStaleState() {
380380
assignments := m.state.GetCPUAssignments()
381381
for podUID := range assignments {
382382
for containerName := range assignments[podUID] {
383-
if _, ok := activeContainers[podUID][containerName]; !ok {
384-
klog.ErrorS(nil, "RemoveStaleState: removing container", "podUID", podUID, "containerName", containerName)
385-
err := m.policyRemoveContainerByRef(podUID, containerName)
386-
if err != nil {
387-
klog.ErrorS(err, "RemoveStaleState: failed to remove container", "podUID", podUID, "containerName", containerName)
388-
}
383+
if _, ok := activeContainers[podUID][containerName]; ok {
384+
klog.V(5).InfoS("RemoveStaleState: container still active", "podUID", podUID, "containerName", containerName)
385+
continue
389386
}
390-
}
391-
}
392-
393-
m.containerMap.Visit(func(podUID, containerName, containerID string) {
394-
if _, ok := activeContainers[podUID][containerName]; !ok {
395-
klog.ErrorS(nil, "RemoveStaleState: removing container", "podUID", podUID, "containerName", containerName)
387+
klog.V(2).InfoS("RemoveStaleState: removing container", "podUID", podUID, "containerName", containerName)
396388
err := m.policyRemoveContainerByRef(podUID, containerName)
397389
if err != nil {
398390
klog.ErrorS(err, "RemoveStaleState: failed to remove container", "podUID", podUID, "containerName", containerName)
399391
}
400392
}
393+
}
394+
395+
m.containerMap.Visit(func(podUID, containerName, containerID string) {
396+
if _, ok := activeContainers[podUID][containerName]; ok {
397+
klog.V(5).InfoS("RemoveStaleState: containerMap: container still active", "podUID", podUID, "containerName", containerName)
398+
return
399+
}
400+
klog.V(2).InfoS("RemoveStaleState: containerMap: removing container", "podUID", podUID, "containerName", containerName)
401+
err := m.policyRemoveContainerByRef(podUID, containerName)
402+
if err != nil {
403+
klog.ErrorS(err, "RemoveStaleState: containerMap: failed to remove container", "podUID", podUID, "containerName", containerName)
404+
}
401405
})
402406
}
403407

@@ -410,7 +414,7 @@ func (m *manager) reconcileState() (success []reconciledContainer, failure []rec
410414
for _, pod := range m.activePods() {
411415
pstatus, ok := m.podStatusProvider.GetPodStatus(pod.UID)
412416
if !ok {
413-
klog.V(4).InfoS("ReconcileState: skipping pod; status not found", "pod", klog.KObj(pod))
417+
klog.V(5).InfoS("ReconcileState: skipping pod; status not found", "pod", klog.KObj(pod))
414418
failure = append(failure, reconciledContainer{pod.Name, "", ""})
415419
continue
416420
}
@@ -420,14 +424,14 @@ func (m *manager) reconcileState() (success []reconciledContainer, failure []rec
420424
for _, container := range allContainers {
421425
containerID, err := findContainerIDByName(&pstatus, container.Name)
422426
if err != nil {
423-
klog.V(4).InfoS("ReconcileState: skipping container; ID not found in pod status", "pod", klog.KObj(pod), "containerName", container.Name, "err", err)
427+
klog.V(5).InfoS("ReconcileState: skipping container; ID not found in pod status", "pod", klog.KObj(pod), "containerName", container.Name, "err", err)
424428
failure = append(failure, reconciledContainer{pod.Name, container.Name, ""})
425429
continue
426430
}
427431

428432
cstatus, err := findContainerStatusByName(&pstatus, container.Name)
429433
if err != nil {
430-
klog.V(4).InfoS("ReconcileState: skipping container; container status not found in pod status", "pod", klog.KObj(pod), "containerName", container.Name, "err", err)
434+
klog.V(5).InfoS("ReconcileState: skipping container; container status not found in pod status", "pod", klog.KObj(pod), "containerName", container.Name, "err", err)
431435
failure = append(failure, reconciledContainer{pod.Name, container.Name, ""})
432436
continue
433437
}
@@ -463,14 +467,14 @@ func (m *manager) reconcileState() (success []reconciledContainer, failure []rec
463467
cset := m.state.GetCPUSetOrDefault(string(pod.UID), container.Name)
464468
if cset.IsEmpty() {
465469
// NOTE: This should not happen outside of tests.
466-
klog.V(4).InfoS("ReconcileState: skipping container; assigned cpuset is empty", "pod", klog.KObj(pod), "containerName", container.Name)
470+
klog.V(2).InfoS("ReconcileState: skipping container; assigned cpuset is empty", "pod", klog.KObj(pod), "containerName", container.Name)
467471
failure = append(failure, reconciledContainer{pod.Name, container.Name, containerID})
468472
continue
469473
}
470474

471475
lcset := m.lastUpdateState.GetCPUSetOrDefault(string(pod.UID), container.Name)
472476
if !cset.Equals(lcset) {
473-
klog.V(4).InfoS("ReconcileState: updating container", "pod", klog.KObj(pod), "containerName", container.Name, "containerID", containerID, "cpuSet", cset)
477+
klog.V(5).InfoS("ReconcileState: updating container", "pod", klog.KObj(pod), "containerName", container.Name, "containerID", containerID, "cpuSet", cset)
474478
err = m.updateContainerCPUSet(ctx, containerID, cset)
475479
if err != nil {
476480
klog.ErrorS(err, "ReconcileState: failed to update container", "pod", klog.KObj(pod), "containerName", container.Name, "containerID", containerID, "cpuSet", cset)

pkg/kubelet/cm/cpumanager/policy_static.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ func (p *staticPolicy) GetTopologyHints(s state.State, pod *v1.Pod, container *v
515515
// kubelet restart, for example.
516516
if allocated, exists := s.GetCPUSet(string(pod.UID), container.Name); exists {
517517
if allocated.Size() != requested {
518-
klog.ErrorS(nil, "CPUs already allocated to container with different number than request", "pod", klog.KObj(pod), "containerName", container.Name, "requestedSize", requested, "allocatedSize", allocated.Size())
518+
klog.InfoS("CPUs already allocated to container with different number than request", "pod", klog.KObj(pod), "containerName", container.Name, "requestedSize", requested, "allocatedSize", allocated.Size())
519519
// An empty list of hints will be treated as a preference that cannot be satisfied.
520520
// In definition of hints this is equal to: TopologyHint[NUMANodeAffinity: nil, Preferred: false].
521521
// For all but the best-effort policy, the Topology Manager will throw a pod-admission error.
@@ -565,7 +565,7 @@ func (p *staticPolicy) GetPodTopologyHints(s state.State, pod *v1.Pod) map[strin
565565
// kubelet restart, for example.
566566
if allocated, exists := s.GetCPUSet(string(pod.UID), container.Name); exists {
567567
if allocated.Size() != requestedByContainer {
568-
klog.ErrorS(nil, "CPUs already allocated to container with different number than request", "pod", klog.KObj(pod), "containerName", container.Name, "allocatedSize", requested, "requestedByContainer", requestedByContainer, "allocatedSize", allocated.Size())
568+
klog.InfoS("CPUs already allocated to container with different number than request", "pod", klog.KObj(pod), "containerName", container.Name, "allocatedSize", requested, "requestedByContainer", requestedByContainer, "allocatedSize", allocated.Size())
569569
// An empty list of hints will be treated as a preference that cannot be satisfied.
570570
// In definition of hints this is equal to: TopologyHint[NUMANodeAffinity: nil, Preferred: false].
571571
// For all but the best-effort policy, the Topology Manager will throw a pod-admission error.

0 commit comments

Comments
 (0)