From e4ce1282952dfec89be8b5cbf26b03983d4bd0a3 Mon Sep 17 00:00:00 2001 From: Ruofeng Lei Date: Thu, 4 Mar 2021 19:03:55 +0800 Subject: [PATCH 1/2] Set logger for controller-runtime Signed-off-by: Ruofeng Lei --- adapter/main.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/adapter/main.go b/adapter/main.go index a7103c050b2..239651eaed7 100644 --- a/adapter/main.go +++ b/adapter/main.go @@ -18,6 +18,7 @@ import ( "k8s.io/client-go/kubernetes/scheme" "k8s.io/klog/v2" "k8s.io/klog/v2/klogr" + ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/config" @@ -132,6 +133,8 @@ func main() { return } + ctrl.SetLogger(logger) + globalHTTPTimeoutStr := os.Getenv("KEDA_HTTP_DEFAULT_TIMEOUT") if globalHTTPTimeoutStr == "" { // default to 3 seconds if they don't pass the env var From 65eb1209731fb1ea166dd6af04e92e964d823685 Mon Sep 17 00:00:00 2001 From: Ruofeng Lei Date: Thu, 4 Mar 2021 19:39:12 +0800 Subject: [PATCH 2/2] Update changelog and run the pre-commit hook Signed-off-by: Ruofeng Lei --- CHANGELOG.md | 1 + adapter/main.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 45261899c1a..7ff37c8e1b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ - Print correct ScaleTarget Kind in Events ([#1641](https://github.com/kedacore/keda/pull/1641)) - Fixed keda clusterroles to give permissions for clustertriggerauthentications ([#1645](https://github.com/kedacore/keda/pull/1645)) - Make `swiftURL` parameter optional for the OpenStack Swift scaler ([#1652](https://github.com/kedacore/keda/pull/1652)) +- Fix memory leak of `keda-metrics-apiserver` by setting a controller-runtime logger properly ([#1654](https://github.com/kedacore/keda/pull/1654)) ### Breaking Changes diff --git a/adapter/main.go b/adapter/main.go index 239651eaed7..860242d90fd 100644 --- a/adapter/main.go +++ b/adapter/main.go @@ -134,7 +134,7 @@ func main() { } ctrl.SetLogger(logger) - + globalHTTPTimeoutStr := os.Getenv("KEDA_HTTP_DEFAULT_TIMEOUT") if globalHTTPTimeoutStr == "" { // default to 3 seconds if they don't pass the env var