Skip to content

FEAT: support idleReplicaCount=0 rendering in Rollout Deployment KEDA template#6972

Open
lokesh-devtron wants to merge 4 commits into
mainfrom
keda-idleReplicaCount-fix
Open

FEAT: support idleReplicaCount=0 rendering in Rollout Deployment KEDA template#6972
lokesh-devtron wants to merge 4 commits into
mainfrom
keda-idleReplicaCount-fix

Conversation

@lokesh-devtron

@lokesh-devtron lokesh-devtron commented Jun 25, 2026

Copy link
Copy Markdown

Type of change

  • Bug fix

Description

Problem Statement

When kedaAutoscaling.idleReplicaCount is configured with the value 0, the generated KEDA ScaledObject does not render the idleReplicaCount field.

The existing Helm template uses the following condition:

{{- if $.Values.kedaAutoscaling.idleReplicaCount }}

Since Helm evaluates 0 as a false value, the condition fails and the field is omitted from the rendered manifest.

As a result, users cannot explicitly configure:

idleReplicaCount: 0

even when it is provided in the deployment template values.

Root Cause

The template checks the truthiness of the value instead of checking whether the value is defined.

Fix

Updated the template condition to explicitly check for nil:

{{- if ne $.Values.kedaAutoscaling.idleReplicaCount nil }}

This ensures that:

  • idleReplicaCount: 0 is rendered correctly.
  • Any non-zero value is also rendered.
  • The field is omitted only when it is not configured.

Additionally, added the default idleReplicaCount: 0 in values.yaml for consistency.

Testing

  • Updated the Rollout Deployment reference chart.
  • Verified the rendered ScaledObject manifest includes:
idleReplicaCount: 0

when configured in values.

Impact

This change preserves existing behavior while correctly supporting explicit zero values for idleReplicaCount.

Summary by Bito

  • Updated KEDA autoscaling template to correctly handle idleReplicaCount when set to 0 by checking for nil instead of truthiness.
  • Added idleReplicaCount with a default value of 0 to the autoscaling configuration in values.yaml.

@github-actions

Copy link
Copy Markdown

Some linked issues are invalid. Please update the issue links:\nIssue # in is not found or invalid (HTTP }404).\n

@github-actions

Copy link
Copy Markdown

Some linked issues are invalid. Please update the issue links:\nIssue # in is not found or invalid (HTTP }404).\n

@lokesh-devtron lokesh-devtron changed the title fix: support idleReplicaCount=0 rendering in Rollout Deployment KEDA template FEAT: support idleReplicaCount=0 rendering in Rollout Deployment KEDA template Jun 25, 2026
@github-actions

Copy link
Copy Markdown

Some linked issues are invalid. Please update the issue links:\nIssue # in is not found or invalid (HTTP }404).\n

@github-actions

Copy link
Copy Markdown

Some linked issues are invalid. Please update the issue links:\nIssue # in is not found or invalid (HTTP }404).\n

cooldownPeriod: 300 # Optional. Default: 300 seconds
minReplicaCount: 1
maxReplicaCount: 2
idleReplicaCount: 0

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lokesh-devtron Why are we including idleReplicaCount: 0 in default values?

@YashasviDevtron previously removed it to fix an issue, can you please verify #6729 once?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

@YashasviDevtron YashasviDevtron Jul 1, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lokesh-devtron idleReplicaCount: 0 was hardcoded into the chart's default values.yaml, so it showed up in every KEDA app's ScaledObject even if the user didn't configure it , meaning pods could get scaled down below minReplicaCount even when user nerver wanted that. That's a problem because it quietly changes behavior: it lets KEDA scale a workload all the way down to zero pods when idle, even for apps that assumed minReplicaCount was a hard floor they'd never drop below, leading to unnecessary downscaling.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the user didn't configure any idleReplicaCount value, it should work purely on minReplicaCount/maxReplicaCount, not silently pick up idleReplicaCount on its own. Removing it from the defaults fixed that, if it's not set, it's just not there, so the manifest skips it and apps go back to their normal min/max replica behavior.

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

Some linked issues are invalid. Please update the issue links:\nIssue # in is not found or invalid (HTTP }404).\n

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

Some linked issues are invalid. Please update the issue links:\nIssue # in is not found or invalid (HTTP }404).\n

@sonarqubecloud

sonarqubecloud Bot commented Jul 2, 2026

Copy link
Copy Markdown

@lokesh-devtron

Copy link
Copy Markdown
Author

Hi @prakarsh-dt

I discussed this with @YashasviDevtron and verified the previous change. Based on the feedback, I have removed the default idleReplicaCount from the values.yaml files across all affected charts.

The template change ({{- if ne $.Values.kedaAutoscaling.idleReplicaCount nil }}) has been retained, so idleReplicaCount will now be rendered only when it is explicitly configured by the user through values/overrides, while preserving the existing default behavior.

Kindly review the updated changes. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants