Skip to content

Reintroduce PR #5974: Remove klogr dependency and move to zap#6578

Merged
JorTurFer merged 3 commits into
kedacore:mainfrom
aliaqel-stripe:aliaqel/update-metrics-server-logging
Jun 9, 2025
Merged

Reintroduce PR #5974: Remove klogr dependency and move to zap#6578
JorTurFer merged 3 commits into
kedacore:mainfrom
aliaqel-stripe:aliaqel/update-metrics-server-logging

Conversation

@aliaqel-stripe

@aliaqel-stripe aliaqel-stripe commented Feb 28, 2025

Copy link
Copy Markdown
Contributor

Reintroducing #5794

This PR reintroduces the above PR to refactor metrics-server to use zap instead of klogr. This not only removes the deprecated dependency but it also enables for JSON logging, a frequently requested feature in the metrics server.

To provide backward compatibility with existing tests and charts, I added handling for the three klogr flags KEDA exposes in helm charts. I translate the verbosity flag to the zap equivalent, but I treat the other flags as no-ops.

I also updated the dev container protoc version so that it does not overwrite the protoc version used to generate proto.

Additionally, I have

I ran locally and validated logs to console work:

2025-04-21T02:46:41.710Z	INFO	keda_metrics_adapter	Starting metrics server
2025-04-21T02:46:41.710Z	INFO	keda_metrics_adapter	KEDA Version: main
2025-04-21T02:46:41.710Z	INFO	keda_metrics_adapter	Git Commit: 5c08467753257d76d62a1eccffd70327a8284f9f
2025-04-21T02:46:41.710Z	INFO	keda_metrics_adapter	Go Version: go1.23.8
2025-04-21T02:46:41.710Z	INFO	keda_metrics_adapter	Go OS/Arch: linux/arm64
2025-04-21T02:46:41.710Z	INFO	keda_metrics_adapter	Running on Kubernetes 1.30	{"version": "v1.30.3"}
2025-04-21T02:46:41.710Z	INFO	keda_metrics_adapter	maxprocs: Updating GOMAXPROCS=1: determined from CPU quota
2025-04-21T02:46:41.711Z	INFO	keda_metrics_adapter	Connecting Metrics Service gRPC client to the server	{"address": "..."}
2025-04-21T02:46:41.717Z	INFO	keda_metrics_adapter.provider	starting
2025-04-21T02:46:41.717Z	INFO	keda_metrics_adapter	starting adapter...
2025-04-21T02:46:41.735Z	INFO	keda_metrics_adapter.provider	Waiting for establishing a gRPC connection to KEDA Metrics Server
2025-04-21T02:46:41.735Z	INFO	keda_metrics_adapter	starting /metrics server endpoint
...
2025-04-21T02:46:42.235Z	INFO	keda_metrics_adapter.provider	Connection to KEDA Metrics Service gRPC server has been successfully established	{"server": "..."}

and then validated I can log in json:

{"level":"info","ts":"2025-04-21T00:31:40Z","logger":"keda_metrics_adapter","msg":"Starting metrics server"}
{"level":"info","ts":"2025-04-21T00:31:40Z","logger":"keda_metrics_adapter","msg":"KEDA Version: main"}
{"level":"info","ts":"2025-04-21T00:31:40Z","logger":"keda_metrics_adapter","msg":"Git Commit: 670eb91693c139a90df21320b92144952196eb31"}
{"level":"info","ts":"2025-04-21T00:31:40Z","logger":"keda_metrics_adapter","msg":"Go Version: go1.23.8"}
{"level":"info","ts":"2025-04-21T00:31:40Z","logger":"keda_metrics_adapter","msg":"Go OS/Arch: linux/arm64"}
{"level":"info","ts":"2025-04-21T00:31:40Z","logger":"keda_metrics_adapter","msg":"Running on Kubernetes 1.30","version":"v1.30.3"}
{"level":"info","ts":"2025-04-21T00:31:40Z","logger":"keda_metrics_adapter","msg":"maxprocs: Updating GOMAXPROCS=1: determined from CPU quota"}
{"level":"info","ts":"2025-04-21T00:31:40Z","logger":"keda_metrics_adapter","msg":"Connecting Metrics Service gRPC client to the server","address":"..."}
{"level":"info","ts":"2025-04-21T00:31:40Z","logger":"keda_metrics_adapter.provider","msg":"starting"}
{"level":"info","ts":"2025-04-21T00:31:40Z","logger":"keda_metrics_adapter","msg":"starting adapter..."}
{"level":"info","ts":"2025-04-21T00:31:40Z","logger":"keda_metrics_adapter.provider","msg":"Waiting for establishing a gRPC connection to KEDA Metrics Server"}
{"level":"info","ts":"2025-04-21T00:31:40Z","logger":"keda_metrics_adapter","msg":"starting /metrics server endpoint"}
I0421 00:31:41.217266      15 secure_serving.go:213] Serving securely on [::]:6443
I0421 00:31:41.217321      15 requestheader_controller.go:172] Starting RequestHeaderAuthRequestController
I0421 00:31:41.217331      15 shared_informer.go:313] Waiting for caches to sync for RequestHeaderAuthRequestController
I0421 00:31:41.217363      15 dynamic_serving_content.go:135] "Starting controller" name="serving-cert::/certs/tls.crt::/certs/tls.key"
I0421 00:31:41.217471      15 tlsconfig.go:243] "Starting DynamicServingCertificateController"
...
...
{"level":"info","ts":"2025-04-21T00:31:41Z","logger":"keda_metrics_adapter.provider","msg":"Connection to KEDA Metrics Service gRPC server has been successfully established","server":"..."}

