Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure consistent JSON logging for proxy-injector container #13335

Merged
merged 2 commits into from
Nov 18, 2024

Conversation

MicahSee
Copy link
Contributor

Ensure consistent JSON logging for proxy-injector container

When JSON logging is enabled in the proxy-injector controllerLogFormat: json some log messages adhere to the JSON format while others do not. This inconsistency creates difficulty in parsing logs, especially in automated workflows. For example:

{"level":"info","msg":"received admission review request \"83a0ce4d-ab81-42c9-abe4-e0ade0f926e2\"","time":"2024-10-10T21:06:18Z"}
time="2024-10-10T21:06:18Z" level=info msg="received pod/mypod"

Modified the logging implementation in the controller/proxy-injector/webhook.go to ensure all log messages follow the JSON format consistently. This was achieved by removing a new instance of the logrus logger that was being created in the file and replacing it with the global logger instance, ensuring all logs respect the controllerLogFormat configuration.

Reproduced the issue by enabling JSON logging and observing mixed-format logs when install the emojivoto sample application. Applied the changes and verified that all logs consistently use the JSON format.
Ran the linkerd check command and confirmed there are no additional warnings or issues.
Tested various scenarios, including pods with and without the injection annotation, to ensure consistent logging behavior.
Fixes #13168

Signed-off-by: Micah See [email protected]

Edited file to use global instance of logger instead of creating a new
one
@MicahSee MicahSee requested a review from a team as a code owner November 15, 2024 22:40
@olix0r olix0r enabled auto-merge (squash) November 18, 2024 16:52
@olix0r olix0r merged commit 264b67c into linkerd:main Nov 18, 2024
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

proxy-injector doesn't respect JSON logging configuration for all log messages
2 participants