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

HTTP Add-On uses wrong default value for maxReplicaCount #607

Closed
t0rr3sp3dr0 opened this issue Feb 21, 2023 · 0 comments · Fixed by #610
Closed

HTTP Add-On uses wrong default value for maxReplicaCount #607

t0rr3sp3dr0 opened this issue Feb 21, 2023 · 0 comments · Fixed by #610
Labels
bug Something isn't working

Comments

@t0rr3sp3dr0
Copy link
Contributor

Report

When creating a HTTPScaledObject, it's optional to set .spec.replicas.max. This should result on the creation of a ScaledObject with .spec.maxReplicaCount unset, causing the ScaledObject controller use the default value of 100 for the field. But the add-on is creating a ScaledObject with .spec.maxReplicaCount set to 0, leading to an unexpected behaviour to users going through Keda's documentation.

Expected Behavior

The add-on shouldn't set .spec.maxReplicaCount to 0 unless explicitly defined by the user.

Actual Behavior

The add-on is setting .spec.maxReplicaCount to 0 by default.

Steps to Reproduce the Problem

  1. Create a HTTPScaledObject without specifying .spec.replicas.max.
  2. Check that the ScaledObject created by the add-on has .spec.maxReplicaCount set to 0 instead of being undefined.

Logs from KEDA HTTP operator

N/A

What version of the KEDA HTTP Add-on are you running?

0.4.0

Kubernetes Version

1.24

Platform

Microsoft Azure

Anything else?

The problem originates on the struct definition of HTTPScaledObject for .spec.replicas. Its members are not pointers, so they will have Golang Zero Values (https://go.dev/tour/basics/12) by default. This is not a problem on most fields, but .spec.maxReplicaCount, just like some other fields (https://keda.sh/docs/2.0/concepts/scaling-deployments/#scaledobject-spec), has a non-zero default value, making the use of non-pointer attributes a problem.

type ReplicaStruct struct {
// Minimum amount of replicas to have in the deployment (Default 0)
Min int32 `json:"min,omitempty" description:"Minimum amount of replicas to have in the deployment (Default 0)"`
// Maximum amount of replicas to have in the deployment (Default 100)
Max int32 `json:"max,omitempty" description:"Maximum amount of replicas to have in the deployment (Default 100)"`
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant