diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a475c4f2..bddd9968 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,7 +23,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.21.6 + go-version: 1.23.2 - name: Install package dependencies run: | diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index fc0fafe9..c07d9c6c 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -20,7 +20,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.21.6 + go-version: 1.23.2 - name: Install package dependencies run: | @@ -31,7 +31,7 @@ jobs: run: | go install github.com/golang/protobuf/protoc-gen-go@v1.3.0 go install github.com/gogo/protobuf/protoc-gen-gogoslick@v1.2.1 - go install github.com/fatih/faillint@v1.11.0 + go install github.com/fatih/faillint@v1.14.0 - name: Test run: make BUILD_IN_CONTAINER=false test @@ -40,7 +40,7 @@ jobs: run: | cd / curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh \ - | sudo sh -s v1.55.2 + | sudo sh -s v1.61.0 - name: Run Linter run: make lint diff --git a/.golangci.yml b/.golangci.yml index c0804db5..5420bc53 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -73,3 +73,5 @@ issues: exclude: - Error return value of .*log\.Logger\)\.Log\x60 is not checked - Error return value of .*.Log.* is not checked + - '"io/ioutil" has been deprecated' + - rand.Seed has been deprecated diff --git a/CHANGELOG.md b/CHANGELOG.md index 49706eb7..a0802a7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 2.2.19 (2024-10-18) + +* Upgrade Go to 1.23.2 +* Upgrade Alpine to 3.20.3 + ## 2.2.18 (2024-08-09) * Upgrade Go to 1.22.6 diff --git a/cmd/docker-driver/Dockerfile b/cmd/docker-driver/Dockerfile index ee09eb4d..bc2a4022 100644 --- a/cmd/docker-driver/Dockerfile +++ b/cmd/docker-driver/Dockerfile @@ -9,7 +9,7 @@ COPY . /src/vali WORKDIR /src/vali RUN make clean && make BUILD_IN_CONTAINER=false cmd/docker-driver/docker-driver -FROM alpine:3.20.2 +FROM alpine:3.20.3 RUN apk add --update --no-cache ca-certificates tzdata COPY --from=build /src/vali/cmd/docker-driver/docker-driver /bin/docker-driver WORKDIR /bin/ diff --git a/cmd/fluent-bit/Dockerfile b/cmd/fluent-bit/Dockerfile index ead66814..76679f69 100644 --- a/cmd/fluent-bit/Dockerfile +++ b/cmd/fluent-bit/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.22.6 as build +FROM golang:1.23.2 as build COPY . /src/vali WORKDIR /src/vali RUN make clean && make BUILD_IN_CONTAINER=false fluent-bit-plugin diff --git a/cmd/logcli/Dockerfile b/cmd/logcli/Dockerfile index 27f849d8..7253fc06 100644 --- a/cmd/logcli/Dockerfile +++ b/cmd/logcli/Dockerfile @@ -1,11 +1,11 @@ -FROM golang:1.22.6 as build +FROM golang:1.23.2 as build ARG TOUCH_PROTOS COPY . /src/vali WORKDIR /src/vali RUN make clean && (if [ "${TOUCH_PROTOS}" ]; then make touch-protos; fi) && make BUILD_IN_CONTAINER=false logcli -FROM alpine:3.20.2 +FROM alpine:3.20.3 RUN apk add --no-cache ca-certificates diff --git a/cmd/migrate/Dockerfile b/cmd/migrate/Dockerfile index d6968e14..edbfc3ec 100644 --- a/cmd/migrate/Dockerfile +++ b/cmd/migrate/Dockerfile @@ -1,9 +1,9 @@ -FROM golang:1.22.6 as build +FROM golang:1.23.2 as build COPY . /src/vali WORKDIR /src/vali RUN make clean && make BUILD_IN_CONTAINER=false migrate -FROM alpine:3.20.2 +FROM alpine:3.20.3 RUN apk add --update --no-cache ca-certificates COPY --from=build /src/vali/cmd/migrate/migrate /usr/bin/migrate #ENTRYPOINT [ "/usr/bin/migrate" ] diff --git a/cmd/querytee/Dockerfile b/cmd/querytee/Dockerfile index 9a8ade01..5b126654 100644 --- a/cmd/querytee/Dockerfile +++ b/cmd/querytee/Dockerfile @@ -1,11 +1,11 @@ -FROM golang:1.22.6 as build +FROM golang:1.23.2 as build ARG TOUCH_PROTOS COPY . /src/vali WORKDIR /src/vali RUN make clean && make BUILD_IN_CONTAINER=false vali-querytee -FROM alpine:3.20.2 +FROM alpine:3.20.3 RUN apk add --update --no-cache ca-certificates COPY --from=build /src/vali/cmd/querytee/vali-querytee /usr/bin/querytee ENTRYPOINT [ "/usr/bin/querytee" ] diff --git a/cmd/querytee/Dockerfile.cross b/cmd/querytee/Dockerfile.cross index 653d65c1..af1d1fad 100644 --- a/cmd/querytee/Dockerfile.cross +++ b/cmd/querytee/Dockerfile.cross @@ -2,7 +2,7 @@ ARG BUILD_IMAGE=ghcr.io/credativ/vali-build-image:0.9.1 # Directories in this file are referenced from the root of the project not this folder # This file is intended to be called from the root like so: # docker build -t ghcr.io/credativ/valitail -f cmd/valitail/Dockerfile . -FROM golang:1.22.6-alpine as goenv +FROM golang:1.23.2-alpine as goenv RUN go env GOARCH > /goarch && \ go env GOARM > /goarm @@ -12,7 +12,7 @@ COPY . /src/vali WORKDIR /src/vali RUN make clean && GOARCH=$(cat /goarch) GOARM=$(cat /goarm) make BUILD_IN_CONTAINER=false vali-querytee -FROM alpine:3.20.2 +FROM alpine:3.20.3 RUN apk add --update --no-cache ca-certificates COPY --from=build /src/vali/cmd/querytee/querytee /usr/bin/querytee ENTRYPOINT [ "/usr/bin/querytee" ] diff --git a/cmd/vali-canary/Dockerfile b/cmd/vali-canary/Dockerfile index 550bacf7..c6a6c1f0 100644 --- a/cmd/vali-canary/Dockerfile +++ b/cmd/vali-canary/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.22.6 as build +FROM golang:1.23.2 as build # TOUCH_PROTOS signifies if we should touch the compiled proto files and thus not regenerate them. # This is helpful when file system timestamps can't be trusted with make ARG TOUCH_PROTOS @@ -6,7 +6,7 @@ COPY . /src/vali WORKDIR /src/vali RUN make clean && (if [ "${TOUCH_PROTOS}" ]; then make touch-protos; fi) && make BUILD_IN_CONTAINER=false vali-canary -FROM alpine:3.20.2 +FROM alpine:3.20.3 RUN apk add --update --no-cache ca-certificates COPY --from=build /src/vali/cmd/vali-canary/vali-canary /usr/bin/vali-canary ENTRYPOINT [ "/usr/bin/vali-canary" ] diff --git a/cmd/vali-canary/Dockerfile.cross b/cmd/vali-canary/Dockerfile.cross index 8bbdeea2..8d5bb8c2 100644 --- a/cmd/vali-canary/Dockerfile.cross +++ b/cmd/vali-canary/Dockerfile.cross @@ -2,7 +2,7 @@ ARG BUILD_IMAGE=ghcr.io/credativ/vali-build-image:0.12.0 # Directories in this file are referenced from the root of the project not this folder # This file is intended to be called from the root like so: # docker build -t ghcr.io/credativ/valitail -f cmd/valitail/Dockerfile . -FROM golang:1.22.6-alpine as goenv +FROM golang:1.23.2-alpine as goenv RUN go env GOARCH > /goarch && \ go env GOARM > /goarm @@ -12,7 +12,7 @@ COPY . /src/vali WORKDIR /src/vali RUN make clean && GOARCH=$(cat /goarch) GOARM=$(cat /goarm) make BUILD_IN_CONTAINER=false vali-canary -FROM alpine:3.20.2 +FROM alpine:3.20.3 RUN apk add --update --no-cache ca-certificates COPY --from=build /src/vali/cmd/vali-canary/vali-canary /usr/bin/vali-canary ENTRYPOINT [ "/usr/bin/vali-canary" ] diff --git a/cmd/vali/Dockerfile b/cmd/vali/Dockerfile index 9b54aa2c..48afbc9b 100644 --- a/cmd/vali/Dockerfile +++ b/cmd/vali/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.22.6 as build +FROM golang:1.23.2 as build # TOUCH_PROTOS signifies if we should touch the compiled proto files and thus not regenerate them. # This is helpful when file system timestamps can't be trusted with make ARG TOUCH_PROTOS @@ -6,7 +6,7 @@ COPY . /src/vali WORKDIR /src/vali RUN make clean && (if [ "${TOUCH_PROTOS}" ]; then make touch-protos; fi) && make BUILD_IN_CONTAINER=false vali -FROM alpine:3.20.2 +FROM alpine:3.20.3 RUN apk add --no-cache ca-certificates libcap diff --git a/cmd/vali/Dockerfile.cross b/cmd/vali/Dockerfile.cross index 6364b56c..e07c1793 100644 --- a/cmd/vali/Dockerfile.cross +++ b/cmd/vali/Dockerfile.cross @@ -2,7 +2,7 @@ ARG BUILD_IMAGE=ghcr.io/credativ/vali-build-image:0.12.0 # Directories in this file are referenced from the root of the project not this folder # This file is intended to be called from the root like so: # docker build -t ghcr.io/credativ/vali -f cmd/vali/Dockerfile . -FROM golang:1.22.6-alpine as goenv +FROM golang:1.23.2-alpine as goenv RUN go env GOARCH > /goarch && \ go env GOARM > /goarm @@ -12,7 +12,7 @@ COPY . /src/vali WORKDIR /src/vali RUN make clean && GOARCH=$(cat /goarch) GOARM=$(cat /goarm) make BUILD_IN_CONTAINER=false vali -FROM alpine:3.20.2 +FROM alpine:3.20.3 RUN apk add --no-cache ca-certificates diff --git a/cmd/vali/Dockerfile.debug b/cmd/vali/Dockerfile.debug index 751d0da7..fd6a2f2a 100644 --- a/cmd/vali/Dockerfile.debug +++ b/cmd/vali/Dockerfile.debug @@ -8,7 +8,7 @@ COPY . /src/vali WORKDIR /src/vali RUN make clean && make BUILD_IN_CONTAINER=false vali-debug -FROM alpine:3.20.2 +FROM alpine:3.20.3 RUN apk add --update --no-cache ca-certificates COPY --from=build /src/vali/cmd/vali/vali-debug /usr/bin/vali-debug COPY --from=build /go/bin/dlv /usr/bin/dlv diff --git a/cmd/valitail/Dockerfile b/cmd/valitail/Dockerfile index 98dc1e5d..0bbdb74b 100644 --- a/cmd/valitail/Dockerfile +++ b/cmd/valitail/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.22.6-bookworm as build +FROM golang:1.23.2-bookworm as build # TOUCH_PROTOS signifies if we should touch the compiled proto files and thus not regenerate them. # This is helpful when file system timestamps can't be trusted with make ARG TOUCH_PROTOS diff --git a/cmd/valitail/Dockerfile.arm32 b/cmd/valitail/Dockerfile.arm32 index 7590595b..c7799f03 100644 --- a/cmd/valitail/Dockerfile.arm32 +++ b/cmd/valitail/Dockerfile.arm32 @@ -1,4 +1,4 @@ -FROM golang:1.20.5 as build +FROM golang:1.23.2 as build # TOUCH_PROTOS signifies if we should touch the compiled proto files and thus not regenerate them. # This is helpful when file system timestamps can't be trusted with make ARG TOUCH_PROTOS diff --git a/cmd/valitail/Dockerfile.cross b/cmd/valitail/Dockerfile.cross index 8ab9274b..4412c6cf 100644 --- a/cmd/valitail/Dockerfile.cross +++ b/cmd/valitail/Dockerfile.cross @@ -2,7 +2,7 @@ ARG BUILD_IMAGE=ghcr.io/credativ/vali-build-image:0.12.0 # Directories in this file are referenced from the root of the project not this folder # This file is intended to be called from the root like so: # docker build -t ghcr.io/credativ/valitail -f cmd/valitail/Dockerfile . -FROM golang:1.22.6-alpine as goenv +FROM golang:1.23.2-alpine as goenv RUN go env GOARCH > /goarch && \ go env GOARM > /goarm diff --git a/cmd/valitail/Dockerfile.debug b/cmd/valitail/Dockerfile.debug index 4d27d871..1fb93d32 100644 --- a/cmd/valitail/Dockerfile.debug +++ b/cmd/valitail/Dockerfile.debug @@ -9,7 +9,7 @@ WORKDIR /src/vali RUN make clean && make BUILD_IN_CONTAINER=false valitail-debug -FROM alpine:3.20.2 +FROM alpine:3.20.3 RUN apk add --update --no-cache ca-certificates tzdata COPY --from=build /src/vali/cmd/valitail/valitail-debug /usr/bin/valitail-debug COPY --from=build /go/bin/dlv /usr/bin/dlv diff --git a/pkg/ingester/instance.go b/pkg/ingester/instance.go index 62a5bc0c..39baebef 100644 --- a/pkg/ingester/instance.go +++ b/pkg/ingester/instance.go @@ -233,7 +233,7 @@ func (i *instance) getOrCreateStream(pushReqStream logproto.Stream, lock bool, r "stream", pushReqStream.Labels, ) } - return nil, httpgrpc.Errorf(http.StatusBadRequest, err.Error()) + return nil, httpgrpc.Errorf(http.StatusBadRequest, "%s", err.Error()) } fp := i.getHashForLabels(labels) diff --git a/pkg/ingester/stream.go b/pkg/ingester/stream.go index 20d67b60..0d71c617 100644 --- a/pkg/ingester/stream.go +++ b/pkg/ingester/stream.go @@ -269,7 +269,7 @@ func (s *stream) Push( fmt.Fprintf(&buf, "total ignored: %d out of %d", len(failedEntriesWithError), len(entries)) - return bytesAdded, httpgrpc.Errorf(http.StatusBadRequest, buf.String()) + return bytesAdded, httpgrpc.Errorf(http.StatusBadRequest, "%s", buf.String()) } return bytesAdded, lastEntryWithErr.e } diff --git a/pkg/ingester/stream_test.go b/pkg/ingester/stream_test.go index 9b8b1a6c..17a9c5ff 100644 --- a/pkg/ingester/stream_test.go +++ b/pkg/ingester/stream_test.go @@ -63,7 +63,7 @@ func TestMaxReturnedStreamsErrors(t *testing.T) { } fmt.Fprintf(&expected, "total ignored: %d out of %d", numLogs, numLogs) - expectErr := httpgrpc.Errorf(http.StatusBadRequest, expected.String()) + expectErr := httpgrpc.Errorf(http.StatusBadRequest, "%s", expected.String()) _, err = s.Push(context.Background(), newLines, recordPool.GetRecord()) require.Error(t, err) diff --git a/pkg/logentry/stages/match.go b/pkg/logentry/stages/match.go index cb31e87b..d59aec5e 100644 --- a/pkg/logentry/stages/match.go +++ b/pkg/logentry/stages/match.go @@ -55,10 +55,10 @@ func validateMatcherConfig(cfg *MatcherConfig) (logql.LogSelectorExpr, error) { return nil, errors.New(ErrUnknownMatchAction) } - if cfg.Action == MatchActionKeep && (cfg.Stages == nil || len(cfg.Stages) == 0) { + if cfg.Action == MatchActionKeep && len(cfg.Stages) == 0 { return nil, errors.New(ErrMatchRequiresStages) } - if cfg.Action == MatchActionDrop && (cfg.Stages != nil && len(cfg.Stages) != 0) { + if cfg.Action == MatchActionDrop && len(cfg.Stages) != 0 { return nil, errors.New(ErrStagesWithDropLine) } diff --git a/pkg/logql/engine.go b/pkg/logql/engine.go index 994d0868..e33b8950 100644 --- a/pkg/logql/engine.go +++ b/pkg/logql/engine.go @@ -290,6 +290,7 @@ func (q *query) evalSample(ctx context.Context, expr SampleExpr) (promql_parser. return result, stepEvaluator.Error() } +// nolint: unparam func (q *query) evalLiteral(_ context.Context, expr *literalExpr) (promql_parser.Value, error) { s := promql.Scalar{ T: q.params.Start().UnixNano() / int64(time.Millisecond), diff --git a/pkg/logql/log/jsonexpr/lexer.go b/pkg/logql/log/jsonexpr/lexer.go index f92a72ef..5cf387d8 100644 --- a/pkg/logql/log/jsonexpr/lexer.go +++ b/pkg/logql/log/jsonexpr/lexer.go @@ -23,7 +23,7 @@ func NewScanner(r io.Reader, debug bool) *Scanner { } func (sc *Scanner) Error(s string) { - sc.err = fmt.Errorf(s) + sc.err = fmt.Errorf("%s", s) fmt.Printf("syntax error: %s\n", s) } @@ -53,7 +53,7 @@ func (sc *Scanner) lex(lval *JSONExprSymType) int { sc.unread() val, err := sc.scanInt() if err != nil { - sc.err = fmt.Errorf(err.Error()) + sc.err = fmt.Errorf("%s", err.Error()) return 0 } diff --git a/pkg/querier/http.go b/pkg/querier/http.go index 4b183ab1..89285dba 100644 --- a/pkg/querier/http.go +++ b/pkg/querier/http.go @@ -38,7 +38,7 @@ func (q *Querier) RangeQueryHandler(w http.ResponseWriter, r *http.Request) { request, err := loghttp.ParseRangeQuery(r) if err != nil { - serverutil.WriteError(httpgrpc.Errorf(http.StatusBadRequest, err.Error()), w) + serverutil.WriteError(httpgrpc.Errorf(http.StatusBadRequest, "%s", err.Error()), w) return } @@ -78,7 +78,7 @@ func (q *Querier) InstantQueryHandler(w http.ResponseWriter, r *http.Request) { request, err := loghttp.ParseInstantQuery(r) if err != nil { - serverutil.WriteError(httpgrpc.Errorf(http.StatusBadRequest, err.Error()), w) + serverutil.WriteError(httpgrpc.Errorf(http.StatusBadRequest, "%s", err.Error()), w) return } @@ -118,12 +118,12 @@ func (q *Querier) LogQueryHandler(w http.ResponseWriter, r *http.Request) { request, err := loghttp.ParseRangeQuery(r) if err != nil { - serverutil.WriteError(httpgrpc.Errorf(http.StatusBadRequest, err.Error()), w) + serverutil.WriteError(httpgrpc.Errorf(http.StatusBadRequest, "%s", err.Error()), w) return } request.Query, err = parseRegexQuery(r) if err != nil { - serverutil.WriteError(httpgrpc.Errorf(http.StatusBadRequest, err.Error()), w) + serverutil.WriteError(httpgrpc.Errorf(http.StatusBadRequest, "%s", err.Error()), w) return } @@ -172,7 +172,7 @@ func (q *Querier) LogQueryHandler(w http.ResponseWriter, r *http.Request) { func (q *Querier) LabelHandler(w http.ResponseWriter, r *http.Request) { req, err := loghttp.ParseLabelQuery(r) if err != nil { - serverutil.WriteError(httpgrpc.Errorf(http.StatusBadRequest, err.Error()), w) + serverutil.WriteError(httpgrpc.Errorf(http.StatusBadRequest, "%s", err.Error()), w) return } @@ -202,13 +202,13 @@ func (q *Querier) TailHandler(w http.ResponseWriter, r *http.Request) { req, err := loghttp.ParseTailQuery(r) if err != nil { - serverutil.WriteError(httpgrpc.Errorf(http.StatusBadRequest, err.Error()), w) + serverutil.WriteError(httpgrpc.Errorf(http.StatusBadRequest, "%s", err.Error()), w) return } req.Query, err = parseRegexQuery(r) if err != nil { - serverutil.WriteError(httpgrpc.Errorf(http.StatusBadRequest, err.Error()), w) + serverutil.WriteError(httpgrpc.Errorf(http.StatusBadRequest, "%s", err.Error()), w) return } @@ -309,7 +309,7 @@ func (q *Querier) TailHandler(w http.ResponseWriter, r *http.Request) { func (q *Querier) SeriesHandler(w http.ResponseWriter, r *http.Request) { req, err := loghttp.ParseSeriesQuery(r) if err != nil { - serverutil.WriteError(httpgrpc.Errorf(http.StatusBadRequest, err.Error()), w) + serverutil.WriteError(httpgrpc.Errorf(http.StatusBadRequest, "%s", err.Error()), w) return } @@ -348,7 +348,7 @@ func parseRegexQuery(httpRequest *http.Request) (string, error) { func (q *Querier) validateEntriesLimits(ctx context.Context, query string, limit uint32) error { userID, err := user.ExtractOrgID(ctx) if err != nil { - return httpgrpc.Errorf(http.StatusBadRequest, err.Error()) + return httpgrpc.Errorf(http.StatusBadRequest, "%s", err.Error()) } expr, err := logql.ParseExpr(query) diff --git a/pkg/querier/queryrange/codec.go b/pkg/querier/queryrange/codec.go index 073f7410..b82858cb 100644 --- a/pkg/querier/queryrange/codec.go +++ b/pkg/querier/queryrange/codec.go @@ -151,14 +151,14 @@ func (*ValiLabelNamesRequest) GetCachingOptions() (res queryrange.CachingOptions func (codec) DecodeRequest(_ context.Context, r *http.Request) (queryrange.Request, error) { if err := r.ParseForm(); err != nil { - return nil, httpgrpc.Errorf(http.StatusBadRequest, err.Error()) + return nil, httpgrpc.Errorf(http.StatusBadRequest, "%s", err.Error()) } switch op := getOperation(r.URL.Path); op { case QueryRangeOp: req, err := loghttp.ParseRangeQuery(r) if err != nil { - return nil, httpgrpc.Errorf(http.StatusBadRequest, err.Error()) + return nil, httpgrpc.Errorf(http.StatusBadRequest, "%s", err.Error()) } return &ValiRequest{ Query: req.Query, @@ -174,7 +174,7 @@ func (codec) DecodeRequest(_ context.Context, r *http.Request) (queryrange.Reque case SeriesOp: req, err := loghttp.ParseSeriesQuery(r) if err != nil { - return nil, httpgrpc.Errorf(http.StatusBadRequest, err.Error()) + return nil, httpgrpc.Errorf(http.StatusBadRequest, "%s", err.Error()) } return &ValiSeriesRequest{ Match: req.Groups, @@ -185,7 +185,7 @@ func (codec) DecodeRequest(_ context.Context, r *http.Request) (queryrange.Reque case LabelNamesOp: req, err := loghttp.ParseLabelQuery(r) if err != nil { - return nil, httpgrpc.Errorf(http.StatusBadRequest, err.Error()) + return nil, httpgrpc.Errorf(http.StatusBadRequest, "%s", err.Error()) } return &ValiLabelNamesRequest{ StartTs: *req.Start, @@ -193,7 +193,7 @@ func (codec) DecodeRequest(_ context.Context, r *http.Request) (queryrange.Reque Path: r.URL.Path, }, nil default: - return nil, httpgrpc.Errorf(http.StatusBadRequest, fmt.Sprintf("unknown request path: %s", r.URL.Path)) + return nil, httpgrpc.Errorf(http.StatusBadRequest, "unknown request path: %s", r.URL.Path) } } @@ -273,7 +273,7 @@ func (codec) EncodeRequest(ctx context.Context, r queryrange.Request) (*http.Req func (codec) DecodeResponse(ctx context.Context, r *http.Response, req queryrange.Request) (queryrange.Response, error) { if r.StatusCode/100 != 2 { body, _ := ioutil.ReadAll(r.Body) - return nil, httpgrpc.Errorf(r.StatusCode, string(body)) + return nil, httpgrpc.Errorf(r.StatusCode, "%s", string(body)) } sp, _ := opentracing.StartSpanFromContext(ctx, "codec.DecodeResponse") diff --git a/pkg/querier/queryrange/limits.go b/pkg/querier/queryrange/limits.go index 49a58e96..c1b05ac5 100644 --- a/pkg/querier/queryrange/limits.go +++ b/pkg/querier/queryrange/limits.go @@ -206,7 +206,7 @@ func (rt limitedRoundTripper) RoundTrip(r *http.Request) (*http.Response, error) } userid, err := user.ExtractOrgID(ctx) if err != nil { - return nil, httpgrpc.Errorf(http.StatusBadRequest, err.Error()) + return nil, httpgrpc.Errorf(http.StatusBadRequest, "%s", err.Error()) } parallelism := rt.limits.MaxQueryParallelism(userid) @@ -255,7 +255,7 @@ func (rt limitedRoundTripper) do(ctx context.Context, r queryrange.Request) (que } if err := user.InjectOrgIDIntoHTTPRequest(ctx, request); err != nil { - return nil, httpgrpc.Errorf(http.StatusBadRequest, err.Error()) + return nil, httpgrpc.Errorf(http.StatusBadRequest, "%s", err.Error()) } response, err := rt.next.RoundTrip(request) diff --git a/pkg/querier/queryrange/roundtrip.go b/pkg/querier/queryrange/roundtrip.go index d944c8ec..e3175579 100644 --- a/pkg/querier/queryrange/roundtrip.go +++ b/pkg/querier/queryrange/roundtrip.go @@ -107,18 +107,18 @@ func newRoundTripper(next, log, metric, series, labels http.RoundTripper, limits func (r roundTripper) RoundTrip(req *http.Request) (*http.Response, error) { err := req.ParseForm() if err != nil { - return nil, httpgrpc.Errorf(http.StatusBadRequest, err.Error()) + return nil, httpgrpc.Errorf(http.StatusBadRequest, "%s", err.Error()) } switch op := getOperation(req.URL.Path); op { case QueryRangeOp: rangeQuery, err := loghttp.ParseRangeQuery(req) if err != nil { - return nil, httpgrpc.Errorf(http.StatusBadRequest, err.Error()) + return nil, httpgrpc.Errorf(http.StatusBadRequest, "%s", err.Error()) } expr, err := logql.ParseExpr(rangeQuery.Query) if err != nil { - return nil, httpgrpc.Errorf(http.StatusBadRequest, err.Error()) + return nil, httpgrpc.Errorf(http.StatusBadRequest, "%s", err.Error()) } switch e := expr.(type) { case logql.SampleExpr: @@ -126,7 +126,7 @@ func (r roundTripper) RoundTrip(req *http.Request) (*http.Response, error) { case logql.LogSelectorExpr: expr, err := transformRegexQuery(req, e) if err != nil { - return nil, httpgrpc.Errorf(http.StatusBadRequest, err.Error()) + return nil, httpgrpc.Errorf(http.StatusBadRequest, "%s", err.Error()) } if err := validateLimits(req, rangeQuery.Limit, r.limits); err != nil { return nil, err @@ -142,13 +142,13 @@ func (r roundTripper) RoundTrip(req *http.Request) (*http.Response, error) { case SeriesOp: _, err := loghttp.ParseSeriesQuery(req) if err != nil { - return nil, httpgrpc.Errorf(http.StatusBadRequest, err.Error()) + return nil, httpgrpc.Errorf(http.StatusBadRequest, "%s", err.Error()) } return r.series.RoundTrip(req) case LabelNamesOp: _, err := loghttp.ParseLabelQuery(req) if err != nil { - return nil, httpgrpc.Errorf(http.StatusBadRequest, err.Error()) + return nil, httpgrpc.Errorf(http.StatusBadRequest, "%s", err.Error()) } return r.labels.RoundTrip(req) default: @@ -179,7 +179,7 @@ func transformRegexQuery(req *http.Request, expr logql.LogSelectorExpr) (logql.L func validateLimits(req *http.Request, reqLimit uint32, limits Limits) error { userID, err := user.ExtractOrgID(req.Context()) if err != nil { - return httpgrpc.Errorf(http.StatusBadRequest, err.Error()) + return httpgrpc.Errorf(http.StatusBadRequest, "%s", err.Error()) } maxEntriesLimit := limits.MaxEntriesLimitPerQuery(userID) diff --git a/pkg/querier/queryrange/split_by_interval.go b/pkg/querier/queryrange/split_by_interval.go index 3feeb213..af2e5cac 100644 --- a/pkg/querier/queryrange/split_by_interval.go +++ b/pkg/querier/queryrange/split_by_interval.go @@ -161,7 +161,7 @@ func (h *splitByInterval) loop(ctx context.Context, ch <-chan *valiResult, next func (h *splitByInterval) Do(ctx context.Context, r queryrange.Request) (queryrange.Response, error) { userid, err := user.ExtractOrgID(ctx) if err != nil { - return nil, httpgrpc.Errorf(http.StatusBadRequest, err.Error()) + return nil, httpgrpc.Errorf(http.StatusBadRequest, "%s", err.Error()) } interval := h.limits.QuerySplitDuration(userid) diff --git a/pkg/util/server/error_test.go b/pkg/util/server/error_test.go index cd9ffc4c..61d6e351 100644 --- a/pkg/util/server/error_test.go +++ b/pkg/util/server/error_test.go @@ -33,7 +33,7 @@ func Test_writeError(t *testing.T) { {"orgid", user.ErrNoOrgID, user.ErrNoOrgID.Error(), http.StatusBadRequest}, {"deadline", context.DeadlineExceeded, ErrDeadlineExceeded, http.StatusGatewayTimeout}, {"parse error", logql.ParseError{}, "parse error : ", http.StatusBadRequest}, - {"httpgrpc", httpgrpc.Errorf(http.StatusBadRequest, errors.New("foo").Error()), "foo", http.StatusBadRequest}, + {"httpgrpc", httpgrpc.Errorf(http.StatusBadRequest, "%s", errors.New("foo").Error()), "foo", http.StatusBadRequest}, {"internal", errors.New("foo"), "foo", http.StatusInternalServerError}, {"query error", chunk.ErrQueryMustContainMetricName, chunk.ErrQueryMustContainMetricName.Error(), http.StatusBadRequest}, {"wrapped query error", fmt.Errorf("wrapped: %w", chunk.ErrQueryMustContainMetricName), "wrapped: " + chunk.ErrQueryMustContainMetricName.Error(), http.StatusBadRequest}, diff --git a/pkg/util/server/middleware.go b/pkg/util/server/middleware.go index 6131e11a..a1072d51 100644 --- a/pkg/util/server/middleware.go +++ b/pkg/util/server/middleware.go @@ -14,7 +14,7 @@ func NewPrepopulateMiddleware() middleware.Interface { return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { err := req.ParseForm() if err != nil { - WriteError(httpgrpc.Errorf(http.StatusBadRequest, err.Error()), w) + WriteError(httpgrpc.Errorf(http.StatusBadRequest, "%s", err.Error()), w) return } diff --git a/vali-build-image/Dockerfile b/vali-build-image/Dockerfile index 2978aa15..a457c838 100644 --- a/vali-build-image/Dockerfile +++ b/vali-build-image/Dockerfile @@ -20,10 +20,10 @@ RUN apk add --no-cache docker-cli # Error: # github.com/fatih/faillint@v1.5.0 requires golang.org/x/tools@v0.0.0-20200207224406-61798d64f025 # (not golang.org/x/tools@v0.0.0-20190918214920-58d531046acd from golang.org/x/tools/cmd/goyacc@58d531046acdc757f177387bc1725bfa79895d69) -FROM docker.io/library/golang:1.22.6 as faillint -RUN go install github.com/fatih/faillint@v1.11.0 +FROM docker.io/library/golang:1.23.2 as faillint +RUN go install github.com/fatih/faillint@v1.14.0 -FROM docker.io/library/golang:1.22.6-bookworm +FROM docker.io/library/golang:1.23.2-bookworm RUN apt-get update && \ apt-get install -qy \ musl gnupg \