kedacore / keda

KEDA is a Kubernetes-based Event Driven Autoscaling component. It provides event driven scale for any container running in Kubernetes
https://keda.sh
Apache License 2.0
8.47k stars 1.07k forks source link

Automaxprocs library prints log in a different format then the rest of the KEDA operator #5970

Open zachgilbert-upwork opened 3 months ago

zachgilbert-upwork commented 3 months ago

Report

With the addition of the automaxprocs package to set GOMAXPROCS (https://github.com/kedacore/keda/issues/4999), the KEDA operator now prints one console type log on startup, then switches to the format configured by logging.operator.format:

2024/07/18 20:58:55 maxprocs: Updating GOMAXPROCS=1: determined from CPU quota
2024-07-18T20:58:57.052292080Z {"level":"info","ts":"2024-07-18T20:58:57Z","logger":"setup","msg":"Starting manager"}
2024-07-18T20:58:57.052312817Z {"level":"info","ts":"2024-07-18T20:58:57Z","logger":"setup","msg":"KEDA Version: 2.13.1"}
{"level":"info","ts":"2024-07-18T20:58:57Z","logger":"setup","msg":"Git Commit: 41dd7a8558fdb274f2c0861f6c6d1eba01f2dcd5"}
2024-07-18T20:58:57.052319615Z {"level":"info","ts":"2024-07-18T20:58:57Z","logger":"setup","msg":"Go Version: go1.21.6"}
2024-07-18T20:58:57.052321484Z {"level":"info","ts":"2024-07-18T20:58:57Z","logger":"setup","msg":"Go OS/Arch: linux/amd64"}
2024-07-18T20:58:57.052323828Z {"level":"info","ts":"2024-07-18T20:58:57Z","logger":"setup","msg":"Running on Kubernetes 1.29+","version":"v1.29.4-eks-036c24b"}
2024-07-18T20:58:57.153119735Z I0718 20:58:57.153022       1 leaderelection.go:250] attempting to acquire leader lease h6m-core-keda/operator.keda.sh...
2024-07-18T20:58:57.153330709Z {"level":"info","ts":"2024-07-18T20:58:57Z","msg":"starting server","kind":"health probe","addr":"[::]:8081"}

We are running KEDA in an environment where this is breaking our log ingestion, as we expect only one log format. The way to disable this logging, or implement it with the same logger as the rest app, is documented here: https://github.com/uber-go/automaxprocs/issues/18.

Expected Behavior

When setting the logging.operator.format to json, I expect all logs produced by the KEDA operator to be in JSON format.

Actual Behavior

When running KEDA operator, there is one log printed by the automaxprocs package that doesn't respect the format as configured by the user.

Steps to Reproduce the Problem

  1. Run KEDA Operator
  2. Observe logs

Logs from KEDA operator

2024/07/18 20:58:55 maxprocs: Updating GOMAXPROCS=1: determined from CPU quota
2024-07-18T20:58:57.052292080Z {"level":"info","ts":"2024-07-18T20:58:57Z","logger":"setup","msg":"Starting manager"}
2024-07-18T20:58:57.052312817Z {"level":"info","ts":"2024-07-18T20:58:57Z","logger":"setup","msg":"KEDA Version: 2.13.1"}
{"level":"info","ts":"2024-07-18T20:58:57Z","logger":"setup","msg":"Git Commit: 41dd7a8558fdb274f2c0861f6c6d1eba01f2dcd5"}
2024-07-18T20:58:57.052319615Z {"level":"info","ts":"2024-07-18T20:58:57Z","logger":"setup","msg":"Go Version: go1.21.6"}
2024-07-18T20:58:57.052321484Z {"level":"info","ts":"2024-07-18T20:58:57Z","logger":"setup","msg":"Go OS/Arch: linux/amd64"}
2024-07-18T20:58:57.052323828Z {"level":"info","ts":"2024-07-18T20:58:57Z","logger":"setup","msg":"Running on Kubernetes 1.29+","version":"v1.29.4-eks-036c24b"}
2024-07-18T20:58:57.153119735Z I0718 20:58:57.153022       1 leaderelection.go:250] attempting to acquire leader lease h6m-core-keda/operator.keda.sh...
2024-07-18T20:58:57.153330709Z {"level":"info","ts":"2024-07-18T20:58:57Z","msg":"starting server","kind":"health probe","addr":"[::]:8081"}

KEDA Version

2.13.1

Kubernetes Version

1.29

Platform

Amazon Web Services

Scaler Details

No response

Anything else?

No response

JorTurFer commented 3 months ago

Interesting catch! are you willing to open a PR with the change?

stale[bot] commented 4 weeks ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.