Skip to content

Commit 40c86d8

Browse files
committed
node: device-mgr: Ensure consistent use of named arguments
Throughout the devicemanager codebase the named argument to represent resource for logging pupose is `resourceName` as opposed to `resource`. The latter can only be seen in topology_hints.go files. To ensure consistency with the rest of the codebase and also because we want to adhere to the recommendations in the Kubernetes documentation about named arguments: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-instrumentation/migration-to-structured-logging.md#name-arguments we update the key from `resource` to `resourceName`. Signed-off-by: Swati Sehgal <[email protected]>
1 parent 19e406a commit 40c86d8

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

pkg/kubelet/cm/devicemanager/topology_hints.go

Lines changed: 8 additions & 8 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, "pod", klog.KObj(pod), "containerName", container.Name, "request", requested)
46+
klog.InfoS("Resource does not have a topology preference", "resourceName", resource, "pod", klog.KObj(pod), "containerName", container.Name, "request", requested)
4747
deviceHints[resource] = nil
4848
continue
4949
}
@@ -54,11 +54,11 @@ func (m *ManagerImpl) GetTopologyHints(pod *v1.Pod, container *v1.Container) map
5454
allocated := m.podDevices.containerDevices(string(pod.UID), container.Name, resource)
5555
if allocated.Len() > 0 {
5656
if allocated.Len() != requested {
57-
klog.InfoS("Resource already allocated to pod with different number than request", "resource", resource, "pod", klog.KObj(pod), "containerName", container.Name, "request", requested, "allocated", allocated.Len())
57+
klog.InfoS("Resource already allocated to pod with different number than request", "resourceName", resource, "pod", klog.KObj(pod), "containerName", container.Name, "request", requested, "allocated", allocated.Len())
5858
deviceHints[resource] = []topologymanager.TopologyHint{}
5959
continue
6060
}
61-
klog.InfoS("Regenerating TopologyHints for resource already allocated to pod", "resource", resource, "pod", klog.KObj(pod), "containerName", container.Name)
61+
klog.InfoS("Regenerating TopologyHints for resource already allocated to pod", "resourceName", resource, "pod", klog.KObj(pod), "containerName", container.Name)
6262
deviceHints[resource] = m.generateDeviceTopologyHints(resource, allocated, sets.Set[string]{}, requested)
6363
continue
6464
}
@@ -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, "pod", klog.KObj(pod), "containerName", container.Name, "request", requested, "available", available.Union(reusable).Len())
70+
klog.InfoS("Unable to generate topology hints: requested number of devices unavailable", "resourceName", 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, "pod", klog.KObj(pod), "request", requested)
97+
klog.InfoS("Resource does not have a topology preference", "resourceName", resource, "pod", klog.KObj(pod), "request", requested)
9898
deviceHints[resource] = nil
9999
continue
100100
}
@@ -105,19 +105,19 @@ func (m *ManagerImpl) GetPodTopologyHints(pod *v1.Pod) map[string][]topologymana
105105
allocated := m.podDevices.podDevices(string(pod.UID), resource)
106106
if allocated.Len() > 0 {
107107
if allocated.Len() != requested {
108-
klog.InfoS("Resource already allocated to pod with different number than request", "resource", resource, "pod", klog.KObj(pod), "request", requested, "allocated", allocated.Len())
108+
klog.InfoS("Resource already allocated to pod with different number than request", "resourceName", resource, "pod", klog.KObj(pod), "request", requested, "allocated", allocated.Len())
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), "allocated", allocated.Len())
112+
klog.InfoS("Regenerating TopologyHints for resource already allocated to pod", "resourceName", 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, "pod", klog.KObj(pod), "request", requested, "available", available.Len())
120+
klog.InfoS("Unable to generate topology hints: requested number of devices unavailable", "resourceName", resource, "pod", klog.KObj(pod), "request", requested, "available", available.Len())
121121
deviceHints[resource] = []topologymanager.TopologyHint{}
122122
continue
123123
}

0 commit comments

Comments
 (0)