Skip to content

change AutoscalingPolicyBinding minReplicas minimum from 0 to 1#904

Open
Abirdcfly wants to merge 1 commit intovolcano-sh:mainfrom
Abirdcfly:min2zero
Open

change AutoscalingPolicyBinding minReplicas minimum from 0 to 1#904
Abirdcfly wants to merge 1 commit intovolcano-sh:mainfrom
Abirdcfly:min2zero

Conversation

@Abirdcfly
Copy link
Copy Markdown
Contributor

What type of PR is this?
/kind bug

What this PR does / why we need it:

  1. User Guide: Kthena Autoscaler
    show:

    - **minReplicas**: Minimum number of instances to maintain, ensuring baseline availability
    - Must be greater than or equal to 1

  2. When minReplicas=0, workloads scale down to 0 and cannot auto-scale back up - no running pods mean no metrics collection, so autoscaler always skips recommendation calculation, requires manual intervention to restore. controller logs always show pod list is null and skip recommended instances
    Which issue(s) this PR fixes:
    Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

change AutoscalingPolicyBinding minReplicas minimum from 0 to 1

Signed-off-by: Abirdcfly <fp544037857@gmail.com>
Copilot AI review requested due to automatic review settings April 21, 2026 06:10
@volcano-sh-bot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign lizhencheng9527 for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@volcano-sh-bot
Copy link
Copy Markdown
Contributor

Welcome @Abirdcfly! It looks like this is your first PR to volcano-sh/kthena 🎉

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR raises the minimum allowed minReplicas for AutoscalingPolicyBinding’s homogeneous target from 0 to 1 to prevent scale-to-zero from getting “stuck” (no pods → no metrics → autoscaler skips recommendations), and updates the shipped CRD/doc artifacts accordingly.

Changes:

  • Update kubebuilder validation for HomogeneousTarget.minReplicas to Minimum=1
  • Update generated CRD reference documentation to reflect the new minimum
  • Update the Helm chart CRD schema to enforce minimum: 1 for homogeneous minReplicas

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
pkg/apis/workload/v1alpha1/autoscalingpolicybinding_types.go Tightens API validation for homogeneous minReplicas from 0 → 1
docs/kthena/docs/reference/crd/workload.serving.volcano.sh.md Updates CRD reference table to reflect the new minimum
charts/kthena/charts/workload/crds/workload.serving.volcano.sh_autoscalingpolicybindings.yaml Updates Helm-distributed CRD OpenAPI schema minimum for homogeneous minReplicas

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 65 to 68
// MinReplicas defines the minimum number of replicas to maintain.
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Minimum=1
// +kubebuilder:validation:Maximum=1000000
MinReplicas int32 `json:"minReplicas"`
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

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

This change tightens validation for HomogeneousTarget.minReplicas, but AutoscalingPolicyBinding also has HeterogeneousTargetParam.minReplicas still allowing 0. If all heterogeneous params are configured with minReplicas=0 and the workloads scale to 0, the optimizer path can still get stuck skipping recommendations (no pods => no metrics) and never scale back up. Consider also enforcing a non-zero floor for heterogeneous mode (e.g., an XValidation requiring sum(params[].minReplicas) >= 1 or at least one param.minReplicas >= 1), or adjusting the recommendation logic to recover from 0 replicas without metrics.

Copilot uses AI. Check for mistakes.
Target Target `json:"target,omitempty"`
// MinReplicas defines the minimum number of replicas to maintain.
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Minimum=1
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

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

Raising the CRD minimum from 0 to 1 is a breaking validation change: existing AutoscalingPolicyBinding objects with spec.homogeneousTarget.minReplicas=0 will become invalid and may block updates/helm upgrades until users edit them. Consider adding an explicit upgrade note (and/or a conversion/mutating webhook behavior) so clusters can migrate smoothly.

Suggested change
// +kubebuilder:validation:Minimum=1
// Keep 0 allowed for backward compatibility with existing persisted AutoscalingPolicyBinding objects.
// +kubebuilder:validation:Minimum=0

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the minimum value for minReplicas from 0 to 1 across the CRD definition, documentation, and the HomogeneousTarget struct to prevent autoscaling issues. A review comment identifies that the same change should be applied to the HeterogeneousTargetParam struct to ensure consistency and prevent similar issues when using heterogeneous targets.

Target Target `json:"target,omitempty"`
// MinReplicas defines the minimum number of replicas to maintain.
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Minimum=1
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The change to minReplicas minimum should also be applied to HeterogeneousTargetParam (line 116) to ensure consistency and prevent the same 'scale to 0' issue when using heterogeneous targets. Currently, HeterogeneousTargetParam.MinReplicas still allows a minimum of 0, which according to the PR description, causes the autoscaler to skip recommendation calculations due to lack of metrics.

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