Skip to content

Commit 34fd61a

Browse files
committed
node: memory-mgr: Add metadata to logs
Ensure that whereever possible, we provide sufficient metadata inclusing pod name and UID to allow filtering by pod name or its UID. Signed-off-by: Swati Sehgal <[email protected]>
1 parent 1714fbf commit 34fd61a

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

pkg/kubelet/cm/memorymanager/memory_manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ func (m *manager) Allocate(pod *v1.Pod, container *v1.Container) error {
266266

267267
// Call down into the policy to assign this container memory if required.
268268
if err := m.policy.Allocate(m.state, pod, container); err != nil {
269-
klog.ErrorS(err, "Allocate error")
269+
klog.ErrorS(err, "Allocate error", "pod", klog.KObj(pod), "containerName", container.Name)
270270
return err
271271
}
272272
return nil

pkg/kubelet/cm/memorymanager/policy_static.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,24 +304,24 @@ func regenerateHints(pod *v1.Pod, ctn *v1.Container, ctnBlocks []state.Block, re
304304
}
305305

306306
if len(ctnBlocks) != len(reqRsrc) {
307-
klog.InfoS("The number of requested resources by the container differs from the number of memory blocks", "containerName", ctn.Name)
307+
klog.InfoS("The number of requested resources by the container differs from the number of memory blocks", "pod", klog.KObj(pod), "containerName", ctn.Name)
308308
return nil
309309
}
310310

311311
for _, b := range ctnBlocks {
312312
if _, ok := reqRsrc[b.Type]; !ok {
313-
klog.InfoS("Container requested resources do not have resource of this type", "containerName", ctn.Name, "type", b.Type)
313+
klog.InfoS("Container requested resources do not have resource of this type", "pod", klog.KObj(pod), "containerName", ctn.Name, "type", b.Type)
314314
return nil
315315
}
316316

317317
if b.Size != reqRsrc[b.Type] {
318-
klog.InfoS("Memory already allocated with different numbers than requested", "podUID", pod.UID, "type", b.Type, "containerName", ctn.Name, "requestedResource", reqRsrc[b.Type], "allocatedSize", b.Size)
318+
klog.InfoS("Memory already allocated with different numbers than requested", "pod", klog.KObj(pod), "containerName", ctn.Name, "type", b.Type, "requestedResource", reqRsrc[b.Type], "allocatedSize", b.Size)
319319
return nil
320320
}
321321

322322
containerNUMAAffinity, err := bitmask.NewBitMask(b.NUMAAffinity...)
323323
if err != nil {
324-
klog.ErrorS(err, "Failed to generate NUMA bitmask")
324+
klog.ErrorS(err, "Failed to generate NUMA bitmask", "pod", klog.KObj(pod), "containerName", ctn.Name, "type", b.Type)
325325
return nil
326326
}
327327

0 commit comments

Comments
 (0)