Skip to content

Commit

Permalink
resmgr/policy: golangci-lint fixes.
Browse files Browse the repository at this point in the history
Signed-off-by: Krisztian Litkey <[email protected]>
  • Loading branch information
klihub authored and askervin committed Dec 11, 2024
1 parent 7dbcb38 commit 0c2b3df
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
4 changes: 1 addition & 3 deletions pkg/resmgr/policy/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package policy

import (
"strconv"
"sync"

"github.com/prometheus/client_golang/prometheus"
v1 "k8s.io/api/core/v1"
Expand All @@ -29,7 +28,6 @@ import (

type PolicyCollector struct {
policy *policy
block sync.Mutex
}

func (p *policy) newPolicyCollector() *PolicyCollector {
Expand Down Expand Up @@ -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(
Expand Down
25 changes: 10 additions & 15 deletions pkg/resmgr/policy/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 0c2b3df

Please sign in to comment.