Skip to content

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

Closed
@t0rr3sp3dr0

Description

@t0rr3sp3dr0

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)"`
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions