kedacore / keda

KEDA is a Kubernetes-based Event Driven Autoscaling component. It provides event driven scale for any container running in Kubernetes
https://keda.sh
Apache License 2.0
8.3k stars 1.05k forks source link

ScaledObject shows condition status `ScalerNotActive` when it should always be active #6145

Open lantingchiang opened 1 week ago

lantingchiang commented 1 week ago

Report

We have a scaler with minReplicaCount > 0 and activationThreshold unset. Based on https://keda.sh/docs/2.8/concepts/scaling-deployments/#managing-activation--scaling-thresholds,

If the minimum replicas is >= 1, the scaler is always active and the activation value will be ignored.

We expect our scaler to be always active and scaling to be handled by the HPA controller (i.e. we're not utilizing the 0 <-> 1 scaling provided by keda-operator). However, we're seeing our scaled objects showing inactive status like so:

Status:
  Conditions:
    Message:  ScaledObject is defined correctly and is ready for scaling
    Reason:   ScaledObjectReady
    Status:   True
    Type:     Ready
    Message:  Scaling is not performed because triggers are not active
    Reason:   ScalerNotActive
    Status:   False
    Type:     Active
    Message:  No fallbacks are active on this scaled object
    Reason:   NoFallbackFound
    Status:   False
    Type:     Fallback
  External Metric Names:
    s0-prometheus-test_metric
  Health:
    s0-prometheus-test_metric:
      Number Of Failures:  0
      Status:              Happy

We have verified that the query is correct and returns metrics with a cardinality of one, and that the scaledobject isn't exhibiting any errors.

Scaled Object spec:

apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
  name: test-scaledobject
  namespace: test-ns
spec:
  fallback:
    failureThreshold: 3
    replicas: 3
  maxReplicaCount: 3
  minReplicaCount: 1
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: test-dep
  triggers:
  - authenticationRef:
      kind: ClusterTriggerAuthentication
      name: keda-prom-creds
    metadata:
      authModes: bearer
      metricName: test_metric
      metricType: AverageValue
      query: |
        REDACTED
      serverAddress: REDACTED
      threshold: "5"
    type: prometheus

Keda version: 2.8 K8s version: 1.22.17

Expected Behavior

Since we set minReplicaCount >= 1 and do not set activationThreshold (which defaults to 0), we expect the condition to always show that the scaledobject is active.

Actual Behavior

We saw that the scaledobject is showing condition inactive:

    Message:  Scaling is not performed because triggers are not active
    Reason:   ScalerNotActive
    Status:   False
    Type:     Active

We've seen this both when the metric value returned by the query is 0 and when the metric value returned by the query is > 0.

Steps to Reproduce the Problem

Uncertain

Logs from KEDA operator

No response

KEDA Version

< 2.11.0

Kubernetes Version

< 1.28

Platform

Amazon Web Services

Scaler Details

Prometheus

Anything else?

No response

joebowbeer commented 6 days ago

Does this repro in a recent version?

https://keda.sh/docs/2.15/concepts/scaling-deployments/#activating-and-scaling-thresholds

zroubalik commented 1 day ago

Does this repro in a recent version?

https://keda.sh/docs/2.15/concepts/scaling-deployments/#activating-and-scaling-thresholds

💯