Skip to content

Commit c68bbd2

Browse files
committed
Move noopScanner to scanner.go and fix RegisterFlagsWithPrefix
Signed-off-by: Justin Jung <[email protected]>
1 parent d6d3839 commit c68bbd2

File tree

5 files changed

+29
-12
lines changed

5 files changed

+29
-12
lines changed

docs/configuration/config-file-reference.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3203,13 +3203,17 @@ lifecycler:
32033203
[upload_compacted_blocks_enabled: <boolean> | default = true]
32043204
32053205
instance_limits:
3206-
# Max CPU utilization that this ingester can reach before rejecting new query
3207-
# request (across all tenants) in percentage, between 0 and 1. 0 = unlimited.
3206+
# EXPERIMENTAL: Max CPU utilization that this ingester can reach before
3207+
# rejecting new query request (across all tenants) in percentage, between 0
3208+
# and 1. monitored_resources config must include the resource type. 0 to
3209+
# disable.
32083210
# CLI flag: -ingester.instance-limits.cpu-utilization
32093211
[cpu_utilization: <float> | default = 0]
32103212
3211-
# Max heap utilization that this ingester can reach before rejecting new query
3212-
# request (across all tenants) in percentage, between 0 and 1. 0 = unlimited.
3213+
# EXPERIMENTAL: Max heap utilization that this ingester can reach before
3214+
# rejecting new query request (across all tenants) in percentage, between 0
3215+
# and 1. monitored_resources config must include the resource type. 0 to
3216+
# disable.
32133217
# CLI flag: -ingester.instance-limits.heap-utilization
32143218
[heap_utilization: <float> | default = 0]
32153219

pkg/ingester/instance_limits.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ func (cfg *InstanceLimits) RegisterFlagsWithPrefix(f *flag.FlagSet, prefix strin
3838
f.Int64Var(&cfg.MaxInMemorySeries, prefix+"instance-limits.max-series", 0, "Max series that this ingester can hold (across all tenants). Requests to create additional series will be rejected. This limit only works when using blocks engine. 0 = unlimited.")
3939
f.Int64Var(&cfg.MaxInflightPushRequests, prefix+"instance-limits.max-inflight-push-requests", 0, "Max inflight push requests that this ingester can handle (across all tenants). Additional requests will be rejected. 0 = unlimited.")
4040
f.Int64Var(&cfg.MaxInflightQueryRequests, prefix+"instance-limits.max-inflight-query-requests", 0, "Max inflight query requests that this ingester can handle (across all tenants). Additional requests will be rejected. 0 = unlimited.")
41-
f.Float64Var(&cfg.CPUUtilization, prefix+"instance-limits.cpu-utilization", 0, "Max CPU utilization that this ingester can reach before rejecting new query request (across all tenants) in percentage, between 0 and 1. 0 = unlimited.")
42-
f.Float64Var(&cfg.HeapUtilization, prefix+"instance-limits.heap-utilization", 0, "Max heap utilization that this ingester can reach before rejecting new query request (across all tenants) in percentage, between 0 and 1. 0 = unlimited.")
41+
cfg.InstanceLimits.RegisterFlagsWithPrefix(f, prefix)
4342
}
4443

4544
func (cfg *InstanceLimits) Validate(monitoredResources flagext.StringSliceCSV) error {

pkg/util/resource/scanner.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ type scanner interface {
1313
scan() (float64, error)
1414
}
1515

16+
type noopScanner struct{}
17+
18+
func (s *noopScanner) scan() (float64, error) {
19+
return 0, nil
20+
}
21+
1622
type heapScanner struct {
1723
metricSamples []metrics.Sample
1824
}

pkg/util/resource/scanner_darwin.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@ import (
88
"github.com/cortexproject/cortex/pkg/util/log"
99
)
1010

11-
type noopScanner struct{}
12-
13-
func (s *noopScanner) scan() (float64, error) {
14-
return 0, nil
15-
}
16-
1711
func newCPUScanner() (scanner, error) {
1812
level.Warn(log.Logger).Log("msg", "CPU scanner not supported in darwin.")
1913
return &noopScanner{}, nil

pkg/util/resource/scanner_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package resource
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/require"
7+
)
8+
9+
func Test_NoopScanner(t *testing.T) {
10+
s := noopScanner{}
11+
val, err := s.scan()
12+
require.NoError(t, err)
13+
require.Zero(t, val)
14+
}

0 commit comments

Comments
 (0)