[APIP] update logging implementation to use logr and add slog handler#2786
Conversation
📝 WalkthroughWalkthroughThe Gateway Operator logging backend changes from Zap to Go’s ChangesGateway Operator logging and release refresh
Estimated code review effort: 4 (Complex) | ~45 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
… related components - Updated K8sGatewayClassReconciler, LlmProviderReconciler, LlmProviderTemplateReconciler, LlmProxyReconciler, ManagedSecretReconciler, McpReconciler, RestApiReconciler, SubscriptionReconciler, and SubscriptionPlanReconciler to use slog.Logger instead of zap.Logger. - Modified logger initialization methods to create slog.Logger instances. - Adjusted logging calls to match the new slog API. - Removed zap dependency and related logger configuration code from logger package.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
kubernetes/gateway-operator/pkg/logger/logger.go (1)
33-60: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider adding unit tests for the new level/format parsing.
parseSlogLevelandNewSlogHandlerare small, pure, and easy to unit test (format branch, each level string, unknown-level fallback), but no test file was included for this new logic. Worth covering since this replaces the whole logging backend.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@kubernetes/gateway-operator/pkg/logger/logger.go` around lines 33 - 60, Add unit tests for parseSlogLevel covering debug, warn/warning, error, and unknown-level fallback to info. Add NewSlogHandler tests covering both text and JSON format branches, verifying the returned handler behavior or concrete handler type without changing the implementation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@kubernetes/gateway-operator/pkg/logger/logger.go`:
- Around line 33-60: Add unit tests for parseSlogLevel covering debug,
warn/warning, error, and unknown-level fallback to info. Add NewSlogHandler
tests covering both text and JSON format branches, verifying the returned
handler behavior or concrete handler type without changing the implementation.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 3ed4c5bb-da31-45c6-a9c2-27b3e3cd5ca0
⛔ Files ignored due to path filters (2)
go.work.sumis excluded by!**/*.sumkubernetes/gateway-operator/go.sumis excluded by!**/*.sum
📒 Files selected for processing (29)
docs/gateway/kubernetes/gateway-operator.mdkubernetes/conformance/README.mdkubernetes/gateway-operator/Makefilekubernetes/gateway-operator/cmd/main.gokubernetes/gateway-operator/go.modkubernetes/gateway-operator/internal/controller/apigateway_controller.gokubernetes/gateway-operator/internal/controller/apikey_controller.gokubernetes/gateway-operator/internal/controller/certificate_controller.gokubernetes/gateway-operator/internal/controller/generic_reconciler.gokubernetes/gateway-operator/internal/controller/httproute_compile.gokubernetes/gateway-operator/internal/controller/httproute_controller.gokubernetes/gateway-operator/internal/controller/httproute_enqueue.gokubernetes/gateway-operator/internal/controller/httproute_policies.gokubernetes/gateway-operator/internal/controller/httproute_policy_params_resolve.gokubernetes/gateway-operator/internal/controller/k8s_gateway_controller.gokubernetes/gateway-operator/internal/controller/k8s_gatewayclass_controller.gokubernetes/gateway-operator/internal/controller/k8s_gatewayclass_controller_test.gokubernetes/gateway-operator/internal/controller/llmprovider_controller.gokubernetes/gateway-operator/internal/controller/llmprovidertemplate_controller.gokubernetes/gateway-operator/internal/controller/llmproxy_controller.gokubernetes/gateway-operator/internal/controller/managedsecret_controller.gokubernetes/gateway-operator/internal/controller/mcp_controller.gokubernetes/gateway-operator/internal/controller/restapi_controller.gokubernetes/gateway-operator/internal/controller/restapi_enqueue.gokubernetes/gateway-operator/internal/controller/subscription_controller.gokubernetes/gateway-operator/internal/controller/subscriptionplan_controller.gokubernetes/gateway-operator/internal/helmgateway/deploy.gokubernetes/gateway-operator/pkg/logger/logger.gokubernetes/helm/operator-helm-chart/values-local.yaml
Related to #2784
This pull request primarily updates the Helm chart version for the Gateway Operator and makes extensive updates to the
go.work.sumfile, adding or updating references to various Go module dependencies. These changes help keep dependencies current and improve compatibility and security.The most important changes include:
Gateway Operator update:
gateway-operator.mdto use Gateway Operator Helm chart version0.10.0and image tag0.10.0, up from0.8.0/0.8.1.Go module dependency additions and updates:
go.work.sum, including but not limited to:github.com/prometheus/client_golangtov1.20.5andgithub.com/prometheus/commontov0.62.0github.com/onsi/ginkgo/v2tov2.27.4andgithub.com/onsi/gomegatov1.39.0go.etcd.io/etcdand related modules tov3.6.8github.com/google/pproftov0.0.0-20250403155104-27863c87afa6github.com/spf13/cobra,github.com/grpc-ecosystem/go-grpc-middleware,github.com/tmc/grpc-websocket-proxy, and more. [1] [2] [3]These updates ensure the project uses the latest compatible versions of its dependencies, which can provide bug fixes, security patches, and new features.