Checklist

  • I have verified that my change is according to the deprecations & breaking changes policy
  • Changelog has been updated and is aligned with our changelog requirements
  • A PR is opened to update our Helm chart (repo) (if applicable, ie. when deployment manifests are modified)
  • A PR is opened to update the documentation on (repo) (if applicable)
  • Commits are signed with Developer Certificate of Origin (DCO - learn more)

Fixes #5732 , #4049

Relates to #741, #1543

@semgrep-app

semgrep-app Bot commented Feb 28, 2025

Copy link
Copy Markdown

Semgrep found 1 no-sudo-in-dockerfile finding:

Avoid using sudo in Dockerfiles. Running processes as a non-root user can help reduce the potential impact of configuration errors and security vulnerabilities.

@aliaqel-stripe aliaqel-stripe force-pushed the aliaqel/update-metrics-server-logging branch from 3a0c3a9 to c11ad1b Compare February 28, 2025 22:25
@aliaqel-stripe aliaqel-stripe marked this pull request as ready for review February 28, 2025 22:42
@aliaqel-stripe aliaqel-stripe requested a review from a team as a code owner February 28, 2025 22:42

@zroubalik zroubalik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, this is great.

My concern is backwards compatibilty, we are changing the way to setup this. I wonder if there's a way how to bypass this, maybe internally convert the "old" params to the new one?

@lucasfcnunes

Copy link
Copy Markdown

In general, this is great.

My concern is backwards compatibilty, we are changing the way to setup this. I wonder if there's a way how to bypass this, maybe internally convert the "old" params to the new one?

Yep. That's how it needs to be.

@aliaqel-stripe aliaqel-stripe force-pushed the aliaqel/update-metrics-server-logging branch 2 times, most recently from de125cb to 3077754 Compare April 21, 2025 00:31
@aliaqel-stripe

aliaqel-stripe commented Apr 21, 2025

Copy link
Copy Markdown
Contributor Author

@zroubalik @lucasfcnunes I added handling for the legacy klogr flags KEDA exposes through Helm and converted them to zap options to the extent that it made sense. Tested them locally on our setup without modifying flags (i.e use the existing klogr flags) and verified logging works and the metrics-server starts up.

@zroubalik

zroubalik commented Apr 24, 2025

Copy link
Copy Markdown
Member

/run-e2e internal
Update: You can check the progress here

@aliaqel-stripe

aliaqel-stripe commented Apr 25, 2025

Copy link
Copy Markdown
Contributor Author

@zroubalik We should probably rerun the e2e tests if possible. Had to rebase to because of a conflict. The original run you started passed, but worth running again I guess

@JorTurFer

JorTurFer commented Apr 26, 2025

Copy link
Copy Markdown
Member

/run-e2e internal
Update: You can check the progress here

@aliaqel-stripe

Copy link
Copy Markdown
Contributor Author

@JorTurFer Not sure why the latest e2e test run failed: https://github.com/kedacore/keda/actions/runs/14682302792

Looks like it was green but the result was failure?

@zroubalik

zroubalik commented May 6, 2025

Copy link
Copy Markdown
Member

/run-e2e internal
Update: You can check the progress here

@aliaqel-stripe aliaqel-stripe force-pushed the aliaqel/update-metrics-server-logging branch 3 times, most recently from 3696a6b to e591100 Compare May 9, 2025 15:12
@aliaqel-stripe aliaqel-stripe force-pushed the aliaqel/update-metrics-server-logging branch from 883bd10 to 75f751f Compare May 31, 2025 15:05
Signed-off-by: Ali Aqel <[email protected]>

remove changelog changes

Signed-off-by: Ali Aqel <[email protected]>

add verbose logging for azure test

Signed-off-by: Ali Aqel <[email protected]>

add verbose logging for azure test

Signed-off-by: Ali Aqel <[email protected]>
@aliaqel-stripe aliaqel-stripe force-pushed the aliaqel/update-metrics-server-logging branch from 75f751f to 6a08338 Compare May 31, 2025 15:07
@JorTurFer

JorTurFer commented Jun 1, 2025

Copy link
Copy Markdown
Member

/run-e2e internal
Update: You can check the progress here

@JorTurFer

JorTurFer commented Jun 2, 2025

Copy link
Copy Markdown
Member

/run-e2e internal
Update: You can check the progress here

@JorTurFer JorTurFer merged commit 4ee73f0 into kedacore:main Jun 9, 2025
20 checks passed
@JorTurFer

Copy link
Copy Markdown
Member

Thanks!

maxcao13 pushed a commit to maxcao13/keda that referenced this pull request Jun 9, 2025
…kedacore#6578)

remove changelog changes

add verbose logging for azure test

add verbose logging for azure test

Signed-off-by: Ali Aqel <[email protected]>
Co-authored-by: Jorge Turrado Ferrero <[email protected]>
Signed-off-by: Max Cao <[email protected]>
dpochopsky pushed a commit to dpochopsky/keda that referenced this pull request Sep 12, 2025
…kedacore#6578)

remove changelog changes



add verbose logging for azure test



add verbose logging for azure test

Signed-off-by: Ali Aqel <[email protected]>
Co-authored-by: Jorge Turrado Ferrero <[email protected]>
Signed-off-by: David Pochopsky <[email protected]>
@itsamenathan

Copy link
Copy Markdown

When will a version with this change be released? Currently v2.17.2 doesn't have this change.

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.

Metrics Server: klogr.New is deprecated use textlogger.NewLogger instead

5 participants