fix(controller): pass log format to plugin subprocess loggers#4806
fix(controller): pass log format to plugin subprocess loggers#4806n0rm4l-me wants to merge 7 commits into
Conversation
go-plugin reads plugin stderr and re-emits lines through the host
process's hclog logger. If the plugin writes logrus text/JSON, the host
wraps it as a string inside its own log entry — producing double-wrapped
output like:
[DEBUG] plugin.gatewayAPI: {"level":"info","msg":"...JSON blob..."}
The fix: replace logrus with hclog throughout the plugin so logs are
written in hclog's native format (@Level, @message, @timestamp). The
host's logStderr parser recognises these fields and re-emits them as
proper structured fields — no wrapping.
The --logformat flag remains: it controls JSONFormat on the hclog logger
passed to goPlugin.Serve(), so the host can render plugin logs as JSON
when running with --logformat=json.
For the controller-side fix that makes --logformat=json actually flow
into the plugin subprocess logger, see:
argoproj/argo-rollouts#4806
Signed-off-by: Petr Petrenko | INPD <petr.petrenko@rakuten.com>
Published E2E Test Results 4 files 4 suites 3h 46m 41s ⏱️ Results for commit 74a0b3a. ♻️ This comment has been updated with latest results. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4806 +/- ##
==========================================
+ Coverage 85.09% 85.31% +0.22%
==========================================
Files 166 166
Lines 19136 19146 +10
==========================================
+ Hits 16283 16335 +52
+ Misses 2005 1958 -47
- Partials 848 853 +5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Published Unit Test Results2 524 tests 2 524 ✅ 3m 23s ⏱️ Results for commit 74a0b3a. ♻️ This comment has been updated with latest results. |
|
@kostis-codefresh Could you please check? |
kostis-codefresh
left a comment
There was a problem hiding this comment.
You need to fix the checks first. I think you forgot to commit go.mod/go.sum?
There was a problem hiding this comment.
go mod tidy makes no changes — go-hclog was already a transitive dependency in go.mod. The Verify Codegen failure is an infrastructure flake (tar cache collision on the runner), unrelated to this change. Could you re-run that job?
UPD: Turned out it was my mistake. Fixing.
212a6c8 to
502cea6
Compare
Plugin subprocesses are launched via go-plugin which reads their stderr and re-emits lines through its own hclog logger. Without a Logger in ClientConfig, go-plugin creates a default one with JSONFormat=false, so plugin logs always render as plain text even when the controller runs with --logformat=json. Fix: add NewPluginLogger() to utils/log that mirrors the controller's log format (JSON when logrus uses JSONFormatter, text otherwise), and wire it into all three plugin clients — traffic router, step, and metric provider. Signed-off-by: Petr Petrenko | INPD <petr.petrenko@rakuten.com>
Signed-off-by: Petr Petrenko | INPD <petr.petrenko@rakuten.com>
Signed-off-by: Petr Petrenko | INPD <petr.petrenko@rakuten.com>
Signed-off-by: Petr Petrenko | INPD <petr.petrenko@rakuten.com>
Signed-off-by: Petr Petrenko | INPD <petr.petrenko@rakuten.com>
Signed-off-by: Petr Petrenko | INPD <petr.petrenko@rakuten.com>
Signed-off-by: Petr Petrenko | INPD <petr.petrenko@rakuten.com>
0946657 to
74a0b3a
Compare
|



What this fixes
When the controller runs with
--logformat=json, its own logs come out as JSON — but plugin subprocess logs (traffic router, step, metric provider) always came out as plain text. This made structured log ingestion painful: JSON and text lines mixed in the same stream.The root cause is in how go-plugin works: it reads plugin stderr and re-emits lines through its own internal hclog logger. When no
Loggeris passed inClientConfig, go-plugin creates a default one withJSONFormat: false. The controller's--logformatflag had no effect on this path at all.This was discovered while implementing
--logformatsupport in the Gateway API traffic router plugin. The plugin was updated to write structured logs using hclog's native format (@level,@message,@timestamp), but the output was still rendered as plain text by the controller side. Investigation showed the fix had to be here, in the controller.What changed
Added
NewPluginLogger()toutils/log— it creates an hclog logger that mirrors the controller's log format by inspecting the global logrus formatter. Wired it into all three plugin clients:rollout/trafficrouting/plugin/client/client.gorollout/steps/plugin/client/client.gometricproviders/plugin/client/client.goBehavior
--logformat=jsonNo change in default behavior. All existing plugin integrations unaffected.
Related
Checklist