Skip to content

Commit

Permalink
feat(sysadvisor): emit bound type code for knob status
Browse files Browse the repository at this point in the history
  • Loading branch information
zzzzhhb committed Dec 1, 2023
1 parent 1d2526f commit dcaf01f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ func (n *MetricSyncerNode) advisorMetric(ctx context.Context) {
Key: fmt.Sprintf("%s%s", data.CustomMetricLabelSelectorPrefixKey, "region"),
Val: fmt.Sprintf("%v", regionName),
},
{
Key: fmt.Sprintf("%s%s", data.CustomMetricLabelSelectorPrefixKey, "bound"),
Val: fmt.Sprintf("%v", regionInfo.RegionStatus.BoundType),
},
}...)
for indicator, overshot := range regionInfo.RegionStatus.OvershootStatus {
regionTag = append(regionTag, metrics.MetricTag{
Expand All @@ -66,7 +62,12 @@ func (n *MetricSyncerNode) advisorMetric(ctx context.Context) {
})
}

_ = n.dataEmitter.StoreFloat64(apimetricnode.CustomMetricNodeAdvisorKnobStatus, 1, metrics.MetricTypeNameRaw, regionTag...)
if code, ok := types.BoundTypeCodeMap[regionInfo.RegionStatus.BoundType]; ok {
_ = n.dataEmitter.StoreFloat64(apimetricnode.CustomMetricNodeAdvisorKnobStatus, float64(code), metrics.MetricTypeNameRaw, regionTag...)
} else {
general.Errorf("invalid bound type %v for ")

Check failure on line 68 in pkg/agent/sysadvisor/plugin/metric-emitter/syncer/node/advisor.go

View workflow job for this annotation

GitHub Actions / Lint

printf: github.com/kubewharf/katalyst-core/pkg/util/general.Errorf format %v reads arg #1, but call has 0 args (govet)

Check failure on line 68 in pkg/agent/sysadvisor/plugin/metric-emitter/syncer/node/advisor.go

View workflow job for this annotation

GitHub Actions / Vet

github.com/kubewharf/katalyst-core/pkg/util/general.Errorf format %v reads arg #1, but call has 0 args
}

return true
})

Expand Down
7 changes: 7 additions & 0 deletions pkg/agent/sysadvisor/types/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ package types

import "time"

var BoundTypeCodeMap = map[BoundType]int{
BoundUpper: BoundUpperCode,
BoundLower: BoundLowerCode,
BoundNone: BoundNoneCode,
BoundUnknown: BoundUnknownCode,
}

const (
RegionNameSeparator = "-"
)
Expand Down
12 changes: 8 additions & 4 deletions pkg/agent/sysadvisor/types/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,20 @@ type BoundType string

const (
// BoundUpper indicates reaching resource upper bound, with highest priority
BoundUpper BoundType = "upper"
BoundUpper BoundType = "upper"
BoundUpperCode int = 0

// BoundLower indicates reaching resource lower bound
BoundLower BoundType = "lower"
BoundLower BoundType = "lower"
BoundLowerCode int = 1

// BoundNone indicates between resource upper and lower bound
BoundNone BoundType = "none"
BoundNone BoundType = "none"
BoundNoneCode int = 2

// BoundUnknown indicates unknown bound status
BoundUnknown BoundType = "unknown"
BoundUnknown BoundType = "unknown"
BoundUnknownCode int = 3
)

// RegionStatus holds stability accounting info of region
Expand Down

0 comments on commit dcaf01f

Please sign in to comment.