Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KEDA doesn't validate empty array of triggers #5520

Closed
SpiritZhou opened this issue Feb 18, 2024 · 6 comments
Closed

KEDA doesn't validate empty array of triggers #5520

SpiritZhou opened this issue Feb 18, 2024 · 6 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@SpiritZhou
Copy link
Contributor

SpiritZhou commented Feb 18, 2024

Report

When triggers is set with an empty array in ScaledObject, KEDA doesn't validate this empty value and will create a default HPA with a default 80% averageUtilization CPU resource. This can mislead users.

Here is the yaml example:

---
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
  name: kafka-scaledobject
spec:
  scaleTargetRef:
    name: sut
  pollingInterval: 30
  minReplicaCount: 3
  maxReplicaCount: 5
  triggers: []

BTW, KEDA will block creation if the value of triggers is empty.

Expected Behavior

Block this creation of ScaledObject if triggers is set with an empty array.

Actual Behavior

ScaledObject is created normally and a default HPA will also be created.

Steps to Reproduce the Problem

  1. Create an ScaledObject with an empy-array triggers.
  2. A CPU-resource HPA will be created soon.

KEDA Version

2.13.0

Kubernetes Version

1.27

Platform

Other

Scaler Details

No response

Anything else?

No response

@SpiritZhou SpiritZhou added the bug Something isn't working label Feb 18, 2024
@vinod827
Copy link
Contributor

vinod827 commented Feb 19, 2024

When triggers is set with an empty array in ScaledObject, KEDA doesn't validate this empty value and will create a default HPA with a default 80% averageUtilization CPU resource. This can mislead users.

hmmm....that's interesting. From where this 80% of averageUtilization for CPU is coming in the HPA?

@SpiritZhou
Copy link
Contributor Author

SpiritZhou commented Feb 19, 2024

When triggers is set with an empty array in ScaledObject, KEDA doesn't validate this empty value and will create a default HPA with a default 80% averageUtilization CPU resource. This can mislead users.

hmmm....that's interesting. From where this 80% of averageUtilization for CPU is coming in the HPA?

It's K8s default behavior. When I create an HPA directly without metrics spec, k8s will create an HPA with 80% of averageUtilization for CPU resource.

HPA example:

apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: test
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: sut
  minReplicas: 1
  maxReplicas: 10

@vinod827
Copy link
Contributor

So that means HPA should not be defaulted to as a scaling option when triggers are empty in the KEDA's ScaledObject

@JorTurFer
Copy link
Member

I think that we should validate it as part of admission hooks and also raise an error in the operator. Adding default value is quite weird as it's totally unrelated with the given triggers. This doesn't happen just with empty triggers but also when there are some issues in the creation loop

@zroubalik zroubalik added the good first issue Good for newcomers label Feb 19, 2024
@zroubalik
Copy link
Member

I agree, we should validate both on the Operator and validation webhook side. This is an ideal "good first issue " :)

@joebowbeer
Copy link
Contributor

joebowbeer commented Oct 23, 2024

It's K8s default behavior. When I create an HPA directly without metrics spec, k8s will create an HPA with 80% of averageUtilization for CPU resource.

Yes, this is k8s default behavior, as described in both k8s and KEDA documentation, and we have been relying on it.

I think this new behavior is a breaking change and a regression.

Can this be reverted? Or at least, can an option to configure it be added?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
Archived in project
Development

No branches or pull requests

5 participants