Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR configures klog (Kubernetes logging library) to use the same structured logger as controller-runtime to ensure consistent log formatting across all soperator components. Previously, leader election logs from Kubernetes components were always in plain text format even when JSON logging was configured.
- Added klog.SetLogger() calls to inherit the same format configuration as the main application logger
- Modified go.mod to make k8s.io/klog/v2 a direct dependency instead of indirect
- Updated Makefile to enable leader election during local development runs
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| go.mod | Changed k8s.io/klog/v2 from indirect to direct dependency |
| cmd/main.go | Added klog configuration and leader election namespace |
| cmd/soperatorchecks/main.go | Added klog configuration for consistent log formatting |
| cmd/sconfigcontroller/main.go | Added klog configuration for consistent log formatting |
| cmd/rebooter/main.go | Added klog configuration for consistent log formatting |
| Makefile | Changed leader election flag from false to true for local runs |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
ali-sattari
approved these changes
Sep 24, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Leader election logs from Kubernetes components (like
leaderelection.go) were always output in plain text format (I0924 10:23:13.769662 1 leaderelection.go:257] attempting to acquire leader lease...), even when the soperator was configured to use JSON logging format. This created inconsistent log formats in structured logging environments where all logs should be in JSON format for proper parsing and processing by log aggregation systems.Solution
Configured
klog(Kubernetes logging library) to use the same structured logger as controller-runtime across all main.go files that use controller-runtime:klog.SetLogger()calls incmd/main.go,cmd/soperatorchecks/main.go,cmd/sconfigcontroller/main.go, andcmd/rebooter/main.go--log-formatflag settingTesting
make lintto ensure no formatting or import issuesRelease Notes
Feature: Leader election and Kubernetes client logs now respect the
--log-formatflag setting, providing consistent JSON or plain text formatting across all soperator components. This improves log consistency in structured logging environments without any breaking changes to existing deployments.