Skip to content

Commit b0badfe

Browse files
committed
nrt: logging: avoid redundancies
There is no de-duplication of key/value pairs by default in go-logr or in klog, so we remove data which is not obviously needed and which is likely to be provided, or already provided in some other form (e.g. logger name) from the framework. Signed-off-by: Francesco Romani <[email protected]>
1 parent 45535c5 commit b0badfe

File tree

5 files changed

+6
-10
lines changed

5 files changed

+6
-10
lines changed

pkg/noderesourcetopology/filter.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,7 @@ func (tm *TopologyMatch) Filter(ctx context.Context, cycleState *framework.Cycle
177177

178178
nodeName := nodeInfo.Node().Name
179179

180-
lh := klog.FromContext(klog.NewContext(ctx, tm.logger)).WithValues("ExtensionPoint", "Filter").
181-
WithValues(logging.KeyPod, klog.KObj(pod), logging.KeyPodUID, logging.PodUID(pod), logging.KeyNode, nodeName)
180+
lh := klog.FromContext(klog.NewContext(ctx, tm.logger)).WithValues(logging.KeyPod, klog.KObj(pod), logging.KeyPodUID, logging.PodUID(pod), logging.KeyNode, nodeName)
182181

183182
lh.V(4).Info(logging.FlowBegin)
184183
defer lh.V(4).Info(logging.FlowEnd)

pkg/noderesourcetopology/plugin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func (tm *TopologyMatch) Name() string {
8989

9090
// New initializes a new plugin and returns it.
9191
func New(ctx context.Context, args runtime.Object, handle framework.Handle) (framework.Plugin, error) {
92-
lh := klog.FromContext(ctx).WithValues("plugin", Name)
92+
lh := klog.FromContext(ctx)
9393

9494
lh.V(5).Info("creating new noderesourcetopology plugin")
9595
tcfg, ok := args.(*apiconfig.NodeResourceTopologyMatchArgs)

pkg/noderesourcetopology/postbind.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ import (
2626
)
2727

2828
func (tm *TopologyMatch) PostBind(ctx context.Context, state *framework.CycleState, pod *corev1.Pod, nodeName string) {
29-
lh := klog.FromContext(klog.NewContext(ctx, tm.logger)).WithValues("ExtensionPoint", "PostBind").
30-
WithValues(logging.KeyPod, klog.KObj(pod), logging.KeyPodUID, logging.PodUID(pod), logging.KeyNode, nodeName)
29+
lh := klog.FromContext(klog.NewContext(ctx, tm.logger)).WithValues(logging.KeyPod, klog.KObj(pod), logging.KeyPodUID, logging.PodUID(pod), logging.KeyNode, nodeName)
3130
lh.V(4).Info(logging.FlowBegin)
3231
defer lh.V(4).Info(logging.FlowEnd)
3332

pkg/noderesourcetopology/reserve.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ import (
2727

2828
func (tm *TopologyMatch) Reserve(ctx context.Context, state *framework.CycleState, pod *corev1.Pod, nodeName string) *framework.Status {
2929
// the scheduler framework will add the node/name key/value pair
30-
lh := klog.FromContext(klog.NewContext(ctx, tm.logger)).WithValues("ExtensionPoint", "Reserve").
31-
WithValues(logging.KeyPod, klog.KObj(pod), logging.KeyPodUID, logging.PodUID(pod), logging.KeyNode, nodeName)
30+
lh := klog.FromContext(klog.NewContext(ctx, tm.logger)).WithValues(logging.KeyPod, klog.KObj(pod), logging.KeyPodUID, logging.PodUID(pod), logging.KeyNode, nodeName)
3231
lh.V(4).Info(logging.FlowBegin)
3332
defer lh.V(4).Info(logging.FlowEnd)
3433

@@ -39,7 +38,7 @@ func (tm *TopologyMatch) Reserve(ctx context.Context, state *framework.CycleStat
3938

4039
func (tm *TopologyMatch) Unreserve(ctx context.Context, state *framework.CycleState, pod *corev1.Pod, nodeName string) {
4140
// the scheduler framework will add the node/name key/value pair
42-
lh := klog.FromContext(ctx).WithValues(logging.KeyPod, klog.KObj(pod), logging.KeyPodUID, logging.PodUID(pod))
41+
lh := klog.FromContext(klog.NewContext(ctx, tm.logger)).WithValues(logging.KeyPod, klog.KObj(pod), logging.KeyPodUID, logging.PodUID(pod), logging.KeyNode, nodeName)
4342
lh.V(4).Info(logging.FlowBegin)
4443
defer lh.V(4).Info(logging.FlowEnd)
4544

pkg/noderesourcetopology/score.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ func (rw resourceToWeightMap) weight(r v1.ResourceName) int64 {
6161

6262
func (tm *TopologyMatch) Score(ctx context.Context, state *framework.CycleState, pod *v1.Pod, nodeName string) (int64, *framework.Status) {
6363
// the scheduler framework will add the node/name key/value pair
64-
lh := klog.FromContext(klog.NewContext(ctx, tm.logger)).WithValues("ExtensionPoint", "Score").
65-
WithValues(logging.KeyPod, klog.KObj(pod), logging.KeyPodUID, logging.PodUID(pod), logging.KeyNode, nodeName)
64+
lh := klog.FromContext(klog.NewContext(ctx, tm.logger)).WithValues(logging.KeyPod, klog.KObj(pod), logging.KeyPodUID, logging.PodUID(pod), logging.KeyNode, nodeName)
6665

6766
lh.V(4).Info(logging.FlowBegin)
6867
defer lh.V(4).Info(logging.FlowEnd)

0 commit comments

Comments
 (0)