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

Deployment scaled to 0 due to inactivity even when minReplicaCount >= 1 #4995

Closed
dagvl opened this issue Sep 24, 2023 · 3 comments
Closed

Deployment scaled to 0 due to inactivity even when minReplicaCount >= 1 #4995

dagvl opened this issue Sep 24, 2023 · 3 comments
Labels
bug Something isn't working stale All issues that are marked as stale due to inactivity

Comments

@dagvl
Copy link

dagvl commented Sep 24, 2023

Report

The docs at https://keda.sh/docs/2.11/concepts/scaling-deployments/#managing-activation--scaling-thresholds say:

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

However, with keda 2.11.2 we see that this is not always true. If a ScaledObject has:

idleReplicaCount: 0
minReplicaCount: 2

and use the cron trigger, the Deployment ends up scaled to 0 when the cron trigger is inactive which is unexpected based on the docs.

Expected Behavior

Given that minReplicaCount: 2, I expect the activation value to be ignored as per docs

Actual Behavior

It scales the deployment to 0 when the cron trigger is inactive.

Steps to Reproduce the Problem

Example with keda 2.11.2.

Install keda with: helm upgrade --install keda kedacore/keda --namespace keda --version 2.11.2 --create-namespace

Create nginx deployment and scaledobject:

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
        - name: nginx
          image: nginx:1.25.2
          ports:
            - containerPort: 80
          resources:
            limits:
              cpu: 100m
              memory: 128Mi
            requests:
              cpu: 100m
              memory: 128Mi

---
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
  name: nginx
spec:
  scaleTargetRef:
    name: nginx-deployment
  idleReplicaCount: 0
  maxReplicaCount: 5
  minReplicaCount: 2
  pollingInterval: 30
  cooldownPeriod: 0
  advanced:
    horizontalPodAutoscalerConfig:
      behavior:
        scaleDown:
          stabilizationWindowSeconds: 0
  triggers:
  - type: cron
    metadata:
      timezone: "America/Los_Angeles"
      start: "0,10,20,30,40,50 * * * *"
      end: "5,15,25,35,45,55 * * * *"
      desiredReplicas: "3"

Logs from KEDA operator

keda-operator-5bb4454c97-vswjr keda-operator 2023-09-24T18:45:24Z	DEBUG	scale_handler	Getting metrics and activity from scaler	{"scaledObject.Namespace": "default", "scaledObject.Name": "nginx", "scaler": "cronScaler", "metricName": "s1-cron-America-Los_Angeles-0,10,20,30,40,50xxxx-5,15,25,35,45,55xxxx", "metrics": [{"metricName":"s1-cron-America-Los_Angeles-0,10,20,30,40,50xxxx-5,15,25,35,45,55xxxx","metricLabels":null,"timestamp":"2023-09-24T18:45:24Z","value":"1"}], "activity": false, "scalerError": null}
keda-operator-5bb4454c97-vswjr keda-operator 2023-09-24T18:45:24Z	INFO	scaleexecutor	Successfully set ScaleTarget replicas count to ScaledObject idleReplicaCount	{"scaledobject.Name": "nginx", "scaledObject.Namespace": "default", "scaleTarget.Name": "nginx-deployment", "Original Replicas Count": 1, "New Replicas Count": 0}
keda-operator-5bb4454c97-vswjr keda-operator 2023-09-24T18:45:24Z	DEBUG	events	Deactivated apps/v1.Deployment default/nginx-deployment from 1 to 0	{"type": "Normal", "object": {"kind":"ScaledObject","namespace":"default","name":"nginx","uid":"fd7102ce-acf8-4bd4-a1be-5a706f770ade","apiVersion":"keda.sh/v1alpha1","resourceVersion":"208928"}, "reason": "KEDAScaleTargetDeactivated"}

### KEDA Version

2.11.2

### Kubernetes Version

1.25

### Platform

Other

### Scaler Details

cron

### Anything else?

_No response_
@dagvl dagvl added the bug Something isn't working label Sep 24, 2023
@zroubalik
Copy link
Member

Just remove idleReplicaCount: 0, this setting allow you to go directly from idle (0) to a number of replicas that is higher then the default (1). See: https://keda.sh/docs/2.11/concepts/scaling-deployments/#idlereplicacount

Feel free to propose docs fix and update, any update to make the docs more clear is really appreciated!

Copy link

stale bot commented Nov 24, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale All issues that are marked as stale due to inactivity label Nov 24, 2023
Copy link

stale bot commented Dec 1, 2023

This issue has been automatically closed due to inactivity.

@stale stale bot closed this as completed Dec 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale All issues that are marked as stale due to inactivity
Projects
Archived in project
Development

No branches or pull requests

2 participants