WINC-1635, WINC-1592: enable log rotation for kubelet and kubeproxy services#3766
WINC-1635, WINC-1592: enable log rotation for kubelet and kubeproxy services#3766jrvaldes wants to merge 6 commits intoopenshift:masterfrom
Conversation
|
Skipping CI for Draft Pull Request. |
|
/retitle WINC-1635: enable log rotation for kubelet service |
|
@jrvaldes: This pull request references WINC-1635 which is a valid jira issue. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
336fc21 to
ad7f5c8
Compare
|
/test ? |
|
/test lint |
|
/test unit |
|
/test images |
|
/test vsphere-e2e-operator |
4469104 to
f6a626f
Compare
|
/test vsphere-e2e-operator |
1 similar comment
|
/test vsphere-e2e-operator |
06d4c31 to
ca06837
Compare
|
/test vsphere-e2e-operator |
ca06837 to
f994aee
Compare
|
/test vsphere-e2e-operator |
f994aee to
547445b
Compare
|
/test vsphere-e2e-operator |
547445b to
abd7af6
Compare
|
/test vsphere-e2e-operator |
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds kubelet Logging configuration (FlushFrequency 5s), promotes k8s.io/component-base to a direct go.mod require, introduces environment-driven log rotation for managed Windows services with helpers, tests and package init-time env parsing, and adds enable_debug_logging() in hack/common.sh to toggle WMCO debug logging. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~30 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Comment |
|
@coderabbitai review |
abd7af6 to
5abf765
Compare
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
🤖 Fix all issues with AI agents
Verify each finding against the current code and only fix it if needed.
In `@pkg/services/services_test.go`:
- Around line 158-189: The test TestGetLogRunnerForCmd relies on package-level
defaults (logFileSize, logFileAge, flushInterval) which are initialized from
environment variables; make the test deterministic by setting those env vars at
test start (use t.Setenv for SERVICES_LOG_FILE_SIZE, SERVICES_LOG_FILE_AGE,
SERVICES_LOG_FLUSH_INTERVAL) to the expected default values ("100M", "168h",
"5s") before calling getLogRunnerForCmd so the output always matches the
hardcoded expected strings.
🧹 Nitpick comments (1)
🤖 Fix all nitpicks with AI agents
Verify each finding against the current code and only fix it if needed. In `@pkg/services/services_test.go`: - Around line 158-189: The test TestGetLogRunnerForCmd relies on package-level defaults (logFileSize, logFileAge, flushInterval) which are initialized from environment variables; make the test deterministic by setting those env vars at test start (use t.Setenv for SERVICES_LOG_FILE_SIZE, SERVICES_LOG_FILE_AGE, SERVICES_LOG_FLUSH_INTERVAL) to the expected default values ("100M", "168h", "5s") before calling getLogRunnerForCmd so the output always matches the hardcoded expected strings.pkg/services/services_test.go (1)
158-189: Test relies on package-level defaults initialized at startup.The test hardcodes expected values (
100M,168h,5s) that match the default constants. However, sincelogFileSize,logFileAge, andflushIntervalare set ininit()from environment variables, if any of these env vars (SERVICES_LOG_FILE_SIZE,SERVICES_LOG_FILE_AGE,SERVICES_LOG_FLUSH_INTERVAL) are set in the test environment, this test will fail unexpectedly.Consider either:
- Explicitly setting the env vars in this test using
t.Setenvto ensure predictable behavior, or- Documenting that this test assumes default values
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pkg/services/services_test.go` around lines 158 - 189, The test TestGetLogRunnerForCmd relies on package-level defaults (logFileSize, logFileAge, flushInterval) which are initialized from environment variables; make the test deterministic by setting those env vars at test start (use t.Setenv for SERVICES_LOG_FILE_SIZE, SERVICES_LOG_FILE_AGE, SERVICES_LOG_FLUSH_INTERVAL) to the expected default values ("100M", "168h", "5s") before calling getLogRunnerForCmd so the output always matches the hardcoded expected strings.
this commit explicitly configures kubelet's logging flush frequency to 5 seconds to ensure log entries are written to disk in near real-time.
ran: go mod tidy && go mod vendor
Makes sense, what do you mean by "can get verified"? |
0465980 to
54c4ce8
Compare
like, on parsing the config you can have a quick bit of code to verify that everything is correct. |
exactly, that is what the validations around the env var values is about: verify that everything is correct syntactically |
54c4ce8 to
857920f
Compare
|
/test ? |
|
/test azure-e2e-upgrade |
pkg/services/services.go
Outdated
| value := os.Getenv(key) | ||
| value = strings.TrimSpace(value) | ||
| if value == "" { | ||
| // not present |
There was a problem hiding this comment.
nit: we can remove these kind of comments and other simple code comments.
pkg/services/services.go
Outdated
| // logging to the given logfilePath. Log rotation parameters can be configured via environment variables. | ||
| func getLogRunnerForCmd(commandPath, logfilePath string) string { | ||
| cmdBuilder := strings.Builder{} | ||
| // log runner path must be first |
There was a problem hiding this comment.
some comments here may be redundant
this commit configures kubelet service to use kube-log-runner wrapper to enable optional log rotation on Windows nodes. This prevents unbounded log growth that could exhaust disk space. Log rotation parameters are configurable via environment variables: - SERVICES_LOG_FILE_SIZE: Size limit before rotation - SERVICES_LOG_FILE_AGE: Retention period for rotated logs - SERVICES_LOG_FLUSH_INTERVAL: Flush interval to disk This approach is necessary because Windows services don't have a native mechanism for output redirection, and Kubernetes has deprecated the --log-file flag for components.
this commit configures kubeproxy service to use kube-log-runner wrapper to enable automatic log rotation on Windows nodes. This prevents unbounded log growth that could exhaust disk space. Log rotation parameters are configurable via environment variables: - SERVICES_LOG_FILE_SIZE: Size limit before rotation (default: 100M) - SERVICES_LOG_FILE_AGE: Retention period for rotated logs (default: 168h) - SERVICES_LOG_FLUSH_INTERVAL: Flush interval to disk (default: 5s)
this commit documents the automatic log rotation for managed Windows services in the Enabled features section in the README.md
857920f to
36f6377
Compare
|
/lgtm |
|
@jrvaldes: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
|
@jrvaldes: jrvaldes unauthorized: /override is restricted to Repo administrators, approvers in top level OWNERS file, and the following github teams:openshift: openshift-release-oversight openshift-staff-engineers openshift-sustaining-engineers. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/override ci/prow/gcp-e2e-operator |
|
@jrvaldes: Overrode contexts on behalf of jrvaldes: ci/prow/gcp-e2e-operator DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
This pull request introduces configurable log rotation and flushing for Windows kubelet services, allowing log file size, retention, and flush interval to be set via environment variables. It also adds helper functions to safely parse and use these environment variables, and includes unit tests to ensure their correctness.
Log rotation and flush configuration:
SERVICES_LOG_FILE_SIZE), log file age (SERVICES_LOG_FILE_AGE), and log flush interval (SERVICES_LOG_FLUSH_INTERVAL), with sensible defaults, to control log runner behavior inpkg/services/services.go. [1] [2]getLogRunnerForCmd, which incorporates the log rotation and flush parameters. [1] [2]Loggingfield, using the newlogsapi.LoggingConfigurationstruct. [1] [2]Helper functions and environment parsing:
getEnvQuantityOrDefaultandgetEnvDurationOrDefaultfunctions to safely parse quantity and duration environment variables, falling back to defaults if invalid. [1] [2]Testing:
pkg/services/services_test.go, covering various scenarios and edge cases.Summary by CodeRabbit
New Features
Updates
Tests
Documentation
Chores