Skip to content
This repository was archived by the owner on Jun 19, 2026. It is now read-only.
Open
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
6 changes: 3 additions & 3 deletions .bingo/Variables.mk
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ $(GOJSONTOYAML): $(BINGO_DIR)/gojsontoyaml.mod
@echo "(re)installing $(GOBIN)/gojsontoyaml-v0.1.0"
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=gojsontoyaml.mod -o=$(GOBIN)/gojsontoyaml-v0.1.0 "github.com/brancz/gojsontoyaml"

GOLANGCI_LINT := $(GOBIN)/golangci-lint-v1.61.0
GOLANGCI_LINT := $(GOBIN)/golangci-lint-v2.11.1
$(GOLANGCI_LINT): $(BINGO_DIR)/golangci-lint.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
@echo "(re)installing $(GOBIN)/golangci-lint-v1.61.0"
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=golangci-lint.mod -o=$(GOBIN)/golangci-lint-v1.61.0 "github.com/golangci/golangci-lint/cmd/golangci-lint"
@echo "(re)installing $(GOBIN)/golangci-lint-v2.11.1"
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=golangci-lint.mod -o=$(GOBIN)/golangci-lint-v2.11.1 "github.com/golangci/golangci-lint/v2/cmd/golangci-lint"

GOTESPLIT := $(GOBIN)/gotesplit-v0.2.1
$(GOTESPLIT): $(BINGO_DIR)/gotesplit.mod
Expand Down
6 changes: 2 additions & 4 deletions .bingo/golangci-lint.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT

go 1.22.1
go 1.25.0

toolchain go1.23.1

require github.com/golangci/golangci-lint v1.61.0 // cmd/golangci-lint
require github.com/golangci/golangci-lint/v2 v2.11.1 // cmd/golangci-lint
295 changes: 295 additions & 0 deletions .bingo/golangci-lint.sum

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ orbs:
executors:
golang:
docker:
- image: cimg/go:1.23-node
- image: cimg/go:1.25-node
golang-test:
docker:
- image: cimg/go:1.23-node
- image: cimg/go:1.25-node
- image: quay.io/thanos/docker-swift-onlyone-authv2-keystone:v0.1

jobs:
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- name: Install Go.
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version: 1.23.x
go-version: 1.25.x

- name: Install bingo modules
run: make install-tool-deps
Expand All @@ -55,7 +55,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version: 1.23.x
go-version: 1.25.x

- uses: actions/cache@0c907a75c2c80ebcb7f088228285e798b750cf8f # v4.2.1
with:
Expand All @@ -82,7 +82,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version: 1.23.x
go-version: 1.25.x

- uses: actions/cache@0c907a75c2c80ebcb7f088228285e798b750cf8f # v4.2.1
with:
Expand All @@ -109,7 +109,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version: 1.23.x
go-version: 1.25.x

- uses: actions/cache@0c907a75c2c80ebcb7f088228285e798b750cf8f # v4.2.1
with:
Expand Down Expand Up @@ -158,7 +158,7 @@ jobs:
- name: Install Go.
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version: 1.23.x
go-version: 1.25.x

- uses: actions/cache@0c907a75c2c80ebcb7f088228285e798b750cf8f # v4.2.1
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ examples/tmp/

# Ignore generated Cortex files
internal/cortex/querier/active-query-tracker
.vscode/
179 changes: 108 additions & 71 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,82 +1,119 @@
# This file contains all available configuration options
# with their default values.

# options for analysis running
version: "2"
run:
# timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 5m

# exit code when at least one issue was found, default is 1
issues-exit-code: 1

# output configuration options
output:
# The formats used to render issues.
formats:
- format: colored-line-number
text:
path: stdout

# print lines of code with issue, default is true
print-issued-lines: true

# print linter name in the end of issue text, default is true
print-linter-name: true

print-linter-name: true
print-issued-lines: true
linters:
enable:
# Sorted alphabetically.
- errcheck
- copyloopvar
- depguard
- forbidigo
- goconst
- godot
- gofmt
- goimports
- gosimple
- govet
- ineffassign
- misspell
- staticcheck
- typecheck
- unparam
- unused
- exportloopref
- promlinter

