From a3ecb2d80106f95d54ee0ae90ca9d0928eb786a8 Mon Sep 17 00:00:00 2001 From: Krisztian Litkey Date: Mon, 9 Dec 2024 18:35:22 +0200 Subject: [PATCH] resmgr/policy: golangci-lint fixes. Signed-off-by: Krisztian Litkey --- pkg/resmgr/policy/metrics.go | 4 +--- pkg/resmgr/policy/policy.go | 25 ++++++++++--------------- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/pkg/resmgr/policy/metrics.go b/pkg/resmgr/policy/metrics.go index 368bb18bf..2fac050ff 100644 --- a/pkg/resmgr/policy/metrics.go +++ b/pkg/resmgr/policy/metrics.go @@ -16,7 +16,6 @@ package policy import ( "strconv" - "sync" "github.com/prometheus/client_golang/prometheus" v1 "k8s.io/api/core/v1" @@ -29,7 +28,6 @@ import ( type PolicyCollector struct { policy *policy - block sync.Mutex } func (p *policy) newPolicyCollector() *PolicyCollector { @@ -89,7 +87,7 @@ func (p *policy) newSystemCollector() *SystemCollector { system: p.system, Nodes: map[int]*NodeMetric{}, Cpus: map[int]*CpuMetric{}, - Metrics: make([]*prometheus.GaugeVec, metricsCount, metricsCount), + Metrics: make([]*prometheus.GaugeVec, metricsCount), } s.Metrics[nodeCapacity] = prometheus.NewGaugeVec( diff --git a/pkg/resmgr/policy/policy.go b/pkg/resmgr/policy/policy.go index 8b74d8995..bbc1bac93 100644 --- a/pkg/resmgr/policy/policy.go +++ b/pkg/resmgr/policy/policy.go @@ -198,20 +198,12 @@ type ZoneAttribute struct { // Policy instance/state. type policy struct { - options Options // policy options - cache cache.Cache // system state cache - active Backend // our active backend - system system.System // system/HW/topology info - sendEvent SendEventFn // function to send event up to the resource manager - pcollect *PolicyCollector // policy metrics collector - scollect *SystemCollector // system metrics collector -} - -// backend is a registered Backend. -type backend struct { - name string // unique backend name - description string // verbose backend description - create CreateFn // backend creation function + options Options // policy options + cache cache.Cache // system state cache + active Backend // our active backend + system system.System // system/HW/topology info + pcollect *PolicyCollector // policy metrics collector + scollect *SystemCollector // system metrics collector } // Out logger instance. @@ -322,7 +314,10 @@ func (p *policy) ExportResourceData(c cache.Container) { } } - p.cache.WriteFile(c.GetID(), ExportedResources, 0644, buf.Bytes()) + err := p.cache.WriteFile(c.GetID(), ExportedResources, 0644, buf.Bytes()) + if err != nil { + log.Warnf("container %s: failed to export resource data: %v", c.PrettyName(), err) + } } // GetTopologyZones returns the policy/pool data for 'topology zone' CRDs.