From 715f382554f421b51050c17653063443076ec110 Mon Sep 17 00:00:00 2001 From: Trevor Whitney Date: Wed, 9 Oct 2024 15:01:45 -0600 Subject: [PATCH 01/15] ci: fix nix build, downgrade toolchain to go1.23.1 --- .github/workflows/nix-ci.yaml | 1 + flake.lock | 12 ++++++------ go.mod | 2 +- nix/packages/loki.nix | 4 ++-- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/nix-ci.yaml b/.github/workflows/nix-ci.yaml index 06a6cad41c8a4..b8871d7e20e5f 100644 --- a/.github/workflows/nix-ci.yaml +++ b/.github/workflows/nix-ci.yaml @@ -4,6 +4,7 @@ on: pull_request: paths: - "flake.nix" + - "go.mod" - "nix/**" jobs: lint: diff --git a/flake.lock b/flake.lock index 06c301936e4db..2e819fa13ad72 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1694529238, - "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "lastModified": 1726560853, + "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", "type": "github" }, "original": { @@ -20,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1699781429, - "narHash": "sha256-UYefjidASiLORAjIvVsUHG6WBtRhM67kTjEY4XfZOFs=", + "lastModified": 1728241625, + "narHash": "sha256-yumd4fBc/hi8a9QgA9IT8vlQuLZ2oqhkJXHPKxH/tRw=", "owner": "nixos", "repo": "nixpkgs", - "rev": "e44462d6021bfe23dfb24b775cc7c390844f773d", + "rev": "c31898adf5a8ed202ce5bea9f347b1c6871f32d1", "type": "github" }, "original": { diff --git a/go.mod b/go.mod index bfccc98c18c0d..1600e0f826207 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,7 @@ module github.com/grafana/loki/v3 go 1.22 -toolchain go1.23.2 +toolchain go1.23.1 require ( cloud.google.com/go/bigtable v1.29.0 diff --git a/nix/packages/loki.nix b/nix/packages/loki.nix index 977161460eb8d..ba2ebf2b8a77d 100644 --- a/nix/packages/loki.nix +++ b/nix/packages/loki.nix @@ -5,7 +5,7 @@ let pname = "lambda-promtail"; src = ./../../tools/lambda-promtail; - vendorHash = "sha256-CKob173T0VHD5c8F26aU7p1l+QzqddNM4qQedMbLJa0="; + vendorHash = "sha256-zEN42vbw4mWtU8KOUi9ZSQiFoRJnH7C04aaZ2wCtA/o="; doCheck = false; @@ -27,7 +27,7 @@ pkgs.stdenv.mkDerivation { bash gcc git - go + go_1_23 golangci-lint nettools yamllint From e0e7a3962f1689080a5c3f4a2a7adb35565a10a8 Mon Sep 17 00:00:00 2001 From: Trevor Whitney Date: Wed, 9 Oct 2024 16:33:40 -0600 Subject: [PATCH 02/15] fix: linting errors --- pkg/pattern/clientpool/client.go | 4 ++++ pkg/util/httpgrpc/carrier.go | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/pattern/clientpool/client.go b/pkg/pattern/clientpool/client.go index a4b23a792108e..f66b63c92e88e 100644 --- a/pkg/pattern/clientpool/client.go +++ b/pkg/pattern/clientpool/client.go @@ -35,6 +35,10 @@ type ClosableHealthAndIngesterClient struct { io.Closer } +func (c ClosableHealthAndIngesterClient) Close() error { + return c.Closer.Close() +} + // Config for an ingester client. type Config struct { PoolConfig PoolConfig `yaml:"pool_config,omitempty" doc:"description=Configures how connections are pooled."` diff --git a/pkg/util/httpgrpc/carrier.go b/pkg/util/httpgrpc/carrier.go index 6b160d615e1bc..29e8b68c7e600 100644 --- a/pkg/util/httpgrpc/carrier.go +++ b/pkg/util/httpgrpc/carrier.go @@ -16,14 +16,14 @@ type Request interface { type HeadersCarrier weaveworks_httpgrpc.HTTPRequest func (c *HeadersCarrier) Set(key, val string) { - c.Headers = append(c.Headers, &weaveworks_httpgrpc.Header{ + c.Headers = append((*c).Headers, &weaveworks_httpgrpc.Header{ Key: key, Values: []string{val}, }) } func (c *HeadersCarrier) ForeachKey(handler func(key, val string) error) error { - for _, h := range c.Headers { + for _, h := range (*c).Headers { for _, v := range h.Values { if err := handler(h.Key, v); err != nil { return err From 45cf841604f64c78733fa6262c0838859ae46cee Mon Sep 17 00:00:00 2001 From: Trevor Whitney Date: Wed, 9 Oct 2024 16:39:23 -0600 Subject: [PATCH 03/15] ci: bump install nix action --- .github/workflows/nix-ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nix-ci.yaml b/.github/workflows/nix-ci.yaml index b8871d7e20e5f..b0f8b0748007d 100644 --- a/.github/workflows/nix-ci.yaml +++ b/.github/workflows/nix-ci.yaml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v22 + - uses: cachix/install-nix-action@v30 with: nix_path: nixpkgs=channel:nixos-unstable - run: nix run --print-build-logs .#lint From f58cad0c94bb110157b5a5a35ac230175009271c Mon Sep 17 00:00:00 2001 From: Trevor Whitney Date: Wed, 9 Oct 2024 16:39:53 -0600 Subject: [PATCH 04/15] ci: bump install nix action --- .github/workflows/nix-ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nix-ci.yaml b/.github/workflows/nix-ci.yaml index b0f8b0748007d..ba08c719ee3dc 100644 --- a/.github/workflows/nix-ci.yaml +++ b/.github/workflows/nix-ci.yaml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v22 + - uses: cachix/install-nix-action@v30 with: nix_path: nixpkgs=channel:nixos-unstable - run: nix run --print-build-logs .#test @@ -27,7 +27,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v22 + - uses: cachix/install-nix-action@v30 with: nix_path: nixpkgs=channel:nixos-unstable - run: nix build --print-build-logs .#promtail From 02a577d54e24ca0c3258c40766e67e1eb216f4b7 Mon Sep 17 00:00:00 2001 From: Trevor Whitney Date: Thu, 10 Oct 2024 06:33:35 -0600 Subject: [PATCH 05/15] chore: bump go version on go.mod --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 1600e0f826207..da86bb21b0c18 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/grafana/loki/v3 -go 1.22 +go 1.23 toolchain go1.23.1 From 71dd20b89d164826fbbe2747cb3843517b4bbfb5 Mon Sep 17 00:00:00 2001 From: Trevor Whitney Date: Thu, 10 Oct 2024 06:45:55 -0600 Subject: [PATCH 06/15] ci: setup go in nix ci build --- .github/workflows/nix-ci.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/nix-ci.yaml b/.github/workflows/nix-ci.yaml index ba08c719ee3dc..4b2ebdce4fddb 100644 --- a/.github/workflows/nix-ci.yaml +++ b/.github/workflows/nix-ci.yaml @@ -22,6 +22,9 @@ jobs: - uses: cachix/install-nix-action@v30 with: nix_path: nixpkgs=channel:nixos-unstable + - uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' - run: nix run --print-build-logs .#test packages: runs-on: ubuntu-latest From 46406788c9f4c8ca76d78ba837840ff1a995d514 Mon Sep 17 00:00:00 2001 From: Trevor Whitney Date: Thu, 10 Oct 2024 06:51:31 -0600 Subject: [PATCH 07/15] ci: get more debugging out of failed go build --- Makefile | 2 +- nix/packages/loki.nix | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 609a8190f00a4..3247f820e5e79 100644 --- a/Makefile +++ b/Makefile @@ -58,7 +58,7 @@ DONT_FIND := -name tools -prune -o -name vendor -prune -o -name operator -prune # Build flags VPREFIX := github.com/grafana/loki/v3/pkg/util/build GO_LDFLAGS := -X $(VPREFIX).Branch=$(GIT_BRANCH) -X $(VPREFIX).Version=$(IMAGE_TAG) -X $(VPREFIX).Revision=$(GIT_REVISION) -X $(VPREFIX).BuildUser=$(shell whoami)@$(shell hostname) -X $(VPREFIX).BuildDate=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ") -GO_FLAGS := -ldflags "-extldflags \"-static\" -s -w $(GO_LDFLAGS)" -tags netgo +GO_FLAGS := -x -ldflags "-extldflags \"-static\" -s -w $(GO_LDFLAGS)" -tags netgo DYN_GO_FLAGS := -ldflags "-s -w $(GO_LDFLAGS)" -tags netgo # Per some websites I've seen to add `-gcflags "all=-N -l"`, the gcflags seem poorly if at all documented # the best I could dig up is -N disables optimizations and -l disables inlining which should make debugging match source better. diff --git a/nix/packages/loki.nix b/nix/packages/loki.nix index ba2ebf2b8a77d..7b2a48697dcb2 100644 --- a/nix/packages/loki.nix +++ b/nix/packages/loki.nix @@ -56,6 +56,8 @@ pkgs.stdenv.mkDerivation { export GOPROXY=off cp -r ${lambda-promtail-gomod} tools/lambda-promtail/vendor + go clean -modcache + go version make clean loki ''; From 00ff46697ea1f69991d8957e4a16267dc3f259ce Mon Sep 17 00:00:00 2001 From: Trevor Whitney Date: Thu, 10 Oct 2024 06:56:14 -0600 Subject: [PATCH 08/15] ci: add gotools dependency to nix build --- nix/packages/loki.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/nix/packages/loki.nix b/nix/packages/loki.nix index 7b2a48697dcb2..f9dbe96bff0b7 100644 --- a/nix/packages/loki.nix +++ b/nix/packages/loki.nix @@ -29,6 +29,7 @@ pkgs.stdenv.mkDerivation { git go_1_23 golangci-lint + gotools nettools yamllint From 9d3e08248fd4cc03da9385058ac22d69b097b18a Mon Sep 17 00:00:00 2001 From: Trevor Whitney Date: Thu, 10 Oct 2024 07:16:11 -0600 Subject: [PATCH 09/15] ci: bump faillint version --- nix/packages/faillint.nix | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/nix/packages/faillint.nix b/nix/packages/faillint.nix index f19d4c9fac760..7bfe8b7a816a0 100644 --- a/nix/packages/faillint.nix +++ b/nix/packages/faillint.nix @@ -1,16 +1,16 @@ { lib, buildGoModule, fetchFromGitHub }: -buildGoModule rec { +buildGoModule { pname = "faillint"; - version = "1.11.0"; + version = "1.13.0"; src = fetchFromGitHub { - owner = "fatih"; + owner = "trevorwhitney"; repo = "faillint"; - rev = "v${version}"; - sha256 = "ZSTeNp8r+Ab315N1eVDbZmEkpQUxmmVovvtqBBskuI4="; + rev = "main"; + sha256 = "NV+wbu547mtTa6dTGv7poBwWXOmu5YjqbauzolCg5qs="; }; - vendorHash = "sha256-5OR6Ylkx8AnDdtweY1B9OEcIIGWsY8IwTHbR/LGnqFI="; + vendorHash = "sha256-vWt4HneDA7YwXYnn8TbfWCKzSv7RcgXxn/HAh6a+htQ="; doCheck = false; } From eaaad95d688600f92b7ea3663908f1b7f203990b Mon Sep 17 00:00:00 2001 From: Trevor Whitney Date: Thu, 10 Oct 2024 07:53:08 -0600 Subject: [PATCH 10/15] fix: undo code changes --- pkg/pattern/clientpool/client.go | 4 ---- pkg/util/httpgrpc/carrier.go | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/pkg/pattern/clientpool/client.go b/pkg/pattern/clientpool/client.go index f66b63c92e88e..a4b23a792108e 100644 --- a/pkg/pattern/clientpool/client.go +++ b/pkg/pattern/clientpool/client.go @@ -35,10 +35,6 @@ type ClosableHealthAndIngesterClient struct { io.Closer } -func (c ClosableHealthAndIngesterClient) Close() error { - return c.Closer.Close() -} - // Config for an ingester client. type Config struct { PoolConfig PoolConfig `yaml:"pool_config,omitempty" doc:"description=Configures how connections are pooled."` diff --git a/pkg/util/httpgrpc/carrier.go b/pkg/util/httpgrpc/carrier.go index 29e8b68c7e600..6b160d615e1bc 100644 --- a/pkg/util/httpgrpc/carrier.go +++ b/pkg/util/httpgrpc/carrier.go @@ -16,14 +16,14 @@ type Request interface { type HeadersCarrier weaveworks_httpgrpc.HTTPRequest func (c *HeadersCarrier) Set(key, val string) { - c.Headers = append((*c).Headers, &weaveworks_httpgrpc.Header{ + c.Headers = append(c.Headers, &weaveworks_httpgrpc.Header{ Key: key, Values: []string{val}, }) } func (c *HeadersCarrier) ForeachKey(handler func(key, val string) error) error { - for _, h := range (*c).Headers { + for _, h := range c.Headers { for _, v := range h.Values { if err := handler(h.Key, v); err != nil { return err From b09a50fc6570a110aa4452c161e61dd02a9270ae Mon Sep 17 00:00:00 2001 From: Trevor Whitney Date: Thu, 10 Oct 2024 07:53:21 -0600 Subject: [PATCH 11/15] fix: undo Makefile changes --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3247f820e5e79..609a8190f00a4 100644 --- a/Makefile +++ b/Makefile @@ -58,7 +58,7 @@ DONT_FIND := -name tools -prune -o -name vendor -prune -o -name operator -prune # Build flags VPREFIX := github.com/grafana/loki/v3/pkg/util/build GO_LDFLAGS := -X $(VPREFIX).Branch=$(GIT_BRANCH) -X $(VPREFIX).Version=$(IMAGE_TAG) -X $(VPREFIX).Revision=$(GIT_REVISION) -X $(VPREFIX).BuildUser=$(shell whoami)@$(shell hostname) -X $(VPREFIX).BuildDate=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ") -GO_FLAGS := -x -ldflags "-extldflags \"-static\" -s -w $(GO_LDFLAGS)" -tags netgo +GO_FLAGS := -ldflags "-extldflags \"-static\" -s -w $(GO_LDFLAGS)" -tags netgo DYN_GO_FLAGS := -ldflags "-s -w $(GO_LDFLAGS)" -tags netgo # Per some websites I've seen to add `-gcflags "all=-N -l"`, the gcflags seem poorly if at all documented # the best I could dig up is -N disables optimizations and -l disables inlining which should make debugging match source better. From e831f3fdf76b9bd7fc473dfa7c2480cd6b12c5db Mon Sep 17 00:00:00 2001 From: Trevor Whitney Date: Thu, 10 Oct 2024 09:33:08 -0600 Subject: [PATCH 12/15] chore: undo unecessary extra changes to package --- nix/packages/loki.nix | 2 -- 1 file changed, 2 deletions(-) diff --git a/nix/packages/loki.nix b/nix/packages/loki.nix index f9dbe96bff0b7..deab8e6b1307d 100644 --- a/nix/packages/loki.nix +++ b/nix/packages/loki.nix @@ -57,8 +57,6 @@ pkgs.stdenv.mkDerivation { export GOPROXY=off cp -r ${lambda-promtail-gomod} tools/lambda-promtail/vendor - go clean -modcache - go version make clean loki ''; From ab93f9d0d7a26978e245e2a62138d44031358819 Mon Sep 17 00:00:00 2001 From: Trevor Whitney Date: Thu, 10 Oct 2024 10:20:22 -0600 Subject: [PATCH 13/15] ci: remove go install from nix build --- .github/workflows/nix-ci.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/nix-ci.yaml b/.github/workflows/nix-ci.yaml index 4b2ebdce4fddb..ba08c719ee3dc 100644 --- a/.github/workflows/nix-ci.yaml +++ b/.github/workflows/nix-ci.yaml @@ -22,9 +22,6 @@ jobs: - uses: cachix/install-nix-action@v30 with: nix_path: nixpkgs=channel:nixos-unstable - - uses: actions/setup-go@v5 - with: - go-version-file: 'go.mod' - run: nix run --print-build-logs .#test packages: runs-on: ubuntu-latest From f0f19efd52cea71a38c79af4aba1229346bb8995 Mon Sep 17 00:00:00 2001 From: Trevor Whitney Date: Thu, 10 Oct 2024 10:59:29 -0600 Subject: [PATCH 14/15] chore: go back to upstream faillint --- nix/packages/faillint.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nix/packages/faillint.nix b/nix/packages/faillint.nix index 7bfe8b7a816a0..30aeb30d76b5b 100644 --- a/nix/packages/faillint.nix +++ b/nix/packages/faillint.nix @@ -1,13 +1,13 @@ { lib, buildGoModule, fetchFromGitHub }: -buildGoModule { +buildGoModule rec { pname = "faillint"; - version = "1.13.0"; + version = "24d8e46ee21be34778b85fce26fed0ad50210141"; src = fetchFromGitHub { - owner = "trevorwhitney"; + owner = "fatih"; repo = "faillint"; - rev = "main"; + rev = "${version}"; sha256 = "NV+wbu547mtTa6dTGv7poBwWXOmu5YjqbauzolCg5qs="; }; From 6b356043cd7c850280dd059eb0289b19adb25989 Mon Sep 17 00:00:00 2001 From: Trevor Whitney Date: Thu, 10 Oct 2024 11:03:16 -0600 Subject: [PATCH 15/15] chore: switch to tagged faillint version --- nix/packages/faillint.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nix/packages/faillint.nix b/nix/packages/faillint.nix index 30aeb30d76b5b..0931fc08fccfa 100644 --- a/nix/packages/faillint.nix +++ b/nix/packages/faillint.nix @@ -2,7 +2,7 @@ buildGoModule rec { pname = "faillint"; - version = "24d8e46ee21be34778b85fce26fed0ad50210141"; + version = "v1.14.0"; src = fetchFromGitHub { owner = "fatih";