chore: container-based Go module updates (update_go) and Renovate Go config#3174
Conversation
Add `make update_go`, which updates both in-repo Go modules (.monitoring/exporter and .keda-external-scaler) to the latest Go toolchain and dependencies using the official Go container (GO_IMAGE, default golang:latest) — no host Go install needed, and updates always track the latest stable release. It bumps each module's go directive to the container's Go version, runs go get -u + tidy (as the invoking user so files are not root-owned), and aligns the external scaler Dockerfile golang base to the same Go minor. Also configure Renovate to run go mod tidy after gomod updates and keep the Go toolchain (go.mod directive and golang image) on the latest release. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
PR Summary by QodoAdd containerized Go module updater and Renovate rules; bump in-repo Go deps
AI Description
Diagram
High-Level Assessment
Files changed (6)
|
Code Review by Qodo
1. update_go masks failures
|
| @GO_VERSION="$$(docker run --rm $(GO_IMAGE) go env GOVERSION | sed 's/go//')"; \ | ||
| GO_MM="$$(echo $$GO_VERSION | sed -E 's/([0-9]+\.[0-9]+).*/\1/')"; \ | ||
| echo "==> Using Go $$GO_VERSION from $(GO_IMAGE)"; \ | ||
| for dir in $(GO_MODULES); do \ | ||
| echo "==> Updating Go module in $$dir"; \ | ||
| docker run --rm -v "$(PWD)":/src -w "/src/$$dir" \ | ||
| --user "$$(id -u):$$(id -g)" -e HOME=/tmp -e GOFLAGS=-mod=mod \ | ||
| $(GO_IMAGE) sh -c "go mod edit -go=$$GO_VERSION && go get -u ./... && go mod tidy"; \ | ||
| done; \ | ||
| echo "==> Aligning .keda-external-scaler Dockerfile base to golang:$$GO_MM"; \ | ||
| sed -i.bak -E "s#(golang:)[0-9]+\.[0-9]+#\1$$GO_MM#g" .keda-external-scaler/Dockerfile && rm -f .keda-external-scaler/Dockerfile.bak |
There was a problem hiding this comment.
1. Update_go masks failures 🐞 Bug ☼ Reliability
update_go runs a backslash-continued multi-command shell block without set -e or explicit status checks, so a failing docker run ... go get/tidy inside the loop can be ignored and the target can still exit 0 if the final sed ... && rm succeeds. This can leave partially-updated go.mod/go.sum while printing success messages.
Agent Prompt
### Issue description
The `update_go` Makefile recipe executes many commands in a single shell invocation (via `\` line continuations) but does not enable fail-fast behavior. As a result, a failure during module updates can be masked by later successful commands (notably the final `sed ... && rm ...`), causing `make update_go` to report success even when updates did not complete.
### Issue Context
- `docker pull $(GO_IMAGE)` (line 162) is a separate recipe line and will fail the target as expected.
- The masking happens inside the subsequent shell block (lines 163–173) because commands are separated with `;` and there is no `set -e` or equivalent.
### Fix Focus Areas
- Makefile[161-173]
### Suggested fix
Within the `@GO_VERSION=...; \` shell block, add fail-fast behavior, for example:
- Prefix the block with `set -e;` (or `set -eu;`), and/or
- Ensure the loop exits on failure (e.g., append `|| exit 1` to the `docker run ...` line), and/or
- Rewrite the block to use `&&` chaining for commands whose failure should stop the target.
Example pattern:
```make
@set -e; \
GO_VERSION=...; \
...; \
for dir in ...; do \
docker run ... || exit 1; \
done; \
...
```
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
db40ecf to
074a09c
Compare
Ran `make update_go` (golang:latest, Go 1.26.5). Also fixes a pre-existing corrupt pseudo-version in the exporter go.mod (github.com/munnerz/goautoneg v0.0.0-2.20.110083416-a7dc8b61c822 -> the canonical v0.0.0-20191010083416-a7dc8b61c822), which had been blocking go mod tidy/get. - exporter: prometheus/common 0.67.5 -> 0.70.0, procfs 0.20.1 -> 0.21.1, x/sys 0.45.0 -> 0.47.0; go directive 1.26.3 -> 1.26.5. - keda-external-scaler: grpc 1.71.0 -> 1.82.0, protobuf 1.36.5 -> 1.36.11, go-logr 1.4.2 -> 1.4.3, plus x/net, x/sys, x/text, genproto; go directive 1.26.0 -> 1.26.5. Both modules build; keda -race tests pass. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Viet Nguyen Duc <nguyenducviet4496@gmail.com>
074a09c to
643eabe
Compare
What
Adds a container-based mechanism to keep the two in-repo Go modules —
.monitoring/exporterand.keda-external-scaler— on the latest Go toolchain and dependencies, and applies a first update.make update_goUpdates both Go modules using the official Go container (no host Go install required), so updates always track the latest stable release:
GO_IMAGE(defaultgolang:latest) provides the toolchain; override e.g.make update_go GO_IMAGE=golang:1.27.godirective to the container's Go version, runsgo get -u ./...+go mod tidy, running as the invoking--usersogo.mod/go.sumare not written root-owned..keda-external-scalerDockerfilegolang:base image to the same Go minor so the container build stays in sync.Renovate
postUpdateOptions: [gomodTidy, gomodUpdateImportPaths]so gomod PRs are tidied automatically.godirective andgolangbase image) on the latest release.Applied update (
make update_go, Go 1.26.5 fromgolang:latest)github.com/munnerz/goautoneg v0.0.0-2.20.110083416-a7dc8b61c822→ canonicalv0.0.0-20191010083416-a7dc8b61c822) that was blockinggo mod tidy/get.Verify
make update_goruns cleanly (Go 1.26.5 fromgolang:latest); resulting files owned by the invoking user, not root..keda-external-scaler:go build ./...+go test ./internal/... -racepass..monitoring/exporter:go buildpasses.Notes
renovate/google.golang.org/grpc-updateand.../protobuf-update; those overlap with the grpc/protobuf bumps here, so one side may supersede the other.🤖 Generated with Claude Code