diff --git a/pkg/registry/generic/registry/storage_factory.go b/pkg/registry/generic/registry/storage_factory.go index 0e1d62f1b..60ad5a9b6 100644 --- a/pkg/registry/generic/registry/storage_factory.go +++ b/pkg/registry/generic/registry/storage_factory.go @@ -49,8 +49,9 @@ func StorageWithCacher() generic.StorageDecorator { if err != nil { return s, d, err } - if klog.V(5).Enabled() { - klog.V(5).InfoS("Storage caching is enabled", objectTypeToArgs(newFunc())...) + if klogV := klog.V(5); klogV.Enabled() { + //nolint:logcheck // It complains about the key/value pairs because it cannot check them. + klogV.InfoS("Storage caching is enabled", objectTypeToArgs(newFunc())...) } cacherConfig := cacherstorage.Config{ diff --git a/pkg/server/filters/priority-and-fairness.go b/pkg/server/filters/priority-and-fairness.go index 6cb3335fc..66e4007d3 100644 --- a/pkg/server/filters/priority-and-fairness.go +++ b/pkg/server/filters/priority-and-fairness.go @@ -125,6 +125,10 @@ func WithPriorityAndFairness( workEstimate := workEstimator(r, classification.FlowSchemaName, classification.PriorityLevelName) fcmetrics.ObserveWorkEstimatedSeats(classification.PriorityLevelName, classification.FlowSchemaName, workEstimate.MaxSeats()) + // nolint:logcheck // Not using the result of klog.V + // inside the if branch is okay, we just use it to + // determine whether the additional information should + // be added. if klog.V(4).Enabled() { httplog.AddKeyValue(ctx, "apf_iseats", workEstimate.InitialSeats) httplog.AddKeyValue(ctx, "apf_fseats", workEstimate.FinalSeats) diff --git a/pkg/storage/etcd3/logger.go b/pkg/storage/etcd3/logger.go index 651b51800..773d12f6f 100644 --- a/pkg/storage/etcd3/logger.go +++ b/pkg/storage/etcd3/logger.go @@ -32,19 +32,19 @@ type klogWrapper struct{} const klogWrapperDepth = 4 func (klogWrapper) Info(args ...interface{}) { - if klog.V(5).Enabled() { - klog.V(5).InfoSDepth(klogWrapperDepth, fmt.Sprint(args...)) + if klogV := klog.V(5); klogV.Enabled() { + klogV.InfoSDepth(klogWrapperDepth, fmt.Sprint(args...)) } } func (klogWrapper) Infoln(args ...interface{}) { - if klog.V(5).Enabled() { - klog.V(5).InfoSDepth(klogWrapperDepth, fmt.Sprintln(args...)) + if klogV := klog.V(5); klogV.Enabled() { + klogV.InfoSDepth(klogWrapperDepth, fmt.Sprintln(args...)) } } func (klogWrapper) Infof(format string, args ...interface{}) { - if klog.V(5).Enabled() { + if klogV := klog.V(5); klogV.Enabled() { klog.V(5).InfoSDepth(klogWrapperDepth, fmt.Sprintf(format, args...)) } } diff --git a/pkg/util/flowcontrol/apf_controller.go b/pkg/util/flowcontrol/apf_controller.go index 8ea4000ee..fee3a8050 100644 --- a/pkg/util/flowcontrol/apf_controller.go +++ b/pkg/util/flowcontrol/apf_controller.go @@ -434,8 +434,8 @@ func (cfgCtlr *configController) digestConfigObjects(newPLs []*flowcontrol.Prior // if we are going to issue an update, be sure we track every name we update so we know if we update it too often. currResult.updatedItems.Insert(fsu.flowSchema.Name) - if klog.V(4).Enabled() { - klog.V(4).Infof("%s writing Condition %s to FlowSchema %s, which had ResourceVersion=%s, because its previous value was %s, diff: %s", + if klogV := klog.V(4); klogV.Enabled() { + klogV.Infof("%s writing Condition %s to FlowSchema %s, which had ResourceVersion=%s, because its previous value was %s, diff: %s", cfgCtlr.name, fsu.condition, fsu.flowSchema.Name, fsu.flowSchema.ResourceVersion, fcfmt.Fmt(fsu.oldValue), cmp.Diff(fsu.oldValue, fsu.condition)) } fsIfc := cfgCtlr.flowcontrolClient.FlowSchemas() diff --git a/pkg/util/flowcontrol/fairqueuing/queueset/queueset.go b/pkg/util/flowcontrol/fairqueuing/queueset/queueset.go index 03e98d2a8..d3864d44b 100644 --- a/pkg/util/flowcontrol/fairqueuing/queueset/queueset.go +++ b/pkg/util/flowcontrol/fairqueuing/queueset/queueset.go @@ -573,9 +573,9 @@ func (qs *queueSet) shuffleShardLocked(hashValue uint64, descr1, descr2 interfac bestQueueIdx = queueIdx } } - if klog.V(6).Enabled() { + if klogV := klog.V(6); klogV.Enabled() { chosenQueue := qs.queues[bestQueueIdx] - klog.V(6).Infof("QS(%s) at t=%s R=%v: For request %#+v %#+v chose queue %d, with sum: %#v & %d seats in use & nextDispatchR=%v", qs.qCfg.Name, qs.clock.Now().Format(nsTimeFmt), qs.currentR, descr1, descr2, bestQueueIdx, chosenQueue.requests.QueueSum(), chosenQueue.seatsInUse, chosenQueue.nextDispatchR) + klogV.Infof("QS(%s) at t=%s R=%v: For request %#+v %#+v chose queue %d, with sum: %#v & %d seats in use & nextDispatchR=%v", qs.qCfg.Name, qs.clock.Now().Format(nsTimeFmt), qs.currentR, descr1, descr2, bestQueueIdx, chosenQueue.requests.QueueSum(), chosenQueue.seatsInUse, chosenQueue.nextDispatchR) } return bestQueueIdx }