Skip to content

ScaledObject with multiple triggers with non unique name should be rejected at creation #4664

Closed
@nonoswz

Description

Report

Hi,

We just upgraded from Keda 2.5 to 2.10.0. We have ScaledObject with multiple triggers with non-unique name. This change was introduced to ensure names are unique amongst all triggers in a ScaledObject.

We were not aware about this change until we saw the following error logs on our end:

2023-06-07T20:40:11Z	ERROR	Reconciler error	{"controller": "scaledobject", "controllerGroup": "keda.sh", "controllerKind": "ScaledObject", "ScaledObject": {"name":"<service-name>","namespace":"<service-name>"}, "namespace": "<service-name>", "name": "<service-name>", "reconcileID": "76264394-339a-4440-9ced-bd3faa280a1b", "error": "triggerName=cron is defined multiple times in the ScaledObject, but it must be unique"}

After investigation we found out few of our ScaledObject indeed have multiple times the same name, such as the following one:

spec:
  maxReplicaCount: 220
  minReplicaCount: 100
  scaleTargetRef:
    apiVersion: apps/v1
    envSourceContainerName: <service-name>
    kind: Deployment
    name: <service-name>
  triggers:
  - metadata:
      type: Utilization
      value: "80"
    name: memory
    type: memory
  - metadata:
      type: Utilization
      value: "65"
    name: cpu
    type: cpu
  - metadata:
      desiredReplicas: "170"
      end: 0 23 * * MON-FRI
      start: 0 8 * * MON-FRI
      timezone: America/New_York
    name: cron
    type: cron
  - metadata:
      desiredReplicas: "135"
      end: 0 23 * * SAT
      start: 0 9 * * SAT
      timezone: America/New_York
    name: cron
    type: cron
  - metadata:
      desiredReplicas: "135"
      end: 0 23 * * SUN
      start: 0 9 * * SUN
      timezone: America/New_York
    name: cron
    type: cron

We understand the change, so we removed the name from the triggers as it's an optional field.

We do think, there is a bug as we are still able to create a ScaledObject with non unique trigger names with 2.10.0. This is actually pretty confusing as the object would be created properly, but the underlying HPA would never be created or reconciled. So it is misleading. Could you please ensure a ScaledObject with multiple triggers with non unique name is rejected at creation? Thanks.

Expected Behavior

A ScaledObject with non unique trigger name should be rejected at creation.

Actual Behavior

A ScaledObject with non unique trigger name can be created, then the underlying HPA is never created or reconciled.

Steps to Reproduce the Problem

  1. Create a scaledObject with mutlitple triggers with the same name, such as the object in the description above.
  2. Get the HPA, and see that it is never created
  3. Check Keda logs and you will see the HPA cannot be reconciled.

Logs from KEDA operator

I replaced our service-name in the logs.

2023-06-07T20:40:11Z	ERROR	Reconciler error	{"controller": "scaledobject", "controllerGroup": "keda.sh", "controllerKind": "ScaledObject", "ScaledObject": {"name":"<service-name>","namespace":"<service-name>"}, "namespace": "<service-name>", "name": "<service-name>", "reconcileID": "76264394-339a-4440-9ced-bd3faa280a1b", "error": "triggerName=cron is defined multiple times in the ScaledObject, but it must be unique"}
2023-06-07T20:40:11Z	ERROR	ScaledObject doesn't have correct triggers specification	{"controller": "scaledobject", "controllerGroup": "keda.sh", "controllerKind": "ScaledObject", "ScaledObject": {"name":"<service-name>","namespace":"<service-name>"}, "namespace": "<service-name>", "name": "<service-name>", "reconcileID": "76264394-339a-4440-9ced-bd3faa280a1b", "error": "triggerName=cron is defined multiple times in the ScaledObject, but it must be unique"}

KEDA Version

2.10.0

Kubernetes Version

1.24

Platform

Amazon Web Services

Scaler Details

cpu/memory/cron

Anything else?

No response

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

  • Status

    Ready To Ship

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions