Skip to content

Commit

Permalink
fix odd number of arguments passed as key-value pairs for logging (ke…
Browse files Browse the repository at this point in the history
…dacore#4369)

Signed-off-by: Zbynek Roubalik <zroubalik@gmail.com>
  • Loading branch information
zroubalik authored and xoanmm committed Mar 22, 2023
1 parent 0460443 commit 50a46a9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ To learn more about active deprecations, we recommend checking [GitHub Discussio
### Other

- **General**: Drop a transitive dependency on bou.ke/monkey ([#4364](https://github.com/kedacore/keda/issues/4364))
- **General**: Fix odd number of arguments passed as key-value pairs for logging ([#4368](https://github.com/kedacore/keda/issues/4368))

## v2.10.0

Expand Down
8 changes: 4 additions & 4 deletions controllers/keda/scaledobject_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func (r *ScaledObjectReconciler) reconcileScaledObject(ctx context.Context, logg
return "ScaledObject doesn't have correct Idle/Min/Max Replica Counts specification", err
}

err = r.checkTriggers(scaledObject)
err = r.checkTriggers(logger, scaledObject)
if err != nil {
return "ScaledObject doesn't have correct triggers specification", err
}
Expand Down Expand Up @@ -337,7 +337,7 @@ func (r *ScaledObjectReconciler) checkTargetResourceIsScalable(ctx context.Conte
// checkTriggers checks that general trigger metadata are valid, it checks:
// - triggerNames in ScaledObject are unique
// - useCachedMetrics is defined only for a supported triggers
func (r *ScaledObjectReconciler) checkTriggers(scaledObject *kedav1alpha1.ScaledObject) error {
func (r *ScaledObjectReconciler) checkTriggers(logger logr.Logger, scaledObject *kedav1alpha1.ScaledObject) error {
triggersCount := len(scaledObject.Spec.Triggers)

if triggersCount > 1 {
Expand All @@ -355,14 +355,14 @@ func (r *ScaledObjectReconciler) checkTriggers(scaledObject *kedav1alpha1.Scaled
_, hasMetricName := trigger.Metadata["metricName"]
// aws-cloudwatch and huawei-cloudeye have a meaningful use of metricName
if hasMetricName && trigger.Type != "aws-cloudwatch" && trigger.Type != "huawei-cloudeye" {
log.Log.Info("metricName is deprecated and will be removed in v2.12, please do not set it anymore (used in %q)", trigger.Type)
logger.Info("\"metricName\" is deprecated and will be removed in v2.12, please do not set it anymore", "trigger.type", trigger.Type)
}

name := trigger.Name
if name != "" {
if _, found := triggerNames[name]; found {
// found duplicate name
return fmt.Errorf("triggerName=%s is defined multiple times in the ScaledObject, but it must be unique", name)
return fmt.Errorf("triggerName %q is defined multiple times in the ScaledObject, but it must be unique", name)
}
triggerNames[name] = true
}
Expand Down

0 comments on commit 50a46a9

Please sign in to comment.