From 6f76a965f248fc987bd2488f4a38b72b9641b794 Mon Sep 17 00:00:00 2001 From: Dylan Guedes Date: Fri, 24 Feb 2023 12:41:47 -0300 Subject: [PATCH] [release-2.7.x] Use 0.28.1 build image and update go and alpine versions (#8583) (#8623) (cherry picked from commit 4f8d3240f6ba1d203f4713fe4a7afe109bdb8ee1) --------- Co-authored-by: Michel Hollands <42814411+MichelHollands@users.noreply.github.com> --- .drone/drone.yml | 36 +++++++++---------- .golangci.yml | 2 +- CHANGELOG.md | 9 ++++- Makefile | 2 +- clients/cmd/docker-driver/Dockerfile | 4 +-- clients/cmd/promtail/Dockerfile | 2 +- clients/cmd/promtail/Dockerfile.arm32 | 2 +- clients/cmd/promtail/Dockerfile.cross | 4 +-- clients/cmd/promtail/Dockerfile.debug | 4 +-- clients/pkg/promtail/promtail_test.go | 7 ++-- .../promtail/targets/testutils/testutils.go | 6 ++-- cmd/logcli/Dockerfile | 4 +-- cmd/logql-analyzer/Dockerfile | 6 ++-- cmd/loki-canary/Dockerfile | 4 +-- cmd/loki-canary/Dockerfile.cross | 6 ++-- cmd/loki/Dockerfile | 7 ++-- cmd/loki/Dockerfile.cross | 9 ++--- cmd/loki/Dockerfile.debug | 5 ++- cmd/migrate/Dockerfile | 4 +-- cmd/querytee/Dockerfile | 4 +-- cmd/querytee/Dockerfile.cross | 6 ++-- go.mod | 2 +- go.sum | 4 +-- integration/shared_test.go | 6 ++-- operator/Dockerfile.cross | 2 +- pkg/canary/comparator/comparator.go | 4 +-- pkg/chunkenc/memchunk_test.go | 21 ++++++----- pkg/logql/engine_test.go | 4 +-- pkg/util/metrics_helper_test.go | 10 +++--- production/helm/loki/README.md | 2 +- production/helm/loki/README.md.gotmpl | 2 +- production/helm/loki/src/helm-test/Dockerfile | 4 +-- .../dev/loki-boltdb-storage-s3/dev.dockerfile | 4 +-- tools/lambda-promtail/Dockerfile | 4 +-- .../assume-no-moving-gc.go | 14 +++++++- .../unsafe/assume-no-moving-gc/untested.go | 6 ++-- vendor/modules.txt | 2 +- 37 files changed, 118 insertions(+), 106 deletions(-) diff --git a/.drone/drone.yml b/.drone/drone.yml index 80d1e99a5287b..2f5fb9c41fc4d 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -93,14 +93,14 @@ steps: depends_on: - clone environment: {} - image: grafana/loki-build-image:0.27.1 + image: grafana/loki-build-image:0.28.1 name: check-drone-drift - commands: - make BUILD_IN_CONTAINER=false check-generated-files depends_on: - clone environment: {} - image: grafana/loki-build-image:0.27.1 + image: grafana/loki-build-image:0.28.1 name: check-generated-files - commands: - cd .. @@ -109,7 +109,7 @@ steps: depends_on: - clone environment: {} - image: grafana/loki-build-image:0.27.1 + image: grafana/loki-build-image:0.28.1 name: clone-main - commands: - make BUILD_IN_CONTAINER=false test @@ -117,7 +117,7 @@ steps: - clone - clone-main environment: {} - image: grafana/loki-build-image:0.27.1 + image: grafana/loki-build-image:0.28.1 name: test - commands: - cd ../loki-main @@ -125,7 +125,7 @@ steps: depends_on: - clone-main environment: {} - image: grafana/loki-build-image:0.27.1 + image: grafana/loki-build-image:0.28.1 name: test-main - commands: - make BUILD_IN_CONTAINER=false compare-coverage old=../loki-main/test_results.txt @@ -135,7 +135,7 @@ steps: - test - test-main environment: {} - image: grafana/loki-build-image:0.27.1 + image: grafana/loki-build-image:0.28.1 name: compare-coverage - commands: - pull=$(echo $CI_COMMIT_REF | awk -F '/' '{print $3}') @@ -148,7 +148,7 @@ steps: TOKEN: from_secret: github_token USER: grafanabot - image: grafana/loki-build-image:0.27.1 + image: grafana/loki-build-image:0.28.1 name: report-coverage - commands: - make BUILD_IN_CONTAINER=false lint @@ -156,7 +156,7 @@ steps: - clone - check-generated-files environment: {} - image: grafana/loki-build-image:0.27.1 + image: grafana/loki-build-image:0.28.1 name: lint - commands: - make BUILD_IN_CONTAINER=false check-mod @@ -165,7 +165,7 @@ steps: - test - lint environment: {} - image: grafana/loki-build-image:0.27.1 + image: grafana/loki-build-image:0.28.1 name: check-mod - commands: - apk add make bash && make lint-scripts @@ -177,21 +177,21 @@ steps: - clone - check-generated-files environment: {} - image: grafana/loki-build-image:0.27.1 + image: grafana/loki-build-image:0.28.1 name: loki - commands: - make BUILD_IN_CONTAINER=false validate-example-configs depends_on: - loki environment: {} - image: grafana/loki-build-image:0.27.1 + image: grafana/loki-build-image:0.28.1 name: validate-example-configs - commands: - make BUILD_IN_CONTAINER=false check-example-config-doc depends_on: - clone environment: {} - image: grafana/loki-build-image:0.27.1 + image: grafana/loki-build-image:0.28.1 name: check-example-config-doc trigger: ref: @@ -218,7 +218,7 @@ steps: depends_on: - clone environment: {} - image: grafana/loki-build-image:0.27.1 + image: grafana/loki-build-image:0.28.1 name: loki-mixin-check trigger: ref: @@ -238,7 +238,7 @@ steps: depends_on: - clone environment: {} - image: grafana/loki-build-image:0.27.1 + image: grafana/loki-build-image:0.28.1 name: documentation-helm-reference-check trigger: ref: @@ -1369,7 +1369,7 @@ steps: NFPM_SIGNING_KEY: from_secret: gpg_private_key NFPM_SIGNING_KEY_FILE: /drone/src/private-key.key - image: grafana/loki-build-image:0.27.1 + image: grafana/loki-build-image:0.28.1 name: write-key - commands: - make BUILD_IN_CONTAINER=false packages @@ -1377,7 +1377,7 @@ steps: NFPM_PASSPHRASE: from_secret: gpg_passphrase NFPM_SIGNING_KEY_FILE: /drone/src/private-key.key - image: grafana/loki-build-image:0.27.1 + image: grafana/loki-build-image:0.28.1 name: test packaging - commands: - ./tools/packaging/verify-deb-install.sh @@ -1403,7 +1403,7 @@ steps: NFPM_PASSPHRASE: from_secret: gpg_passphrase NFPM_SIGNING_KEY_FILE: /drone/src/private-key.key - image: grafana/loki-build-image:0.27.1 + image: grafana/loki-build-image:0.28.1 name: publish when: event: @@ -1648,6 +1648,6 @@ kind: secret name: gpg_private_key --- kind: signature -hmac: ec77034ab90d10b2a9f927372d9c4c4472b36f588966e54a26251b58dbabe89e +hmac: de666c125b41d3affaa6db91e0ef93c39bdf35b208cccc87bbf1fbd614380544 ... diff --git a/.golangci.yml b/.golangci.yml index c91154200a9a4..08340a16095e6 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -4,7 +4,7 @@ # options for analysis running run: # define go version - go: "1.19" + go: "1.20" # default concurrency is a available CPU number concurrency: 16 diff --git a/CHANGELOG.md b/CHANGELOG.md index 34002d2ae3788..f388a62ab43a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ ##### Changes +##### Build + #### Promtail ##### Enhancements @@ -28,7 +30,7 @@ ### Dependencies -## 2.7.4 (2023-02-23) +## 2.7.4 (2023-02-24) #### Loki @@ -39,6 +41,11 @@ * [7988](https://github.com/grafana/loki/pull/7988) **ashwanthgoli**: store: write overlapping chunks to multiple stores. * [7925](https://github.com/grafana/loki/pull/7925) **sandeepsukhani**: Fix bugs in logs results caching causing query-frontend to return logs outside of query window. +##### Build + +* [8575](https://github.com/grafana/loki/pull/8575) **MichelHollands**: Update build image to go 1.20.1 and alpine 3.16.4. +* [8583](https://github.com/grafana/loki/pull/8583) **MichelHollands**: Use 0.28.1 build image and update go and alpine versions. + #### Promtail ##### Enhancements diff --git a/Makefile b/Makefile index 27a31b7c46fc1..293d4c09a186c 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,7 @@ DOCKER_IMAGE_DIRS := $(patsubst %/Dockerfile,%,$(DOCKERFILES)) BUILD_IN_CONTAINER ?= true # ensure you run `make drone` after changing this -BUILD_IMAGE_VERSION := 0.27.1 +BUILD_IMAGE_VERSION := 0.28.1 # Docker image info IMAGE_PREFIX ?= grafana diff --git a/clients/cmd/docker-driver/Dockerfile b/clients/cmd/docker-driver/Dockerfile index 7309a39a20bcc..fd60286a6a57c 100644 --- a/clients/cmd/docker-driver/Dockerfile +++ b/clients/cmd/docker-driver/Dockerfile @@ -1,4 +1,4 @@ -ARG BUILD_IMAGE=grafana/loki-build-image:0.27.1 +ARG BUILD_IMAGE=grafana/loki-build-image:0.28.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 grafana/loki -f cmd/loki/Dockerfile . @@ -9,7 +9,7 @@ COPY . /src/loki WORKDIR /src/loki RUN make clean && make BUILD_IN_CONTAINER=false clients/cmd/docker-driver/docker-driver -FROM alpine:3.16.2 +FROM alpine:3.16.4 RUN apk add --update --no-cache ca-certificates tzdata COPY --from=build /src/loki/clients/cmd/docker-driver/docker-driver /bin/docker-driver WORKDIR /bin/ diff --git a/clients/cmd/promtail/Dockerfile b/clients/cmd/promtail/Dockerfile index 63053b33447f5..a3b3cb7180bbd 100644 --- a/clients/cmd/promtail/Dockerfile +++ b/clients/cmd/promtail/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.19.5-bullseye as build +FROM golang:1.20.1-bullseye as build COPY . /src/loki WORKDIR /src/loki diff --git a/clients/cmd/promtail/Dockerfile.arm32 b/clients/cmd/promtail/Dockerfile.arm32 index e98f250e786aa..bd32d8ab7d4ee 100644 --- a/clients/cmd/promtail/Dockerfile.arm32 +++ b/clients/cmd/promtail/Dockerfile.arm32 @@ -1,4 +1,4 @@ -FROM golang:1.19.5-bullseye as build +FROM golang:1.20.1-bullseye as build COPY . /src/loki WORKDIR /src/loki diff --git a/clients/cmd/promtail/Dockerfile.cross b/clients/cmd/promtail/Dockerfile.cross index fafff8cf04406..d279f87972b4b 100644 --- a/clients/cmd/promtail/Dockerfile.cross +++ b/clients/cmd/promtail/Dockerfile.cross @@ -1,8 +1,8 @@ -ARG BUILD_IMAGE=grafana/loki-build-image:0.27.1 +ARG BUILD_IMAGE=grafana/loki-build-image:0.28.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 grafana/promtail -f clients/cmd/promtail/Dockerfile . -FROM golang:1.19.5-alpine as goenv +FROM golang:1.20.1-alpine as goenv RUN go env GOARCH > /goarch && \ go env GOARM > /goarm diff --git a/clients/cmd/promtail/Dockerfile.debug b/clients/cmd/promtail/Dockerfile.debug index 6dc9ee647e091..f057e6afaf849 100644 --- a/clients/cmd/promtail/Dockerfile.debug +++ b/clients/cmd/promtail/Dockerfile.debug @@ -2,14 +2,14 @@ # This file is intended to be called from the root like so: # docker build -t grafana/promtail -f clients/cmd/promtail/Dockerfile.debug . -FROM grafana/loki-build-image:0.27.1 as build +FROM grafana/loki-build-image:0.28.1 as build ARG GOARCH="amd64" COPY . /src/loki WORKDIR /src/loki RUN make clean && make BUILD_IN_CONTAINER=false promtail-debug -FROM alpine:3.16.2 +FROM alpine:3.16.4 RUN apk add --update --no-cache ca-certificates tzdata COPY --from=build /src/loki/clients/cmd/promtail/promtail-debug /usr/bin/promtail-debug COPY --from=build /go/bin/dlv /usr/bin/dlv diff --git a/clients/pkg/promtail/promtail_test.go b/clients/pkg/promtail/promtail_test.go index 29bcd6cb1fd23..6dbad71bb6a69 100644 --- a/clients/pkg/promtail/promtail_test.go +++ b/clients/pkg/promtail/promtail_test.go @@ -39,6 +39,7 @@ import ( "github.com/grafana/loki/clients/pkg/promtail/server" pserver "github.com/grafana/loki/clients/pkg/promtail/server" file2 "github.com/grafana/loki/clients/pkg/promtail/targets/file" + "github.com/grafana/loki/clients/pkg/promtail/targets/testutils" "github.com/grafana/loki/pkg/logproto" "github.com/grafana/loki/pkg/util" @@ -54,7 +55,7 @@ func TestPromtail(t *testing.T) { logger = level.NewFilter(logger, level.AllowInfo()) util_log.Logger = logger - initRandom() + testutils.InitRandom() dirName := "/tmp/promtail_test_" + randName() positionsFileName := dirName + "/positions.yml" @@ -641,10 +642,6 @@ func buildTestConfig(t *testing.T, positionsFileName string, logDirName string) return cfg } -func initRandom() { - rand.Seed(time.Now().UnixNano()) -} - var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") func randName() string { diff --git a/clients/pkg/promtail/targets/testutils/testutils.go b/clients/pkg/promtail/targets/testutils/testutils.go index 41444769c28df..b88e87b323dd1 100644 --- a/clients/pkg/promtail/targets/testutils/testutils.go +++ b/clients/pkg/promtail/targets/testutils/testutils.go @@ -5,8 +5,10 @@ import ( "time" ) +var randomGenerator *rand.Rand + func InitRandom() { - rand.Seed(time.Now().UnixNano()) + randomGenerator = rand.New(rand.NewSource(time.Now().UnixNano())) } var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") @@ -14,7 +16,7 @@ var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") func RandName() string { b := make([]rune, 10) for i := range b { - b[i] = letters[rand.Intn(len(letters))] + b[i] = letters[randomGenerator.Intn(len(letters))] } return string(b) } diff --git a/cmd/logcli/Dockerfile b/cmd/logcli/Dockerfile index 117c0e15510b4..c959e9bce593d 100644 --- a/cmd/logcli/Dockerfile +++ b/cmd/logcli/Dockerfile @@ -1,10 +1,10 @@ -FROM golang:1.19.5 as build +FROM golang:1.20.1 as build COPY . /src/loki WORKDIR /src/loki RUN make clean && make BUILD_IN_CONTAINER=false logcli -FROM alpine:3.16.2 +FROM alpine:3.16.4 RUN apk add --no-cache ca-certificates diff --git a/cmd/logql-analyzer/Dockerfile b/cmd/logql-analyzer/Dockerfile index db6061ff1517f..a9593a51f21f4 100644 --- a/cmd/logql-analyzer/Dockerfile +++ b/cmd/logql-analyzer/Dockerfile @@ -1,13 +1,13 @@ -FROM golang:1.19.5 as build +FROM golang:1.20.1 as build COPY . /src/loki WORKDIR /src/loki RUN make clean && CGO_ENABLED=0 go build ./cmd/logql-analyzer/ -FROM alpine:3.15.4 +FROM alpine:3.16.4 RUN apk add --no-cache ca-certificates COPY --from=build /src/loki/logql-analyzer /usr/bin/logql-analyzer -ENTRYPOINT [ "/usr/bin/logql-analyzer" ] \ No newline at end of file +ENTRYPOINT [ "/usr/bin/logql-analyzer" ] diff --git a/cmd/loki-canary/Dockerfile b/cmd/loki-canary/Dockerfile index 9355ef305f702..8217f356c54fa 100644 --- a/cmd/loki-canary/Dockerfile +++ b/cmd/loki-canary/Dockerfile @@ -1,10 +1,10 @@ -FROM golang:1.19.5 as build +FROM golang:1.20.1 as build COPY . /src/loki WORKDIR /src/loki RUN make clean && make BUILD_IN_CONTAINER=false loki-canary -FROM alpine:3.16.2 +FROM alpine:3.16.4 RUN apk add --update --no-cache ca-certificates COPY --from=build /src/loki/cmd/loki-canary/loki-canary /usr/bin/loki-canary ENTRYPOINT [ "/usr/bin/loki-canary" ] diff --git a/cmd/loki-canary/Dockerfile.cross b/cmd/loki-canary/Dockerfile.cross index 1d5185abd3e20..305a8d1a3b3b3 100644 --- a/cmd/loki-canary/Dockerfile.cross +++ b/cmd/loki-canary/Dockerfile.cross @@ -1,8 +1,8 @@ -ARG BUILD_IMAGE=grafana/loki-build-image:0.27.1 +ARG BUILD_IMAGE=grafana/loki-build-image:0.28.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 grafana/promtail -f cmd/promtail/Dockerfile . -FROM golang:1.19.5-alpine as goenv +FROM golang:1.20.1-alpine as goenv RUN go env GOARCH > /goarch && \ go env GOARM > /goarm @@ -12,7 +12,7 @@ COPY . /src/loki WORKDIR /src/loki RUN make clean && GOARCH=$(cat /goarch) GOARM=$(cat /goarm) make BUILD_IN_CONTAINER=false loki-canary -FROM alpine:3.16.2 +FROM alpine:3.16.4 RUN apk add --update --no-cache ca-certificates COPY --from=build /src/loki/cmd/loki-canary/loki-canary /usr/bin/loki-canary ENTRYPOINT [ "/usr/bin/loki-canary" ] diff --git a/cmd/loki/Dockerfile b/cmd/loki/Dockerfile index 82c836cfa87bf..a063fafcee79d 100644 --- a/cmd/loki/Dockerfile +++ b/cmd/loki/Dockerfile @@ -1,10 +1,10 @@ -FROM golang:1.19.5 as build +FROM golang:1.20.1 as build COPY . /src/loki WORKDIR /src/loki RUN make clean && make BUILD_IN_CONTAINER=false loki -FROM alpine:3.16.2 +FROM alpine:3.16.4 RUN apk add --no-cache ca-certificates libcap @@ -17,9 +17,6 @@ RUN mkdir -p /loki/rules && \ mkdir -p /loki/rules-temp && \ chown -R loki:loki /etc/loki /loki -# See https://github.com/grafana/loki/issues/1928 -RUN [ ! -e /etc/nsswitch.conf ] && echo 'hosts: files dns' > /etc/nsswitch.conf - USER 10001 EXPOSE 3100 ENTRYPOINT [ "/usr/bin/loki" ] diff --git a/cmd/loki/Dockerfile.cross b/cmd/loki/Dockerfile.cross index 9168dbab5ea64..442c25cd760d1 100644 --- a/cmd/loki/Dockerfile.cross +++ b/cmd/loki/Dockerfile.cross @@ -1,8 +1,8 @@ -ARG BUILD_IMAGE=grafana/loki-build-image:0.27.1 +ARG BUILD_IMAGE=grafana/loki-build-image:0.28.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 grafana/loki -f cmd/loki/Dockerfile . -FROM golang:1.19.5-alpine as goenv +FROM golang:1.20.1-alpine as goenv RUN go env GOARCH > /goarch && \ go env GOARM > /goarm @@ -12,7 +12,7 @@ COPY . /src/loki WORKDIR /src/loki RUN make clean && GOARCH=$(cat /goarch) GOARM=$(cat /goarm) make BUILD_IN_CONTAINER=false loki -FROM alpine:3.16.2 +FROM alpine:3.16.4 RUN apk add --no-cache ca-certificates @@ -24,9 +24,6 @@ RUN addgroup -g 10001 -S loki && \ RUN mkdir -p /loki && \ chown -R loki:loki /etc/loki /loki -# See https://github.com/grafana/loki/issues/1928 -RUN [ ! -e /etc/nsswitch.conf ] && echo 'hosts: files dns' > /etc/nsswitch.conf - USER 10001 EXPOSE 3100 ENTRYPOINT [ "/usr/bin/loki" ] diff --git a/cmd/loki/Dockerfile.debug b/cmd/loki/Dockerfile.debug index e4ff4d60615d0..eae2b64bc6f31 100644 --- a/cmd/loki/Dockerfile.debug +++ b/cmd/loki/Dockerfile.debug @@ -1,14 +1,13 @@ # 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 grafana/loki -f cmd/loki/Dockerfile.debug . - -FROM grafana/loki-build-image:0.27.1 as build +FROM grafana/loki-build-image:0.28.1 as build ARG GOARCH="amd64" COPY . /src/loki WORKDIR /src/loki RUN make clean && make BUILD_IN_CONTAINER=false loki-debug -FROM alpine:3.16.2 +FROM alpine:3.16.4 RUN apk add --update --no-cache ca-certificates COPY --from=build /src/loki/cmd/loki/loki-debug /usr/bin/loki-debug COPY --from=build /usr/bin/dlv /usr/bin/dlv diff --git a/cmd/migrate/Dockerfile b/cmd/migrate/Dockerfile index a5e9d4a31f23f..3e04d019f7400 100644 --- a/cmd/migrate/Dockerfile +++ b/cmd/migrate/Dockerfile @@ -1,9 +1,9 @@ -FROM golang:1.19.5 as build +FROM golang:1.20.1 as build COPY . /src/loki WORKDIR /src/loki RUN make clean && make BUILD_IN_CONTAINER=false migrate -FROM alpine:3.16.2 +FROM alpine:3.16.4 RUN apk add --update --no-cache ca-certificates COPY --from=build /src/loki/cmd/migrate/migrate /usr/bin/migrate #ENTRYPOINT [ "/usr/bin/migrate" ] diff --git a/cmd/querytee/Dockerfile b/cmd/querytee/Dockerfile index e1e46d85fd5cd..20beb06da29a9 100644 --- a/cmd/querytee/Dockerfile +++ b/cmd/querytee/Dockerfile @@ -1,10 +1,10 @@ -FROM golang:1.19.5 as build +FROM golang:1.20.1 as build COPY . /src/loki WORKDIR /src/loki RUN make clean && make BUILD_IN_CONTAINER=false loki-querytee -FROM alpine:3.16.2 +FROM alpine:3.16.4 RUN apk add --update --no-cache ca-certificates COPY --from=build /src/loki/cmd/querytee/querytee /usr/bin/querytee ENTRYPOINT [ "/usr/bin/querytee" ] diff --git a/cmd/querytee/Dockerfile.cross b/cmd/querytee/Dockerfile.cross index 1992241475e9b..b3d29396657d3 100644 --- a/cmd/querytee/Dockerfile.cross +++ b/cmd/querytee/Dockerfile.cross @@ -1,8 +1,8 @@ -ARG BUILD_IMAGE=grafana/loki-build-image:0.27.1 +ARG BUILD_IMAGE=grafana/loki-build-image:0.28.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 grafana/promtail -f cmd/promtail/Dockerfile . -FROM golang:1.19.5-alpine as goenv +FROM golang:1.20.1-alpine as goenv RUN go env GOARCH > /goarch && \ go env GOARM > /goarm @@ -12,7 +12,7 @@ COPY . /src/loki WORKDIR /src/loki RUN make clean && GOARCH=$(cat /goarch) GOARM=$(cat /goarm) make BUILD_IN_CONTAINER=false loki-querytee -FROM alpine:3.16.2 +FROM alpine:3.16.4 RUN apk add --update --no-cache ca-certificates COPY --from=build /src/loki/cmd/querytee/querytee /usr/bin/querytee ENTRYPOINT [ "/usr/bin/querytee" ] diff --git a/go.mod b/go.mod index 724d02c087ae2..804d03533588f 100644 --- a/go.mod +++ b/go.mod @@ -272,7 +272,7 @@ require ( go.uber.org/multierr v1.8.0 // indirect go.uber.org/zap v1.21.0 // indirect go4.org/intern v0.0.0-20211027215823-ae77deb06f29 // indirect - go4.org/unsafe/assume-no-moving-gc v0.0.0-20220617031537-928513b29760 // indirect + go4.org/unsafe/assume-no-moving-gc v0.0.0-20230221090011-e4bae7ad2296 // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect golang.org/x/tools v0.1.12 // indirect diff --git a/go.sum b/go.sum index 40e0fa60c6c78..c7d960887ff8a 100644 --- a/go.sum +++ b/go.sum @@ -1449,8 +1449,8 @@ go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw= go4.org/intern v0.0.0-20211027215823-ae77deb06f29 h1:UXLjNohABv4S58tHmeuIZDO6e3mHpW2Dx33gaNt03LE= go4.org/intern v0.0.0-20211027215823-ae77deb06f29/go.mod h1:cS2ma+47FKrLPdXFpr7CuxiTW3eyJbWew4qx0qtQWDA= go4.org/unsafe/assume-no-moving-gc v0.0.0-20211027215541-db492cf91b37/go.mod h1:FftLjUGFEDu5k8lt0ddY+HcrH/qU/0qk+H8j9/nTl3E= -go4.org/unsafe/assume-no-moving-gc v0.0.0-20220617031537-928513b29760 h1:FyBZqvoA/jbNzuAWLQE2kG820zMAkcilx6BMjGbL/E4= -go4.org/unsafe/assume-no-moving-gc v0.0.0-20220617031537-928513b29760/go.mod h1:FftLjUGFEDu5k8lt0ddY+HcrH/qU/0qk+H8j9/nTl3E= +go4.org/unsafe/assume-no-moving-gc v0.0.0-20230221090011-e4bae7ad2296 h1:QJ/xcIANMLApehfgPCHnfK1hZiaMmbaTVmPv7DAoTbo= +go4.org/unsafe/assume-no-moving-gc v0.0.0-20230221090011-e4bae7ad2296/go.mod h1:FftLjUGFEDu5k8lt0ddY+HcrH/qU/0qk+H8j9/nTl3E= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= diff --git a/integration/shared_test.go b/integration/shared_test.go index 53fb7de15722e..61b469ecd0044 100644 --- a/integration/shared_test.go +++ b/integration/shared_test.go @@ -5,8 +5,10 @@ import ( "time" ) +var randomGenerator *rand.Rand + func init() { - rand.Seed(time.Now().UnixNano()) + randomGenerator = rand.New(rand.NewSource(time.Now().UnixNano())) } var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") @@ -14,7 +16,7 @@ var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") func randStringRunes() string { b := make([]rune, 12) for i := range b { - b[i] = letterRunes[rand.Intn(len(letterRunes))] + b[i] = letterRunes[randomGenerator.Intn(len(letterRunes))] } return string(b) } diff --git a/operator/Dockerfile.cross b/operator/Dockerfile.cross index 09d9cebe89d81..a06cb5f835992 100644 --- a/operator/Dockerfile.cross +++ b/operator/Dockerfile.cross @@ -1,4 +1,4 @@ -ARG BUILD_IMAGE=grafana/loki-build-image:0.27.1 +ARG BUILD_IMAGE=grafana/loki-build-image:0.28.1 FROM golang:1.19.1-alpine as goenv RUN go env GOARCH > /goarch && \ diff --git a/pkg/canary/comparator/comparator.go b/pkg/canary/comparator/comparator.go index f35fc024dd60e..de1e50c559d73 100644 --- a/pkg/canary/comparator/comparator.go +++ b/pkg/canary/comparator/comparator.go @@ -249,8 +249,8 @@ func (c *Comparator) run() { t := time.NewTicker(c.pruneInterval) // Use a random tick up to the interval for the first tick firstMt := true - rand.Seed(time.Now().UnixNano()) - mt := time.NewTicker(time.Duration(rand.Int63n(c.metricTestInterval.Nanoseconds()))) + randomGenerator := rand.New(rand.NewSource(time.Now().UnixNano())) + mt := time.NewTicker(time.Duration(randomGenerator.Int63n(c.metricTestInterval.Nanoseconds()))) sc := time.NewTicker(c.spotCheckQueryRate) defer func() { t.Stop() diff --git a/pkg/chunkenc/memchunk_test.go b/pkg/chunkenc/memchunk_test.go index 3ecea49eb6042..3b8d069fdd610 100644 --- a/pkg/chunkenc/memchunk_test.go +++ b/pkg/chunkenc/memchunk_test.go @@ -68,9 +68,9 @@ func TestBlocksInclusive(t *testing.T) { func TestBlock(t *testing.T) { for _, enc := range testEncoding { + enc := enc t.Run(enc.String(), func(t *testing.T) { t.Parallel() - chk := NewMemChunk(enc, DefaultHeadBlockFmt, testBlockSize, testTargetSize) cases := []struct { ts int64 @@ -180,6 +180,7 @@ func TestBlock(t *testing.T) { func TestCorruptChunk(t *testing.T) { for _, enc := range testEncoding { + enc := enc t.Run(enc.String(), func(t *testing.T) { t.Parallel() @@ -251,6 +252,8 @@ func TestRoundtripV2(t *testing.T) { for _, f := range HeadBlockFmts { for _, enc := range testEncoding { for _, version := range []byte{chunkFormatV2, chunkFormatV3} { + enc := enc + version := version t.Run(enc.String(), func(t *testing.T) { t.Parallel() @@ -308,6 +311,7 @@ func TestRoundtripV2(t *testing.T) { func TestRoundtripV3(t *testing.T) { for _, f := range HeadBlockFmts { for _, enc := range testEncoding { + enc := enc t.Run(fmt.Sprintf("%v-%v", f, enc), func(t *testing.T) { t.Parallel() @@ -331,6 +335,7 @@ func TestRoundtripV3(t *testing.T) { func TestSerialization(t *testing.T) { for _, f := range HeadBlockFmts { for _, enc := range testEncoding { + enc := enc t.Run(enc.String(), func(t *testing.T) { t.Parallel() @@ -382,6 +387,7 @@ func TestSerialization(t *testing.T) { func TestChunkFilling(t *testing.T) { for _, f := range HeadBlockFmts { for _, enc := range testEncoding { + enc := enc t.Run(enc.String(), func(t *testing.T) { t.Parallel() @@ -893,34 +899,26 @@ func TestMemChunk_IteratorBounds(t *testing.T) { expect []bool // array of expected values for next call in sequence }{ {time.Unix(0, 0), time.Unix(0, 1), logproto.FORWARD, []bool{false}}, - {time.Unix(0, 1), time.Unix(0, 1), logproto.FORWARD, []bool{true, false}}, {time.Unix(0, 1), time.Unix(0, 2), logproto.FORWARD, []bool{true, false}}, - {time.Unix(0, 2), time.Unix(0, 2), logproto.FORWARD, []bool{true, false}}, {time.Unix(0, 1), time.Unix(0, 3), logproto.FORWARD, []bool{true, true, false}}, {time.Unix(0, 2), time.Unix(0, 3), logproto.FORWARD, []bool{true, false}}, - {time.Unix(0, 3), time.Unix(0, 3), logproto.FORWARD, []bool{false}}, {time.Unix(0, 0), time.Unix(0, 1), logproto.BACKWARD, []bool{false}}, - {time.Unix(0, 1), time.Unix(0, 1), logproto.BACKWARD, []bool{true, false}}, {time.Unix(0, 1), time.Unix(0, 2), logproto.BACKWARD, []bool{true, false}}, - {time.Unix(0, 2), time.Unix(0, 2), logproto.BACKWARD, []bool{true, false}}, {time.Unix(0, 1), time.Unix(0, 3), logproto.BACKWARD, []bool{true, true, false}}, {time.Unix(0, 2), time.Unix(0, 3), logproto.BACKWARD, []bool{true, false}}, - {time.Unix(0, 3), time.Unix(0, 3), logproto.BACKWARD, []bool{false}}, } { t.Run( fmt.Sprintf("mint:%d,maxt:%d,direction:%s", tt.mint.UnixNano(), tt.maxt.UnixNano(), tt.direction), func(t *testing.T) { - t.Parallel() - tt := tt c := createChunk() // testing headchunk it, err := c.Iterator(context.Background(), tt.mint, tt.maxt, tt.direction, noopStreamPipeline) require.NoError(t, err) - for i := range tt.expect { - require.Equal(t, tt.expect[i], it.Next()) + for idx, expected := range tt.expect { + require.Equal(t, expected, it.Next(), "idx: %s", idx) } require.NoError(t, it.Close()) @@ -938,6 +936,7 @@ func TestMemChunk_IteratorBounds(t *testing.T) { func TestMemchunkLongLine(t *testing.T) { for _, enc := range testEncoding { + enc := enc t.Run(enc.String(), func(t *testing.T) { t.Parallel() diff --git a/pkg/logql/engine_test.go b/pkg/logql/engine_test.go index ca428657df52f..5890c92b0abb4 100644 --- a/pkg/logql/engine_test.go +++ b/pkg/logql/engine_test.go @@ -2352,15 +2352,15 @@ func TestStepEvaluator_Error(t *testing.T) { } for _, tc := range tests { + tc := tc t.Run(tc.name, func(t *testing.T) { - t.Parallel() - tc := tc eng := NewEngine(EngineOpts{}, tc.querier, NoLimits, log.NewNopLogger()) q := eng.Query(LiteralParams{ qs: tc.qs, start: time.Unix(0, 0), end: time.Unix(180, 0), step: 1 * time.Second, + limit: 1, }) _, err := q.Exec(user.InjectOrgID(context.Background(), "fake")) require.Equal(t, tc.err, err) diff --git a/pkg/util/metrics_helper_test.go b/pkg/util/metrics_helper_test.go index 0f3b261d67b95..2d83cbdb1843d 100644 --- a/pkg/util/metrics_helper_test.go +++ b/pkg/util/metrics_helper_test.go @@ -461,7 +461,7 @@ func TestFloat64PrecisionStability(t *testing.T) { // Randomise the seed but log it in case we need to reproduce the test on failure. seed := time.Now().UnixNano() - rand.Seed(seed) + randomGenerator := rand.New(rand.NewSource(seed)) t.Log("random generator seed:", seed) // Generate a large number of registries with different metrics each. @@ -472,22 +472,22 @@ func TestFloat64PrecisionStability(t *testing.T) { g := promauto.With(reg).NewGaugeVec(prometheus.GaugeOpts{Name: "test_gauge"}, labelNames) for i := 0; i < cardinality; i++ { - g.WithLabelValues("a", strconv.Itoa(i)).Set(rand.Float64()) + g.WithLabelValues("a", strconv.Itoa(i)).Set(randomGenerator.Float64()) } c := promauto.With(reg).NewCounterVec(prometheus.CounterOpts{Name: "test_counter"}, labelNames) for i := 0; i < cardinality; i++ { - c.WithLabelValues("a", strconv.Itoa(i)).Add(rand.Float64()) + c.WithLabelValues("a", strconv.Itoa(i)).Add(randomGenerator.Float64()) } h := promauto.With(reg).NewHistogramVec(prometheus.HistogramOpts{Name: "test_histogram", Buckets: []float64{0.1, 0.5, 1}}, labelNames) for i := 0; i < cardinality; i++ { - h.WithLabelValues("a", strconv.Itoa(i)).Observe(rand.Float64()) + h.WithLabelValues("a", strconv.Itoa(i)).Observe(randomGenerator.Float64()) } s := promauto.With(reg).NewSummaryVec(prometheus.SummaryOpts{Name: "test_summary"}, labelNames) for i := 0; i < cardinality; i++ { - s.WithLabelValues("a", strconv.Itoa(i)).Observe(rand.Float64()) + s.WithLabelValues("a", strconv.Itoa(i)).Observe(randomGenerator.Float64()) } registries.AddUserRegistry(strconv.Itoa(userID), reg) diff --git a/production/helm/loki/README.md b/production/helm/loki/README.md index d4b4c54e9d364..fd3498b5a115c 100644 --- a/production/helm/loki/README.md +++ b/production/helm/loki/README.md @@ -17,4 +17,4 @@ Helm chart for Grafana Loki in simple, scalable mode | https://charts.min.io/ | minio(minio) | 4.0.12 | | https://grafana.github.io/helm-charts | grafana-agent-operator(grafana-agent-operator) | 0.2.3 | -[Find more information in the Loki Helm Chart documentation](https://grafana.com/docs/loki/next/installation/helm). +Find more information in the Loki Helm Chart [documentation](https://grafana.com/docs/loki/next/installation/helm). diff --git a/production/helm/loki/README.md.gotmpl b/production/helm/loki/README.md.gotmpl index 163aaad13d0b2..dcd577845d4b3 100644 --- a/production/helm/loki/README.md.gotmpl +++ b/production/helm/loki/README.md.gotmpl @@ -8,4 +8,4 @@ {{ template "chart.requirementsSection" . }} -[Find more information in the Loki Helm Chart [documentation](https://grafana.com/docs/loki/next/installation/helm). +Find more information in the Loki Helm Chart [documentation](https://grafana.com/docs/loki/next/installation/helm). diff --git a/production/helm/loki/src/helm-test/Dockerfile b/production/helm/loki/src/helm-test/Dockerfile index 5ffb228f70bc2..3fdc486d04073 100644 --- a/production/helm/loki/src/helm-test/Dockerfile +++ b/production/helm/loki/src/helm-test/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.18.5 as build +FROM golang:1.20.1 as build # build via Makefile target helm-test-image in root # Makefile. Building from this directory will not be @@ -7,7 +7,7 @@ COPY . /src/loki WORKDIR /src/loki RUN make clean && make BUILD_IN_CONTAINER=false helm-test -FROM alpine:3.16.2 +FROM alpine:3.16.4 RUN apk add --update --no-cache ca-certificates=20220614-r0 COPY --from=build /src/loki/production/helm/loki/src/helm-test/helm-test /usr/bin/helm-test ENTRYPOINT [ "/usr/bin/helm-test" ] diff --git a/tools/dev/loki-boltdb-storage-s3/dev.dockerfile b/tools/dev/loki-boltdb-storage-s3/dev.dockerfile index d1b073b3e3ed2..8c1fc1a95ed51 100644 --- a/tools/dev/loki-boltdb-storage-s3/dev.dockerfile +++ b/tools/dev/loki-boltdb-storage-s3/dev.dockerfile @@ -1,8 +1,8 @@ -FROM golang:1.18.5 +FROM golang:1.20.1 ENV CGO_ENABLED=0 RUN go install github.com/go-delve/delve/cmd/dlv@v1.9.0 -FROM alpine:3.16.2 +FROM alpine:3.16.4 RUN mkdir /loki WORKDIR /loki diff --git a/tools/lambda-promtail/Dockerfile b/tools/lambda-promtail/Dockerfile index 0b3e0a1410934..f0bc66ad460fb 100644 --- a/tools/lambda-promtail/Dockerfile +++ b/tools/lambda-promtail/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.19.5-alpine AS build-image +FROM golang:1.20.1-alpine AS build-image COPY tools/lambda-promtail /src/lambda-promtail WORKDIR /src/lambda-promtail @@ -12,7 +12,7 @@ RUN go mod download RUN go build -o ./main -tags lambda.norpc -ldflags="-s -w" lambda-promtail/*.go -FROM alpine:3.16.2 +FROM alpine:3.16.4 WORKDIR /app diff --git a/vendor/go4.org/unsafe/assume-no-moving-gc/assume-no-moving-gc.go b/vendor/go4.org/unsafe/assume-no-moving-gc/assume-no-moving-gc.go index 14a41e73edf94..72b009a96680a 100644 --- a/vendor/go4.org/unsafe/assume-no-moving-gc/assume-no-moving-gc.go +++ b/vendor/go4.org/unsafe/assume-no-moving-gc/assume-no-moving-gc.go @@ -4,7 +4,11 @@ // Package go4.org/unsafe/assume-no-moving-gc exists so you can depend // on it from unsafe code that wants to declare that it assumes that -// the Go runtime does not using a moving garbage colllector. +// the Go runtime does not using a moving garbage collector. Specifically, +// it asserts that the caller is playing stupid games with the addresses +// of heap-allocated values. It says nothing about values that Go's escape +// analysis keeps on the stack. Ensuring things aren't stack-allocated +// is the caller's responsibility. // // This package is then updated for new Go versions when that // is still the case and explodes at runtime with a failure @@ -16,6 +20,14 @@ // // There is no API. // +// It is intentional that this package will break code that's not updated +// regularly to double check its assumptions about the world and new Go +// versions. If you play stupid games with unsafe pointers, the stupid prize +// is this maintenance cost. (The alternative would be memory corruption if +// some unmaintained, unsafe library were built with a future version of Go +// that worked very differently than when the unsafe library was built.) +// Ideally you shouldn't write unsafe code, though. +// // The GitHub repo is at https://github.com/go4org/unsafe-assume-no-moving-gc package assume_no_moving_gc diff --git a/vendor/go4.org/unsafe/assume-no-moving-gc/untested.go b/vendor/go4.org/unsafe/assume-no-moving-gc/untested.go index da4d943f6b7b0..dbb169045ad28 100644 --- a/vendor/go4.org/unsafe/assume-no-moving-gc/untested.go +++ b/vendor/go4.org/unsafe/assume-no-moving-gc/untested.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build go1.20 -// +build go1.20 +//go:build go1.21 +// +build go1.21 package assume_no_moving_gc @@ -22,5 +22,5 @@ func init() { if os.Getenv(env) == v { return } - panic("Something in this program imports go4.org/unsafe/assume-no-moving-gc to declare that it assumes a non-moving garbage collector, but your version of go4.org/unsafe/assume-no-moving-gc hasn't been updated to assert that it's safe against the " + v + " runtime. If you want to risk it, run with environment variable " + env + "=" + v + " set. Notably, if " + v + " adds a moving garbage collector, this program is unsafe to use.") + panic("Something in this program imports go4.org/unsafe/assume-no-moving-gc to declare that it assumes a non-moving garbage collector, but your version of go4.org/unsafe/assume-no-moving-gc hasn't been updated to assert that it's safe against the " + v + " runtime. If you want to risk it, run with environment variable " + env + "=\"" + v + "\" set. Notably, if " + v + " adds a moving garbage collector, this program is unsafe to use.") } diff --git a/vendor/modules.txt b/vendor/modules.txt index 55ffabb267064..4cabea676ba43 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1256,7 +1256,7 @@ go.uber.org/zap/zapgrpc # go4.org/intern v0.0.0-20211027215823-ae77deb06f29 ## explicit; go 1.13 go4.org/intern -# go4.org/unsafe/assume-no-moving-gc v0.0.0-20220617031537-928513b29760 +# go4.org/unsafe/assume-no-moving-gc v0.0.0-20230221090011-e4bae7ad2296 ## explicit; go 1.11 go4.org/unsafe/assume-no-moving-gc # golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa