Skip to content

chore(operator): replace go.uber.org/zap with stdlib log/slog - #423

Merged
lusoris merged 1 commit into
masterfrom
chore/zap-to-slog-uniform
May 31, 2026
Merged

lusoris merged 1 commit into
masterfrom
chore/zap-to-slog-uniform

Conversation

@lusoris

@lusoris lusoris commented May 31, 2026

Copy link
Copy Markdown
Contributor

Summary

Replaces go.uber.org/zap with the standard-library log/slog package in
cmd/vmafx-operator/ — the last of 25 Go binaries on the fork still using
the kubebuilder-template-default zap logger. All other vmafx Go binaries
(vmafx-server, vmafx-controller, vmafx-tune, MCP server, …) already
log via slog. The operator now bridges slog.NewJSONHandler into
controller-runtime via logr.FromSlogHandler, giving the fork a single
uniform logging stack across its entire Go surface.

Audit modernization item #3 (zap holdout retirement).

Type

  • chore / refactor — no behaviour change, dependency cleanup.

Dependencies removed (direct)

  • go.uber.org/zap → now indirect only (pulled in by controller-runtime internals; upstream's choice, unaffected).
  • github.com/go-logr/zapr → dropped from go.mod entirely.
  • go.uber.org/multierr → dropped from go.mod entirely.

Promoted to direct dep:

  • github.com/go-logr/logr (was indirect; now used by the logr.FromSlogHandler bridge).

Bug-status hygiene (ADR-0165)

  • no state delta: pure dependency-modernization refactor, no bug
    fixed/opened/ruled-out and no user-visible behaviour change.

Netflix golden-data gate (ADR-0024)

  • I did not modify any assertAlmostEqual(...) score in the Netflix golden Python tests.
  • No Python or C touched at all — Go-only change.

Deep-dive deliverables (ADR-0108)

  • Research digest — no digest needed: mechanical 1-importer refactor with no design surface.
  • Decision matrix — no alternatives: only-one-way fix (drop zap, use the slog handler all other vmafx binaries already use).
  • AGENTS.md invariant note — added rule chore(deps): Update dependency anthropic to >=0.104.1 #6 to cmd/vmafx-operator/AGENTS.md documenting the slog bridge so a future kubebuilder template re-scaffold doesn't silently reintroduce zap.
  • Reproducer / smoke-test command — pasted below under "Reproducer".
  • CHANGELOG fragment — changelog.d/changed/zap-to-slog-uniform.md.
  • Rebase note — head entry in docs/rebase-notes.md ("vmafx-operator zap → slog uniformity"). Netflix/vmaf has no operator so cross-repo impact is zero; the note covers the kubebuilder-template re-scaffold path instead.

Reproducer

# Build + vet
go build ./...
go vet ./cmd/vmafx-operator/...

# Tests (require envtest assets)
export KUBEBUILDER_ASSETS=$(setup-envtest use 1.31 -p path)
go test -count=1 ./cmd/vmafx-operator/...

# Verify zap is no longer a direct importer
grep -rn 'go.uber.org/zap' --include='*.go' .   # → no matches

Local run on master tip + this branch: go build ./... clean,
go vet clean, golangci-lint run ./cmd/vmafx-operator/... reports
0 issues., go test ./cmd/vmafx-operator/... passes
(ok 5.306s, 3 specs in the envtest suite).

Known follow-ups

None. zap remains an indirect transitive dependency of
sigs.k8s.io/controller-runtime; eliminating it entirely would require
forking controller-runtime, which is out of scope.

@lusoris
lusoris marked this pull request as ready for review May 31, 2026 03:10
@lusoris
lusoris enabled auto-merge (squash) May 31, 2026 03:10
The vmafx-operator was the last of 25 Go binaries on the fork still
using the kubebuilder-template-default zap logger. All other binaries
(vmafx-server, vmafx-controller, vmafx-tune, MCP server, …) already
log via the standard library's log/slog package. This change retires
the holdout so the fork has a single, uniform logging stack across
its entire Go surface.

main.go now installs a slog.NewJSONHandler against os.Stderr and
bridges it into controller-runtime via logr.FromSlogHandler. The
envtest suite_test.go uses slog.NewTextHandler against GinkgoWriter
for the same reason.

go.uber.org/zap is removed from direct dependencies (it remains
present as an indirect transitive dep of sigs.k8s.io/controller-runtime
internals; that is upstream's choice and unaffected). go-logr/zapr
and go.uber.org/multierr are dropped from go.mod entirely.
github.com/go-logr/logr is promoted to a direct dependency.

ADR-0108 deliverables:
- Research digest: no digest needed — mechanical 1-importer refactor.
- Decision matrix: no alternatives — only-one-way fix (replace with
  the slog handler all other binaries already use).
- AGENTS.md invariant: cmd/vmafx-operator/AGENTS.md gains rule #6
  documenting the slog bridge for future kubebuilder re-syncs.
- Reproducer: KUBEBUILDER_ASSETS=\$(setup-envtest use 1.31 -p path) \\
  go test ./cmd/vmafx-operator/...
- CHANGELOG fragment: changelog.d/changed/zap-to-slog-uniform.md.
- Rebase note: docs/rebase-notes.md head entry covers re-applying
  the slog bridge after a kubebuilder template re-scaffold.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@lusoris
lusoris force-pushed the chore/zap-to-slog-uniform branch from 7f52ae5 to 45bbbe6 Compare May 31, 2026 03:11
@lusoris
lusoris merged commit dea7318 into master May 31, 2026
57 of 60 checks passed
@lusoris
lusoris deleted the chore/zap-to-slog-uniform branch May 31, 2026 03:32
@lusoris lusoris added this to the 1.0.0 — First release milestone Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant