Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resmgr/policy: golangci-lint fixes. #440

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading