Skip to content

Commit 20b12ad

Browse files
authored
Merge pull request kubernetes#129685 from swatisehgal/cpu-mgr-logs-improvements
CPU Manager logging improvements
2 parents e094e5e + 7997c93 commit 20b12ad

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

pkg/kubelet/cm/cpumanager/cpu_manager.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,8 @@ func (m *manager) Start(activePods ActivePodsFunc, sourcesReady config.SourcesRe
239239
return err
240240
}
241241

242+
klog.V(4).InfoS("CPU manager started", "policy", m.policy.Name())
243+
242244
m.allocatableCPUs = m.policy.GetAllocatableCPUs(m.state)
243245

244246
if m.policy.Name() == string(PolicyNone) {
@@ -465,7 +467,7 @@ func (m *manager) reconcileState() (success []reconciledContainer, failure []rec
465467
cset := m.state.GetCPUSetOrDefault(string(pod.UID), container.Name)
466468
if cset.IsEmpty() {
467469
// NOTE: This should not happen outside of tests.
468-
klog.V(2).InfoS("ReconcileState: skipping container; assigned cpuset is empty", "pod", klog.KObj(pod), "containerName", container.Name)
470+
klog.V(2).InfoS("ReconcileState: skipping container; empty cpuset assigned", "pod", klog.KObj(pod), "containerName", container.Name)
469471
failure = append(failure, reconciledContainer{pod.Name, container.Name, containerID})
470472
continue
471473
}

pkg/kubelet/cm/cpumanager/policy_static.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ func (p *staticPolicy) Allocate(s state.State, pod *v1.Pod, container *v1.Contai
388388
p.updateCPUsToReuse(pod, container, cpuset)
389389
p.updateMetricsOnAllocate(cpuset)
390390

391+
klog.V(4).InfoS("Allocated exclusive CPUs", "pod", klog.KObj(pod), "containerName", container.Name, "cpuset", cpuset)
391392
return nil
392393
}
393394

@@ -455,7 +456,9 @@ func (p *staticPolicy) allocateCPUs(s state.State, numCPUs int, numaAffinity bit
455456
}
456457

457458
func (p *staticPolicy) guaranteedCPUs(pod *v1.Pod, container *v1.Container) int {
458-
if v1qos.GetPodQOS(pod) != v1.PodQOSGuaranteed {
459+
qos := v1qos.GetPodQOS(pod)
460+
if qos != v1.PodQOSGuaranteed {
461+
klog.V(5).InfoS("Exclusive CPU allocation skipped, pod QoS is not guaranteed", "pod", klog.KObj(pod), "containerName", container.Name, "qos", qos)
459462
return 0
460463
}
461464
cpuQuantity := container.Resources.Requests[v1.ResourceCPU]
@@ -474,7 +477,9 @@ func (p *staticPolicy) guaranteedCPUs(pod *v1.Pod, container *v1.Container) int
474477
cpuQuantity = cs.AllocatedResources[v1.ResourceCPU]
475478
}
476479
}
477-
if cpuQuantity.Value()*1000 != cpuQuantity.MilliValue() {
480+
cpuValue := cpuQuantity.Value()
481+
if cpuValue*1000 != cpuQuantity.MilliValue() {
482+
klog.V(5).InfoS("Exclusive CPU allocation skipped, pod requested non-integral CPUs", "pod", klog.KObj(pod), "containerName", container.Name, "cpu", cpuValue)
478483
return 0
479484
}
480485
// Safe downcast to do for all systems with < 2.1 billion CPUs.

pkg/kubelet/cm/cpumanager/state/state_checkpoint.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ func (sc *stateCheckpoint) SetCPUSet(podUID string, containerName string, cset c
201201
sc.cache.SetCPUSet(podUID, containerName, cset)
202202
err := sc.storeState()
203203
if err != nil {
204-
klog.InfoS("Store state to checkpoint error", "err", err)
204+
klog.ErrorS(err, "Failed to store state to checkpoint", "podUID", podUID, "containerName", containerName)
205205
}
206206
}
207207

@@ -212,7 +212,7 @@ func (sc *stateCheckpoint) SetDefaultCPUSet(cset cpuset.CPUSet) {
212212
sc.cache.SetDefaultCPUSet(cset)
213213
err := sc.storeState()
214214
if err != nil {
215-
klog.InfoS("Store state to checkpoint error", "err", err)
215+
klog.ErrorS(err, "Failed to store state to checkpoint")
216216
}
217217
}
218218

@@ -223,7 +223,7 @@ func (sc *stateCheckpoint) SetCPUAssignments(a ContainerCPUAssignments) {
223223
sc.cache.SetCPUAssignments(a)
224224
err := sc.storeState()
225225
if err != nil {
226-
klog.InfoS("Store state to checkpoint error", "err", err)
226+
klog.ErrorS(err, "Failed to store state to checkpoint")
227227
}
228228
}
229229

@@ -234,7 +234,7 @@ func (sc *stateCheckpoint) Delete(podUID string, containerName string) {
234234
sc.cache.Delete(podUID, containerName)
235235
err := sc.storeState()
236236
if err != nil {
237-
klog.InfoS("Store state to checkpoint error", "err", err)
237+
klog.ErrorS(err, "Failed to store state to checkpoint", "podUID", podUID, "containerName", containerName)
238238
}
239239
}
240240

@@ -245,6 +245,6 @@ func (sc *stateCheckpoint) ClearState() {
245245
sc.cache.ClearState()
246246
err := sc.storeState()
247247
if err != nil {
248-
klog.InfoS("Store state to checkpoint error", "err", err)
248+
klog.ErrorS(err, "Failed to store state to checkpoint")
249249
}
250250
}

0 commit comments

Comments
 (0)