mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-18 08:09:58 +00:00
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 <swsehgal@redhat.com>
This commit is contained in:
parent
19e406a357
commit
40c86d8e06
@ -43,7 +43,7 @@ func (m *ManagerImpl) GetTopologyHints(pod *v1.Pod, container *v1.Container) map
|
|||||||
for resource, requested := range accumulatedResourceRequests {
|
for resource, requested := range accumulatedResourceRequests {
|
||||||
// Only consider devices that actually contain topology information.
|
// Only consider devices that actually contain topology information.
|
||||||
if aligned := m.deviceHasTopologyAlignment(resource); !aligned {
|
if aligned := m.deviceHasTopologyAlignment(resource); !aligned {
|
||||||
klog.InfoS("Resource does not have a topology preference", "resource", resource, "pod", klog.KObj(pod), "containerName", container.Name, "request", requested)
|
klog.InfoS("Resource does not have a topology preference", "resourceName", resource, "pod", klog.KObj(pod), "containerName", container.Name, "request", requested)
|
||||||
deviceHints[resource] = nil
|
deviceHints[resource] = nil
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -54,11 +54,11 @@ func (m *ManagerImpl) GetTopologyHints(pod *v1.Pod, container *v1.Container) map
|
|||||||
allocated := m.podDevices.containerDevices(string(pod.UID), container.Name, resource)
|
allocated := m.podDevices.containerDevices(string(pod.UID), container.Name, resource)
|
||||||
if allocated.Len() > 0 {
|
if allocated.Len() > 0 {
|
||||||
if allocated.Len() != requested {
|
if allocated.Len() != requested {
|
||||||
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())
|
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())
|
||||||
deviceHints[resource] = []topologymanager.TopologyHint{}
|
deviceHints[resource] = []topologymanager.TopologyHint{}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
klog.InfoS("Regenerating TopologyHints for resource already allocated to pod", "resource", resource, "pod", klog.KObj(pod), "containerName", container.Name)
|
klog.InfoS("Regenerating TopologyHints for resource already allocated to pod", "resourceName", resource, "pod", klog.KObj(pod), "containerName", container.Name)
|
||||||
deviceHints[resource] = m.generateDeviceTopologyHints(resource, allocated, sets.Set[string]{}, requested)
|
deviceHints[resource] = m.generateDeviceTopologyHints(resource, allocated, sets.Set[string]{}, requested)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -67,7 +67,7 @@ func (m *ManagerImpl) GetTopologyHints(pod *v1.Pod, container *v1.Container) map
|
|||||||
available := m.getAvailableDevices(resource)
|
available := m.getAvailableDevices(resource)
|
||||||
reusable := m.devicesToReuse[string(pod.UID)][resource]
|
reusable := m.devicesToReuse[string(pod.UID)][resource]
|
||||||
if available.Union(reusable).Len() < requested {
|
if available.Union(reusable).Len() < requested {
|
||||||
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())
|
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())
|
||||||
deviceHints[resource] = []topologymanager.TopologyHint{}
|
deviceHints[resource] = []topologymanager.TopologyHint{}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -94,7 +94,7 @@ func (m *ManagerImpl) GetPodTopologyHints(pod *v1.Pod) map[string][]topologymana
|
|||||||
for resource, requested := range accumulatedResourceRequests {
|
for resource, requested := range accumulatedResourceRequests {
|
||||||
// Only consider devices that actually contain topology information.
|
// Only consider devices that actually contain topology information.
|
||||||
if aligned := m.deviceHasTopologyAlignment(resource); !aligned {
|
if aligned := m.deviceHasTopologyAlignment(resource); !aligned {
|
||||||
klog.InfoS("Resource does not have a topology preference", "resource", resource, "pod", klog.KObj(pod), "request", requested)
|
klog.InfoS("Resource does not have a topology preference", "resourceName", resource, "pod", klog.KObj(pod), "request", requested)
|
||||||
deviceHints[resource] = nil
|
deviceHints[resource] = nil
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -105,11 +105,11 @@ func (m *ManagerImpl) GetPodTopologyHints(pod *v1.Pod) map[string][]topologymana
|
|||||||
allocated := m.podDevices.podDevices(string(pod.UID), resource)
|
allocated := m.podDevices.podDevices(string(pod.UID), resource)
|
||||||
if allocated.Len() > 0 {
|
if allocated.Len() > 0 {
|
||||||
if allocated.Len() != requested {
|
if allocated.Len() != requested {
|
||||||
klog.InfoS("Resource already allocated to pod with different number than request", "resource", resource, "pod", klog.KObj(pod), "request", requested, "allocated", allocated.Len())
|
klog.InfoS("Resource already allocated to pod with different number than request", "resourceName", resource, "pod", klog.KObj(pod), "request", requested, "allocated", allocated.Len())
|
||||||
deviceHints[resource] = []topologymanager.TopologyHint{}
|
deviceHints[resource] = []topologymanager.TopologyHint{}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
klog.InfoS("Regenerating TopologyHints for resource already allocated to pod", "resource", resource, "pod", klog.KObj(pod), "allocated", allocated.Len())
|
klog.InfoS("Regenerating TopologyHints for resource already allocated to pod", "resourceName", resource, "pod", klog.KObj(pod), "allocated", allocated.Len())
|
||||||
deviceHints[resource] = m.generateDeviceTopologyHints(resource, allocated, sets.Set[string]{}, requested)
|
deviceHints[resource] = m.generateDeviceTopologyHints(resource, allocated, sets.Set[string]{}, requested)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -117,7 +117,7 @@ func (m *ManagerImpl) GetPodTopologyHints(pod *v1.Pod) map[string][]topologymana
|
|||||||
// Get the list of available devices, for which TopologyHints should be generated.
|
// Get the list of available devices, for which TopologyHints should be generated.
|
||||||
available := m.getAvailableDevices(resource)
|
available := m.getAvailableDevices(resource)
|
||||||
if available.Len() < requested {
|
if available.Len() < requested {
|
||||||
klog.InfoS("Unable to generate topology hints: requested number of devices unavailable", "resource", resource, "pod", klog.KObj(pod), "request", requested, "available", available.Len())
|
klog.InfoS("Unable to generate topology hints: requested number of devices unavailable", "resourceName", resource, "pod", klog.KObj(pod), "request", requested, "available", available.Len())
|
||||||
deviceHints[resource] = []topologymanager.TopologyHint{}
|
deviceHints[resource] = []topologymanager.TopologyHint{}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user