linters-settings:
errcheck:
# List of functions to exclude from checking, where each entry is a single function to exclude.
exclude-functions:
- (github.com/go-kit/log.Logger).Log
- fmt.Fprintln
- fmt.Fprint
misspell:
locale: US
goconst:
min-occurrences: 5

issues:
exclude-rules:
# We don't check metrics naming in the tests.
- path: _test\.go
linters:
- promlinter
# These are not being checked since these methods exist
# so that no one else could implement them.
- linters:
- unused
text: "SourceStoreAPI.implementsStoreAPI"
- linters:
- unused
text: "SourceStoreAPI.producesBlocks"
- linters:
- unused
text: "Source.producesBlocks"
- linters:
- unused
text: "newMockAlertmanager"
- linters:
- unused
text: "ruleAndAssert"
# Which dirs to exclude: issues from them won't be reported.
exclude-dirs:
- vendor
- internal/cortex
- unparam
settings:
depguard:
# TODO(bwplotka): Add Printf, DefaultRegisterer, NewGaugeFunc and MustRegister
# once exceptions are accepted. Add fmt.Errorf → github.com/pkg/errors.Errorf
# once https://github.com/fatih/faillint/issues/10 is addressed.
rules:
main:
deny:
- pkg: github.com/prometheus/tsdb
desc: "use github.com/prometheus/prometheus/tsdb instead"
- pkg: github.com/prometheus/prometheus/pkg/testutils
desc: "use github.com/thanos-io/thanos/pkg/testutil instead"
- pkg: sync/atomic
desc: "use go.uber.org/atomic instead"
- pkg: github.com/cortexproject/cortex
desc: "use github.com/thanos-io/thanos/internal/cortex instead"
- pkg: io/ioutil
desc: "deprecated: use io and os packages instead"
- pkg: github.com/NYTimes/gziphandler
desc: "use github.com/klauspost/compress/gzhttp instead"
forbidigo:
exclude-godoc-examples: true
analyze-types: true
forbid:
- pattern: '^fmt\.Print(|ln)$'
msg: "use a logger instead"
- pattern: '^fmt\.Sprint$'
msg: "use a logger instead"
- pattern: '^prometheus\.(DefaultGatherer|DefBuckets|NewUntypedFunc|UntypedFunc)$'
pkg: '^github\.com/prometheus/client_golang/prometheus$'
msg: "banned prometheus function"
- pattern: '^prometheus\.(NewCounter|NewCounterVec|NewGauge|NewGaugeVec|NewGaugeFunc|NewHistorgram|NewHistogramVec|NewSummary|NewSummaryVec)$'
pkg: '^github\.com/prometheus/client_golang/prometheus$'
msg: "use promauto equivalent instead"
- pattern: '^parser\.(ParseExpr|ParseMetricSelector)$'
pkg: '^github\.com/prometheus/prometheus/promql/parser$'
msg: "use github.com/thanos-io/thanos/pkg/extpromql instead"
errcheck:
exclude-functions:
- (github.com/go-kit/log.Logger).Log
- fmt.Fprintln
- fmt.Fprint
goconst:
min-occurrences: 5
misspell:
locale: US
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
# We don't check metrics naming in the tests.
- linters:
- promlinter
path: _test\.go
# These are not being checked since these methods exist
# so that no one else could implement them.
- linters:
- unused
text: SourceStoreAPI.implementsStoreAPI
- linters:
- unused
text: SourceStoreAPI.producesBlocks
- linters:
- unused
text: Source.producesBlocks
- linters:
- unused
text: newMockAlertmanager
- linters:
- unused
text: ruleAndAssert
- linters:
- unparam
path: test/e2e/compatibility_test\.go
# fmt.Print/Println/Sprint are allowed in tests.
- linters:
- forbidigo
path: _test\.go
paths:
- vendor
- internal/cortex
- third_party$
- builtin$
- ^examples/
formatters:
enable:
- gofmt
- goimports
exclusions:
generated: lax
paths:
- vendor
- internal/cortex
- third_party$
- builtin$
- ^examples/
33 changes: 16 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,9 @@ format: go-format shell-format

