File tree 5 files changed +54
-3
lines changed
5 files changed +54
-3
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,7 @@ Here is an overview of all new **experimental** features:
73
73
74
74
### Fixes
75
75
76
+ - ** General** : Centralize and improve automaxprocs configuration with proper structured logging ([ #5970 ] ( https://github.com/kedacore/keda/issues/5970 ) )
76
77
- ** General** : Paused ScaledObject count is reported correctly after operator restart ([ #6321 ] ( https://github.com/kedacore/keda/issues/6321 ) )
77
78
78
79
### Deprecations
Original file line number Diff line number Diff line change @@ -26,7 +26,6 @@ import (
26
26
grpcprom "github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus"
27
27
"github.com/prometheus/client_golang/prometheus"
28
28
"github.com/prometheus/client_golang/prometheus/collectors"
29
- _ "go.uber.org/automaxprocs"
30
29
appsv1 "k8s.io/api/apps/v1"
31
30
apimetrics "k8s.io/apiserver/pkg/endpoints/metrics"
32
31
"k8s.io/client-go/kubernetes/scheme"
@@ -257,6 +256,12 @@ func main() {
257
256
return
258
257
}
259
258
259
+ err = kedautil .ConfigureMaxProcs (logger )
260
+ if err != nil {
261
+ logger .Error (err , "failed to set max procs" )
262
+ return
263
+ }
264
+
260
265
kedaProvider , err := cmd .makeProvider (ctx )
261
266
if err != nil {
262
267
logger .Error (err , "making provider" )
Original file line number Diff line number Diff line change @@ -22,7 +22,6 @@ import (
22
22
"time"
23
23
24
24
"github.com/spf13/pflag"
25
- _ "go.uber.org/automaxprocs"
26
25
apimachineryruntime "k8s.io/apimachinery/pkg/runtime"
27
26
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
28
27
kubeinformers "k8s.io/client-go/informers"
@@ -115,6 +114,13 @@ func main() {
115
114
116
115
ctrl .SetLogger (zap .New (zap .UseFlagOptions (& opts )))
117
116
ctx := ctrl .SetupSignalHandler ()
117
+
118
+ err := kedautil .ConfigureMaxProcs (setupLog )
119
+ if err != nil {
120
+ setupLog .Error (err , "failed to set max procs" )
121
+ os .Exit (1 )
122
+ }
123
+
118
124
namespaces , err := kedautil .GetWatchNamespaces ()
119
125
if err != nil {
120
126
setupLog .Error (err , "failed to get watch namespace" )
Original file line number Diff line number Diff line change @@ -22,7 +22,6 @@ import (
22
22
"os"
23
23
24
24
"github.com/spf13/pflag"
25
- _ "go.uber.org/automaxprocs"
26
25
apimachineryruntime "k8s.io/apimachinery/pkg/runtime"
27
26
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
28
27
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
@@ -80,6 +79,12 @@ func main() {
80
79
81
80
ctrl .SetLogger (zap .New (zap .UseFlagOptions (& opts )))
82
81
82
+ err := kedautil .ConfigureMaxProcs (setupLog )
83
+ if err != nil {
84
+ setupLog .Error (err , "failed to set max procs" )
85
+ os .Exit (1 )
86
+ }
87
+
83
88
ctx := ctrl .SetupSignalHandler ()
84
89
85
90
cfg := ctrl .GetConfigOrDie ()
Original file line number Diff line number Diff line change
1
+ /*
2
+ Copyright 2024 The KEDA Authors
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ package util
18
+
19
+ import (
20
+ "fmt"
21
+
22
+ "go.uber.org/automaxprocs/maxprocs"
23
+ "k8s.io/klog/v2"
24
+ )
25
+
26
+ // ConfigureMaxProcs sets up automaxprocs with proper logging configuration.
27
+ // It wraps the automaxprocs logger to handle structured logging with string keys
28
+ // to prevent panics when automaxprocs tries to pass numeric keys.
29
+ func ConfigureMaxProcs (logger klog.Logger ) error {
30
+ _ , err := maxprocs .Set (maxprocs .Logger (func (format string , args ... interface {}) {
31
+ logger .Info (fmt .Sprintf (format , args ... ))
32
+ }))
33
+ return err
34
+ }
You can’t perform that action at this time.
0 commit comments