Send step INFO and DEBUG logging to stdout, keep warnings on stderr - #225
Open
skywalkw3r wants to merge 1 commit into
Open
skywalkw3r wants to merge 1 commit into
skywalkw3r wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Debug logging can corrupt the machine-readable JSON output from debug-ephemeral-container.py.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
Updates Kubernetes workflow logging so informational output goes to stdout while warnings and errors remain on stderr.
Changes:
- Adds split-stream logging and tests.
- Applies it across workflow scripts.
- Updates debug descriptions and failed-job error handling.
| File | Summary |
|---|---|
plugin.yaml |
Updates Debug option descriptions. |
contents/tests/test_common.py |
Tests logging routing and stdout exclusions. |
contents/StatefulSet-wait.py |
Enables normal output on stdout. |
contents/service-update.py |
Enables normal output on stdout. |
contents/service-delete.py |
Enables normal output on stdout. |
contents/service-create.py |
Enables normal output on stdout. |
contents/pods-wait.py |
Enables normal output on stdout. |
contents/pods-read-logs.py |
Updates logging behavior. |
contents/pods-delete.py |
Enables normal output on stdout. |
contents/pods-create.py |
Enables normal output on stdout. |
contents/pod-describe.py |
Enables normal output on stdout. |
contents/job-wait.py |
Splits logging and reports failed Jobs as errors. |
contents/job-run.py |
Enables normal output on stdout. |
contents/job-delete.py |
Enables normal output on stdout. |
contents/job-create.py |
Enables normal output on stdout. |
contents/deployment-wait.py |
Updates logging behavior. |
contents/deployment-update.py |
Enables normal output on stdout. |
contents/deployment-status.py |
Enables normal output on stdout. |
contents/deployment-delete.py |
Enables normal output on stdout. |
contents/deployment-create.py |
Enables normal output on stdout. |
contents/delete.py |
Enables normal output on stdout. |
contents/debug-ephemeral-container.py |
Changes logging, but debug output can contaminate JSON stdout. |
contents/create-from-yaml.py |
Enables normal output on stdout. |
contents/common.py |
Adds split stdout/stderr logging. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
|
||
| logging.basicConfig(stream=sys.stdout, level=logging.INFO, | ||
| format='%(message)s') | ||
| common.log_info_to_stdout() |
Rundeck records every line a step writes to stderr at ERROR level. Every script imports common.py, whose logging.basicConfig(stream=sys.stderr) runs first, so each script's own basicConfig call has no effect and all log records go to stderr, including those scripts meant for stdout. So normal progress messages, such as the pod log that Kubernetes / Job / Waitfor prints, are shown in red as errors, and log filters that only act on normal output (key-value-data, quiet-output) never see those lines: RUNDECK:DATA values printed by a Job cannot be captured, for example. Add common.log_info_to_stdout(), which sends DEBUG and INFO records to stdout and WARNING and above to stderr, in the same format as before so existing filters keep matching, and call it in place of the ineffective basicConfig in the workflow steps whose output is read by people. The resource model, node executor, file copier and inline script steps are unchanged, because Rundeck and job authors parse their stdout. The Waitfor step now logs "Job failed" as an error, so a failed Job is still shown as one. The Debug option of those steps now says debug messages go to the step log instead of to stderr.
skywalkw3r
force-pushed
the
step-logging-stdout
branch
from
September 28, 2026 01:23
e13d493 to
0b4430e
Compare
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.

Fixes #223. Also addresses #172 and #179 (the "everything is red" part).
Problem
Rundeck records every line a step writes to stderr at ERROR level, and this plugin sends all Python logging to stderr. So normal progress messages show in red as errors:
Job succeeded,waiting for deployment, and so on,Log filters that only act on NORMAL-level lines skip them:
key-value-data,quiet-output(at itsmatchLoglevel),highlight-outputandrender-datatype.Cause
Every script imports
common.pybefore callinglogging.basicConfig(...), andcommon.pycallslogging.basicConfig(stream=sys.stderr, ...)at import. The first call wins, so each script's own call has no effect, including the two that ask for stdout.Fix
common.log_info_to_stdout(). It sends DEBUG and INFO records to stdout and WARNING and above to stderr, in the sameLEVEL: logger: messageformat as before, so existing filters that match that text keep working.basicConfigin the 21 workflow steps whose output is read by people.Job failedas an error. It was INFO and red only because everything was.plugin.yaml, the Debug option of the 17 affected steps now says "Write debug messages to the step log" instead of "... to stderr".This is opt-in per script rather than a change to
common.py's default. A future script that writes data to stdout therefore stays safe unless it chooses to send its logging to stdout.Compatibility
highlight-output,render-datatypeandquiet-output(withmatchLoglevel: normal) now apply to these steps' INFO lines.key-value-datacan now captureRUNDECK:DATA:values from these steps if its regex matches the line as printed,INFO: kubernetes-wait-job: b'RUNDECK:DATA: ...'. Our jobs do this with mask filters that strip the prefix first. With the default regex, the prefix still prevents a match.pods-read-logs.py,debug-ephemeral-container.pyanddeployment-wait.pyasked for a bare%(message)sformat that they never actually got. I kept the format they produce today so their output doesn't change shape.Testing
contents/tests/test_common.py:job-wait.pyrun as a real process against an unreachable API with Debug on: the DEBUG line went to stdout, while urllib3's retry warnings and the traceback went to stderr.key-value-datafilter:RUNDECK:DATA: pod_0 = donenot capturedWARNING: An error occurred - retries: N).{"pod_0":"done"}capturedERROR: kubernetes-wait-job: Job failed, and Rundeck's result-code line. The step fails as before