Skip to content

Commit 584e224

Browse files
committed
node: device-mgr: Add metadata to logs
Ensure that if 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 c56426b commit 584e224

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

pkg/kubelet/cm/devicemanager/manager.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ func (m *ManagerImpl) allocateContainerResources(pod *v1.Pod, container *v1.Cont
836836
for k, v := range container.Resources.Limits {
837837
resource := string(k)
838838
needed := int(v.Value())
839-
klog.V(3).InfoS("Looking for needed resources", "needed", needed, "resourceName", resource)
839+
klog.V(3).InfoS("Looking for needed resources", "resourceName", resource, "pod", klog.KObj(pod), "containerName", container.Name, "needed", needed)
840840
if !m.isDevicePluginResource(resource) {
841841
continue
842842
}
@@ -882,7 +882,7 @@ func (m *ManagerImpl) allocateContainerResources(pod *v1.Pod, container *v1.Cont
882882
devs := allocDevices.UnsortedList()
883883
// TODO: refactor this part of code to just append a ContainerAllocationRequest
884884
// in a passed in AllocateRequest pointer, and issues a single Allocate call per pod.
885-
klog.V(3).InfoS("Making allocation request for device plugin", "devices", devs, "resourceName", resource)
885+
klog.V(3).InfoS("Making allocation request for device plugin", "devices", devs, "resourceName", resource, "pod", klog.KObj(pod), "containerName", container.Name)
886886
resp, err := eI.e.allocate(devs)
887887
metrics.DevicePluginAllocationDuration.WithLabelValues(resource).Observe(metrics.SinceInSeconds(startRPCTime))
888888
if err != nil {
@@ -952,7 +952,7 @@ func (m *ManagerImpl) GetDeviceRunContainerOptions(pod *v1.Pod, container *v1.Co
952952
}
953953

954954
if !m.checkPodActive(pod) {
955-
klog.InfoS("pod deleted from activePods, skip to reAllocate", "podUID", podUID)
955+
klog.InfoS("pod deleted from activePods, skip to reAllocate", "pod", klog.KObj(pod), "podUID", podUID, "containerName", container.Name)
956956
continue
957957
}
958958

@@ -984,7 +984,7 @@ func (m *ManagerImpl) callPreStartContainerIfNeeded(podUID, contName, resource s
984984

985985
if eI.opts == nil || !eI.opts.PreStartRequired {
986986
m.mutex.Unlock()
987-
klog.V(4).InfoS("Plugin options indicate to skip PreStartContainer for resource", "resourceName", resource)
987+
klog.V(4).InfoS("Plugin options indicate to skip PreStartContainer for resource", "podUID", podUID, "resourceName", resource, "containerName", contName)
988988
return nil
989989
}
990990

@@ -1014,12 +1014,12 @@ func (m *ManagerImpl) callGetPreferredAllocationIfAvailable(podUID, contName, re
10141014
}
10151015

10161016
if eI.opts == nil || !eI.opts.GetPreferredAllocationAvailable {
1017-
klog.V(4).InfoS("Plugin options indicate to skip GetPreferredAllocation for resource", "resourceName", resource)
1017+
klog.V(4).InfoS("Plugin options indicate to skip GetPreferredAllocation for resource", "resourceName", resource, "podUID", podUID, "containerName", contName)
10181018
return nil, nil
10191019
}
10201020

10211021
m.mutex.Unlock()
1022-
klog.V(4).InfoS("Issuing a GetPreferredAllocation call for container", "containerName", contName, "podUID", podUID)
1022+
klog.V(4).InfoS("Issuing a GetPreferredAllocation call for container", "resourceName", resource, "containerName", contName, "podUID", podUID)
10231023
resp, err := eI.e.getPreferredAllocation(available.UnsortedList(), mustInclude.UnsortedList(), size)
10241024
m.mutex.Lock()
10251025
if err != nil {

pkg/kubelet/cm/devicemanager/topology_hints.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func (m *ManagerImpl) GetTopologyHints(pod *v1.Pod, container *v1.Container) map
4343
for resource, requested := range accumulatedResourceRequests {
4444
// Only consider devices that actually contain topology information.
4545
if aligned := m.deviceHasTopologyAlignment(resource); !aligned {
46-
klog.InfoS("Resource does not have a topology preference", "resource", resource)
46+
klog.InfoS("Resource does not have a topology preference", "resource", resource, "pod", klog.KObj(pod), "containerName", container.Name, "request", requested)
4747
deviceHints[resource] = nil
4848
continue
4949
}
@@ -67,7 +67,7 @@ func (m *ManagerImpl) GetTopologyHints(pod *v1.Pod, container *v1.Container) map
6767
available := m.getAvailableDevices(resource)
6868
reusable := m.devicesToReuse[string(pod.UID)][resource]
6969
if available.Union(reusable).Len() < requested {
70-
klog.InfoS("Unable to generate topology hints: requested number of devices unavailable", "resource", resource, "request", requested, "available", available.Union(reusable).Len())
70+
klog.InfoS("Unable to generate topology hints: requested number of devices unavailable", "resource", resource, "pod", klog.KObj(pod), "containerName", container.Name, "request", requested, "available", available.Union(reusable).Len())
7171
deviceHints[resource] = []topologymanager.TopologyHint{}
7272
continue
7373
}
@@ -94,7 +94,7 @@ func (m *ManagerImpl) GetPodTopologyHints(pod *v1.Pod) map[string][]topologymana
9494
for resource, requested := range accumulatedResourceRequests {
9595
// Only consider devices that actually contain topology information.
9696
if aligned := m.deviceHasTopologyAlignment(resource); !aligned {
97-
klog.InfoS("Resource does not have a topology preference", "resource", resource)
97+
klog.InfoS("Resource does not have a topology preference", "resource", resource, "pod", klog.KObj(pod), "request", requested)
9898
deviceHints[resource] = nil
9999
continue
100100
}
@@ -109,15 +109,15 @@ func (m *ManagerImpl) GetPodTopologyHints(pod *v1.Pod) map[string][]topologymana
109109
deviceHints[resource] = []topologymanager.TopologyHint{}
110110
continue
111111
}
112-
klog.InfoS("Regenerating TopologyHints for resource already allocated to pod", "resource", resource, "pod", klog.KObj(pod))
112+
klog.InfoS("Regenerating TopologyHints for resource already allocated to pod", "resource", resource, "pod", klog.KObj(pod), "allocated", allocated.Len())
113113
deviceHints[resource] = m.generateDeviceTopologyHints(resource, allocated, sets.Set[string]{}, requested)
114114
continue
115115
}
116116

117117
// Get the list of available devices, for which TopologyHints should be generated.
118118
available := m.getAvailableDevices(resource)
119119
if available.Len() < requested {
120-
klog.InfoS("Unable to generate topology hints: requested number of devices unavailable", "resource", resource, "request", requested, "available", available.Len())
120+
klog.InfoS("Unable to generate topology hints: requested number of devices unavailable", "resource", resource, "pod", klog.KObj(pod), "request", requested, "available", available.Len())
121121
deviceHints[resource] = []topologymanager.TopologyHint{}
122122
continue
123123
}

0 commit comments

Comments
 (0)