linkerd2/controller/proxy-injector
MicahSee 264b67c5fe
Ensure consistent JSON logging for proxy-injector container (#13335)
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 msee@usc.edu
2024-11-18 17:15:24 +00:00
..
fake Implement providing configuration for TCP_USER_TIMEOUT to linkerd-proxy (#13024) 2024-10-03 16:08:01 +00:00
metrics.go Enable gocritic linting (#7906) 2022-02-17 22:45:25 +00:00
webhook.go Ensure consistent JSON logging for proxy-injector container (#13335) 2024-11-18 17:15:24 +00:00
webhook_test.go make group ID configurable (#11924) 2024-05-23 15:54:21 -05:00