.PHONY: go-format
go-format: ## Formats Go code including imports.
go-format: $(GOIMPORTS)
go-format: $(GOLANGCI_LINT)
@echo ">> formatting go code"
@gofmt -s -w $(FILES_TO_FMT)
@$(GOIMPORTS) -w $(FILES_TO_FMT)
@$(GOLANGCI_LINT) fmt

.PHONY: proto
proto: ## Generates Go files from Thanos proto files.
Expand Down Expand Up @@ -398,21 +397,8 @@ lint: go-lint react-app-lint shell-lint
# --mem-profile-path string Path to memory profile output file
# to debug big allocations during linting.
.PHONY: go-lint
go-lint: check-git deps $(GOLANGCI_LINT) $(FAILLINT)
go-lint: check-git deps $(GOLANGCI_LINT)
$(call require_clean_work_tree,'detected not clean work tree before running lint, previous job changed something?')
@echo ">> verifying modules being imported"
@# TODO(bwplotka): Add, Printf, DefaultRegisterer, NewGaugeFunc and MustRegister once exception are accepted. Add fmt.{Errorf}=github.com/pkg/errors.{Errorf} once https://github.com/fatih/faillint/issues/10 is addressed.
@$(FAILLINT) -paths "github.com/prometheus/tsdb=github.com/prometheus/prometheus/tsdb,\
github.com/prometheus/prometheus/pkg/testutils=github.com/thanos-io/thanos/pkg/testutil,\
github.com/prometheus/client_golang/prometheus.{DefaultGatherer,DefBuckets,NewUntypedFunc,UntypedFunc},\
github.com/prometheus/client_golang/prometheus.{NewCounter,NewCounterVec,NewCounterVec,NewGauge,NewGaugeVec,NewGaugeFunc,\
NewHistorgram,NewHistogramVec,NewSummary,NewSummaryVec}=github.com/prometheus/client_golang/prometheus/promauto.{NewCounter,\
NewCounterVec,NewCounterVec,NewGauge,NewGaugeVec,NewGaugeFunc,NewHistorgram,NewHistogramVec,NewSummary,NewSummaryVec},\
github.com/NYTimes/gziphandler.{GzipHandler}=github.com/klauspost/compress/gzhttp.{GzipHandler},\
sync/atomic=go.uber.org/atomic,github.com/cortexproject/cortex=github.com/thanos-io/thanos/internal/cortex,\
github.com/prometheus/prometheus/promql/parser.{ParseExpr,ParseMetricSelector}=github.com/thanos-io/thanos/pkg/extpromql.{ParseExpr,ParseMetricSelector},\
io/ioutil.{Discard,NopCloser,ReadAll,ReadDir,ReadFile,TempDir,TempFile,Writefile}" $(shell go list ./... | grep -v "internal/cortex")
@$(FAILLINT) -paths "fmt.{Print,Println,Sprint}" -ignore-tests ./...
@echo ">> linting all of the Go files GOGC=${GOGC}"
@$(GOLANGCI_LINT) run
@echo ">> ensuring Copyright headers"
Expand All @@ -421,6 +407,19 @@ io/ioutil.{Discard,NopCloser,ReadAll,ReadDir,ReadFile,TempDir,TempFile,Writefile
@$(MAKE) proto
$(call require_clean_work_tree,'detected files without copyright, run make lint and commit changes')

.PHONY: lint-local
lint-local: ## Runs Go linters locally without clean work tree checks.
lint-local: check-git deps $(GOLANGCI_LINT)
@echo ">> linting all of the Go files GOGC=${GOGC}"
@$(GOLANGCI_LINT) run


.PHONY: lint-fix
lint-fix: ## Runs Go linters and auto-fixes issues where possible.
lint-fix: check-git deps $(GOLANGCI_LINT)
@echo ">> linting and fixing Go files GOGC=${GOGC}"
@$(GOLANGCI_LINT) run --fix

.PHONY: shell-lint
shell-lint: ## Runs static analysis against our shell scripts.
shell-lint: $(SHELLCHECK)
Expand Down
10 changes: 5 additions & 5 deletions cmd/thanos/query_frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,24 @@ func registerQueryFrontend(app *extkingpin.App) {

// Query range tripperware flags.
cmd.Flag("query-range.align-range-with-step", "Mutate incoming queries to align their start and end with their step for better cache-ability. Note: Grafana dashboards do that by default.").
Default("true").BoolVar(&cfg.QueryRangeConfig.AlignRangeWithStep)
Default("true").BoolVar(&cfg.AlignRangeWithStep)

cmd.Flag("query-range.request-downsampled", "Make additional query for downsampled data in case of empty or incomplete response to range request.").
Default("true").BoolVar(&cfg.QueryRangeConfig.RequestDownsampled)
Default("true").BoolVar(&cfg.RequestDownsampled)

cmd.Flag("query-range.split-interval", "Split query range requests by an interval and execute in parallel, it should be greater than 0 when query-range.response-cache-config is configured.").
Default("24h").DurationVar(&cfg.QueryRangeConfig.SplitQueriesByInterval)

cmd.Flag("query-range.min-split-interval", "Split query range requests above this interval in query-range.horizontal-shards requests of equal range. "+
"Using this parameter is not allowed with query-range.split-interval. "+
"One should also set query-range.split-min-horizontal-shards to a value greater than 1 to enable splitting.").
Default("0").DurationVar(&cfg.QueryRangeConfig.MinQuerySplitInterval)
Default("0").DurationVar(&cfg.MinQuerySplitInterval)

cmd.Flag("query-range.max-split-interval", "Split query range below this interval in query-range.horizontal-shards. Queries with a range longer than this value will be split in multiple requests of this length.").
Default("0").DurationVar(&cfg.QueryRangeConfig.MaxQuerySplitInterval)
Default("0").DurationVar(&cfg.MaxQuerySplitInterval)

cmd.Flag("query-range.horizontal-shards", "Split queries in this many requests when query duration is below query-range.max-split-interval.").
Default("0").Int64Var(&cfg.QueryRangeConfig.HorizontalShards)
Default("0").Int64Var(&cfg.HorizontalShards)

cmd.Flag("query-range.max-retries-per-request", "Maximum number of retries for a single query range request; beyond this, the downstream error is returned.").
Default("5").IntVar(&cfg.QueryRangeConfig.MaxRetries)
Expand Down
4 changes: 2 additions & 2 deletions cmd/thanos/receive.go
Original file line number Diff line number Diff line change
Expand Up @@ -1096,10 +1096,10 @@ func (rc *receiveConfig) registerFlag(cmd extkingpin.FlagClause) {

cmd.Flag("receive.hashrings", "Alternative to 'receive.hashrings-file' flag (lower priority). Content of file that contains the hashring configuration.").PlaceHolder("<content>").StringVar(&rc.hashringsFileContent)

hashringAlgorithmsHelptext := strings.Join([]string{string(receive.AlgorithmHashmod), string(receive.AlgorithmKetama)}, ", ")
hashringAlgorithmsHelptext := strings.Join([]string{string(receive.AlgorithmHashmod), string(receive.AlgorithmKetama), string(receive.AlgorithmRendezvous)}, ", ")
cmd.Flag("receive.hashrings-algorithm", "The algorithm used when distributing series in the hashrings. Must be one of "+hashringAlgorithmsHelptext+". Will be overwritten by the tenant-specific algorithm in the hashring config.").
Default(string(receive.AlgorithmHashmod)).
EnumVar(&rc.hashringsAlgorithm, string(receive.AlgorithmHashmod), string(receive.AlgorithmKetama), string(receive.AlgorithmAlignedKetama))
EnumVar(&rc.hashringsAlgorithm, string(receive.AlgorithmHashmod), string(receive.AlgorithmKetama), string(receive.AlgorithmRendezvous))

rc.refreshInterval = extkingpin.ModelDuration(cmd.Flag("receive.hashrings-file-refresh-interval", "Refresh interval to re-read the hashring configuration file. (used as a fallback)").
Default("5m"))
Expand Down
Loading
Loading