Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ To learn more about active deprecations, we recommend checking [GitHub Discussio
- **General**: Fix int64 overflow in milli-quantity conversion for very large metric values ([#7441](https://github.com/kedacore/keda/issues/7441))
- **General**: Fix ScaledObject admission webhook to return validation error from `verifyReplicaCount`, preventing invalid ScaledObjects from being created ([#5954](https://github.com/kedacore/keda/issues/5954))
- **General**: Handle paused scaling directly in reconciler ([#7663](https://github.com/kedacore/keda/issues/7663))
- **General**: Honor `stderrthreshold` when `logtostderr` is enabled by updating klog to v2.140.0 ([#7568](https://github.com/kedacore/keda/pull/7568))
- **Azure Data Explorer Scaler**: Remove clientSecretFromEnv support ([#7554](https://github.com/kedacore/keda/pull/7554))
- **Cron Scaler**: Fix metric name generation so cron expressions with comma-separated values no longer produce invalid metric names ([#7448](https://github.com/kedacore/keda/issues/7448))
- **Forgejo Scaler**: Limit HTTP error response logging ([#7469](https://github.com/kedacore/keda/pull/7469))
Expand Down
16 changes: 16 additions & 0 deletions cmd/adapter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"k8s.io/client-go/kubernetes/scheme"
kubemetrics "k8s.io/component-base/metrics"
"k8s.io/component-base/metrics/legacyregistry"
"k8s.io/klog/v2"
ctrl "sigs.k8s.io/controller-runtime"
ctrlcache "sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
Expand Down Expand Up @@ -254,6 +255,21 @@ func main() {
// Make sure we get the zap flags
opts := zap.Options{}
opts.BindFlags(flag.CommandLine)

// Register klog flags on flag.CommandLine so they can be set programmatically.
klog.InitFlags(nil)

// Opt into the new klog behavior so that -stderrthreshold is honored even
// when -logtostderr=true (the default). Without this, all log levels are
// unconditionally sent to stderr and users cannot filter by severity.
// Requires klog v2.140.0+ (kubernetes/klog#432).
if err := flag.CommandLine.Set("legacy_stderr_threshold_behavior", "false"); err != nil {
klog.Fatalf("Failed to set legacy_stderr_threshold_behavior: %v", err)
}
if err := flag.CommandLine.Set("stderrthreshold", "INFO"); err != nil {
klog.Fatalf("Failed to set stderrthreshold: %v", err)
}
Comment on lines +262 to +271
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

These flag.CommandLine.Set(...) calls will fail unless klog has registered its flags on flag.CommandLine (via klog.InitFlags(...)). This file currently doesn’t initialize klog flags, so the adapter will exit early with "no such flag". Also note that this command already defines a pflag --stderrthreshold (currently documented as a no-op); even after initializing klog flags, users changing the existing pflag won’t affect klog unless you explicitly propagate the parsed stdErrThreshold value into klog (for example, after parsing, call flag.CommandLine.Set("stderrthreshold", stdErrThreshold) when the flag was provided).

Copilot uses AI. Check for mistakes.

cmd.Flags().AddGoFlagSet(flag.CommandLine)

if err := cmd.Flags().Parse(os.Args); err != nil {
Expand Down
16 changes: 16 additions & 0 deletions cmd/operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
_ "k8s.io/client-go/plugin/pkg/client/auth"
"k8s.io/client-go/tools/cache"
"k8s.io/klog/v2"
ctrl "sigs.k8s.io/controller-runtime"
ctrlcache "sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/controller"
Expand Down Expand Up @@ -118,6 +119,21 @@ func main() {
pflag.StringVar(&filePathAuthRootPath, "filepath-auth-root-path", "", "Allowed filesystem path for KEDA to read auth from.")
opts := zap.Options{}
opts.BindFlags(flag.CommandLine)

// Register klog flags on flag.CommandLine so they can be set programmatically.
klog.InitFlags(nil)

// Opt into the new klog behavior so that -stderrthreshold is honored even
// when -logtostderr=true (the default). Without this, all log levels are
// unconditionally sent to stderr and users cannot filter by severity.
// Requires klog v2.140.0+ (kubernetes/klog#432).
if err := flag.CommandLine.Set("legacy_stderr_threshold_behavior", "false"); err != nil {
klog.Fatalf("Failed to set legacy_stderr_threshold_behavior: %v", err)
}
if err := flag.CommandLine.Set("stderrthreshold", "INFO"); err != nil {
klog.Fatalf("Failed to set stderrthreshold: %v", err)
}
Comment on lines +126 to +135
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

flag.CommandLine.Set("legacy_stderr_threshold_behavior", ...) / Set("stderrthreshold", ...) will fail unless the klog flags have been registered on flag.CommandLine first. This binary doesn’t call klog.InitFlags(...) (and the stdlib flag package won’t pick up klog’s internal flagset automatically), so these Set calls will return "no such flag" and the process will exit via klog.Fatalf. Call klog.InitFlags(nil) (or klog.InitFlags(flag.CommandLine)) before setting these values, then add the Go flagset to pflag and parse so users can override them via CLI.

Copilot uses AI. Check for mistakes.

pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
pflag.Parse()

Expand Down
16 changes: 16 additions & 0 deletions cmd/webhooks/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
_ "k8s.io/client-go/plugin/pkg/client/auth"
"k8s.io/klog/v2"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
Expand Down Expand Up @@ -73,6 +74,21 @@ func main() {

opts := zap.Options{}
opts.BindFlags(flag.CommandLine)

// Register klog flags on flag.CommandLine so they can be set programmatically.
klog.InitFlags(nil)

// Opt into the new klog behavior so that -stderrthreshold is honored even
// when -logtostderr=true (the default). Without this, all log levels are
// unconditionally sent to stderr and users cannot filter by severity.
// Requires klog v2.140.0+ (kubernetes/klog#432).
if err := flag.CommandLine.Set("legacy_stderr_threshold_behavior", "false"); err != nil {
klog.Fatalf("Failed to set legacy_stderr_threshold_behavior: %v", err)
}
if err := flag.CommandLine.Set("stderrthreshold", "INFO"); err != nil {
klog.Fatalf("Failed to set stderrthreshold: %v", err)
}
Comment on lines +81 to +90
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

Same issue as in the operator: these flag.CommandLine.Set(...) calls depend on klog flags being registered on the Go flagset first. Without an earlier klog.InitFlags(...), Set will fail with "no such flag" and the program will terminate via klog.Fatalf. Initialize klog flags before these Set calls.

Copilot uses AI. Check for mistakes.

pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
pflag.Parse()

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ require (
k8s.io/client-go v0.35.3
k8s.io/code-generator v0.35.3
k8s.io/component-base v0.35.0
k8s.io/klog/v2 v2.130.1
k8s.io/klog/v2 v2.140.0
k8s.io/kube-openapi v0.0.0-20260127142750-a19766b6e2d4
k8s.io/metrics v0.35.0
k8s.io/utils v0.0.0-20260108192941-914a6e750570
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1353,8 +1353,8 @@ k8s.io/component-base v0.34.3 h1:zsEgw6ELqK0XncCQomgO9DpUIzlrYuZYA0Cgo+JWpVk=
k8s.io/component-base v0.34.3/go.mod h1:5iIlD8wPfWE/xSHTRfbjuvUul2WZbI2nOUK65XL0E/c=
k8s.io/gengo/v2 v2.0.0-20250903151518-081d64401ab4 h1:I8k0vOOD2ZQWs3PtYXC0mjJdlIMriS0O/N+RjSkWB48=
k8s.io/gengo/v2 v2.0.0-20250903151518-081d64401ab4/go.mod h1:CgujABENc3KuTrcsdpGmrrASjtQsWCT7R99mEV4U/fM=
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
k8s.io/klog/v2 v2.140.0 h1:Tf+J3AH7xnUzZyVVXhTgGhEKnFqye14aadWv7bzXdzc=
k8s.io/klog/v2 v2.140.0/go.mod h1:o+/RWfJ6PwpnFn7OyAG3QnO47BFsymfEfrz6XyYSSp0=
k8s.io/kms v0.35.0 h1:/x87FED2kDSo66csKtcYCEHsxF/DBlNl7LfJ1fVQs1o=
k8s.io/kms v0.35.0/go.mod h1:VT+4ekZAdrZDMgShK37vvlyHUVhwI9t/9tvh0AyCWmQ=
k8s.io/kube-aggregator v0.35.2 h1:bnF7E238wUOVaPpTyKrqGCAEXOAJ6HRTARvJTZ0UIC0=
Expand Down
2 changes: 0 additions & 2 deletions vendor/k8s.io/klog/v2/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading