Skip to content

Commit

Permalink
migrate noderesources, noderesourcetopology dirs to structured logging
Browse files Browse the repository at this point in the history
  • Loading branch information
yharish991 committed Sep 14, 2021
1 parent 49ebc2b commit 1b08670
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 20 deletions.
2 changes: 1 addition & 1 deletion pkg/noderesources/allocatable.go
Expand Up @@ -138,7 +138,7 @@ func score(capacity int64, mode config.ModeType) int64 {
return capacity
}

klog.V(10).Infoln("No match for mode: ", mode)
klog.V(10).InfoS("No match for mode", "mode", mode)
return 0
}

Expand Down
26 changes: 11 additions & 15 deletions pkg/noderesources/resource_allocation.go
Expand Up @@ -73,20 +73,16 @@ func (r *resourceAllocationScorer) score(
}
if klog.V(10).Enabled() {
if len(pod.Spec.Volumes) >= 0 && utilfeature.DefaultFeatureGate.Enabled(features.BalanceAttachedNodeVolumes) && nodeInfo.TransientInfo != nil {
klog.Infof(
"%v -> %v: %v, map of allocatable resources %v, map of requested resources %v , allocatable volumes %d, requested volumes %d, score %d",
pod.Name, node.Name, r.Name,
allocatable, requested, nodeInfo.TransientInfo.TransNodeInfo.AllocatableVolumesCount,
nodeInfo.TransientInfo.TransNodeInfo.RequestedVolumes,
score,
)
klog.InfoS("Resources, volumes and score",
"podName", pod.Name, "nodeName", node.Name, "scorer", r.Name,
"allocatableResources", allocatable, "requestedResources", requested,
"allocatableVolumes", nodeInfo.TransientInfo.TransNodeInfo.AllocatableVolumesCount, "requestedVolumes", nodeInfo.TransientInfo.TransNodeInfo.RequestedVolumes,
"score", score)
} else {
klog.Infof(
"%v -> %v: %v, map of allocatable resources %v, map of requested resources %v ,score %d,",
pod.Name, node.Name, r.Name,
allocatable, requested, score,
)

klog.InfoS("Resources and score",
"podName", pod.Name, "nodeName", node.Name, "scorer", r.Name,
"allocatableResources", allocatable, "requestedResources", requested,
"score", score)
}
}

Expand All @@ -110,8 +106,8 @@ func calculateResourceAllocatableRequest(nodeInfo *framework.NodeInfo, pod *v1.P
}
}
if klog.V(10).Enabled() {
klog.Infof("requested resource %v not considered for node score calculation",
resource,
klog.InfoS("Requested resource not considered for node score calculation",
"resource", resource,
)
}
return 0, 0
Expand Down
8 changes: 4 additions & 4 deletions pkg/noderesourcetopology/filter.go
Expand Up @@ -34,7 +34,7 @@ import (
type PolicyHandler func(pod *v1.Pod, zoneMap topologyv1alpha1.ZoneList) *framework.Status

func singleNUMAContainerLevelHandler(pod *v1.Pod, zones topologyv1alpha1.ZoneList) *framework.Status {
klog.V(5).Infof("Single NUMA node handler")
klog.V(5).InfoS("Single NUMA node handler")

// prepare NUMANodes list from zoneMap
nodes := createNUMANodeList(zones)
Expand Down Expand Up @@ -94,7 +94,7 @@ func resMatchNUMANodes(nodes NUMANodeList, resources v1.ResourceList, qos v1.Pod
}

func singleNUMAPodLevelHandler(pod *v1.Pod, zones topologyv1alpha1.ZoneList) *framework.Status {
klog.V(5).Infof("Pod Level Resource handler")
klog.V(5).InfoS("Pod Level Resource handler")
resources := make(v1.ResourceList)

// We count here in the way TopologyManager is doing it, IOW we put InitContainers
Expand Down Expand Up @@ -131,14 +131,14 @@ func (tm *TopologyMatch) Filter(ctx context.Context, cycleState *framework.Cycle
return nil
}

klog.V(5).Infof("nodeTopology: %v", nodeTopology)
klog.V(5).InfoS("Found NodeResourceTopology", klog.KObj(nodeTopology))
for _, policyName := range nodeTopology.TopologyPolicies {
if handler, ok := tm.policyHandlers[topologyv1alpha1.TopologyManagerPolicy(policyName)]; ok {
if status := handler.filter(pod, nodeTopology.Zones); status != nil {
return status
}
} else {
klog.V(5).Infof("Handler for policy %s not found", policyName)
klog.V(5).Infof("Policy handler not found", "policy", policyName)
}
}
return nil
Expand Down

0 comments on commit 1b08670

Please sign in to comment.