Skip to content

autoscaler: populate status, conditions, and observedGeneration for homogeneous and heterogeneous policies - #1470

Open
bhuvan-somisetty wants to merge 2 commits into
volcano-sh:mainfrom
bhuvan-somisetty:fix/autoscaler-homogeneous-heterogeneous-status-1469
Open

autoscaler: populate status, conditions, and observedGeneration for homogeneous and heterogeneous policies#1470
bhuvan-somisetty wants to merge 2 commits into
volcano-sh:mainfrom
bhuvan-somisetty:fix/autoscaler-homogeneous-heterogeneous-status-1469

Conversation

@bhuvan-somisetty

Copy link
Copy Markdown
Contributor

What type of PR is this?

/kind bug

What this PR does / why we need it:

AutoscaleController previously only updated AutoscalingPolicy custom resource status for DisaggregatedTarget policies (via updateDisaggregatedPolicyStatus). For HomogeneousTarget and HeterogeneousTarget policies, doScale and doOptimize executed the replica scaling patches on ModelServing instances but omitted updating .status on the AutoscalingPolicy custom resource entirely.

As a result, AutoscalingPolicy resources using homogeneous or heterogeneous scaling targets remained with empty status blocks (status: {}), leaving observedGeneration, conditions (Ready, TargetFound), homogeneousStatus, and heterogeneousStatus unpopulated.

This PR adds status update helpers and integrates them into doScale and doOptimize:

  • updateHomogeneousPolicyStatus: Writes ObservedGeneration, Conditions (Ready, TargetFound), and HomogeneousStatus (current/desired replicas, mode, last scale time).
  • updateHeterogeneousPolicyStatus: Writes ObservedGeneration, Conditions (Ready, TargetFound), and HeterogeneousStatus (per-target current/desired replicas, mode, last scale time).
  • Employs retry.RetryOnConflict with a fallback API read strategy to handle status update conflicts cleanly.

Which issue(s) this PR fixes:
Fixes #1469

Bug evidence (required for bug-related PRs):

Source path inspection:

  • doScale in pkg/autoscaler/controller/autoscale_controller.go scaled target replicas but had no status update call.
  • doOptimize in pkg/autoscaler/controller/autoscale_controller.go scaled target replicas across heterogeneous backends but had no status update call.
  • AutoscalingPolicyStatus API definition in pkg/apis/workload/v1alpha1/autoscalingpolicy_types.go explicitly defines HomogeneousStatus and HeterogeneousStatus, but no corresponding status reconciliation functions existed in AutoscaleController.

Reproduction:

  1. Apply an AutoscalingPolicy with a homogeneousTarget or heterogeneousTarget.
  2. Observe that AutoscaleController reconciles and scales target ModelServing instances.
  3. Check kubectl get asp <name> -o yaml.status is completely empty.

Special notes for your reviewer:

  • Comprehensive unit tests added in pkg/autoscaler/controller/autoscale_controller_test.go:
    • TestUpdateHomogeneousPolicyStatus_Success
    • TestUpdateHomogeneousPolicyStatus_TargetNotFound
    • TestUpdateHeterogeneousPolicyStatus_Success
    • TestUpdateHeterogeneousPolicyStatus_TargetNotFound
  • All 21 tests in pkg/autoscaler/controller pass cleanly.

Does this PR introduce a user-facing change?:

Fix AutoscaleController to populate status, conditions, and observedGeneration for HomogeneousTarget and HeterogeneousTarget AutoscalingPolicies.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@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 git-malu 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

@bhuvan-somisetty

Copy link
Copy Markdown
Contributor Author

/cc @YaoZengzeng @LiZhenCheng9527 @hzxuzhonghu @git-malu

This PR resolves issue #1469 by implementing status update helpers (updateHomogeneousPolicyStatus and updateHeterogeneousPolicyStatus) for HomogeneousTarget and HeterogeneousTarget policies in AutoscaleController. It ensures .status (ObservedGeneration, Conditions, HomogeneousStatus, HeterogeneousStatus) is accurately populated and updated with conflict retry handling.

…omogeneous and heterogeneous policies

The AutoscaleController previously only updated AutoscalingPolicy status for DisaggregatedTarget policies (via updateDisaggregatedPolicyStatus). For HomogeneousTarget and HeterogeneousTarget policies, doScale and doOptimize scaled target ModelServing instances but omitted updating the policy status, leaving status unpopulated in production.

This change introduces updateHomogeneousPolicyStatus and updateHeterogeneousPolicyStatus in AutoscaleController:
- Populates Status.ObservedGeneration to match the policy's generation.
- Populates Status.Conditions (Ready and TargetFound) to reflect reconciliation outcome and target resolution.
- Populates Status.HomogeneousStatus (CurrentReplicas, DesiredReplicas, Mode, LastScaleTime) for HomogeneousTarget policies.
- Populates Status.HeterogeneousStatus (per-target CurrentReplicas, DesiredReplicas, Mode, LastScaleTime) for HeterogeneousTarget policies.
- Uses retry.RetryOnConflict with a fallback read strategy to prevent status update conflicts.

Unit tests in autoscale_controller_test.go verify status generation, condition transitions, and target lookup failures for both policy types.

Signed-off-by: bhuvan-somisetty <somisettybhuvan5@gmail.com>
@bhuvan-somisetty
bhuvan-somisetty force-pushed the fix/autoscaler-homogeneous-heterogeneous-status-1469 branch from acd5ed5 to fe05072 Compare August 1, 2026 12:15
…omogeneous and heterogeneous policies

The AutoscaleController previously only updated AutoscalingPolicy status for DisaggregatedTarget policies (via updateDisaggregatedPolicyStatus). For HomogeneousTarget and HeterogeneousTarget policies, doScale and doOptimize scaled target ModelServing instances but omitted updating the policy status, leaving status unpopulated in production.

This change introduces updateHomogeneousPolicyStatus and updateHeterogeneousPolicyStatus in AutoscaleController:
- Populates Status.ObservedGeneration to match the policy's generation.
- Populates Status.Conditions (Ready and TargetFound) to reflect reconciliation outcome and target resolution.
- Populates Status.HomogeneousStatus (CurrentReplicas, DesiredReplicas, Mode, LastScaleTime) for HomogeneousTarget policies.
- Populates Status.HeterogeneousStatus (per-target CurrentReplicas, DesiredReplicas, Mode, LastScaleTime) for HeterogeneousTarget policies.
- Uses retry.RetryOnConflict with a fallback read strategy to prevent status update conflicts.

Unit tests in autoscale_controller_test.go verify status generation, condition transitions, and target lookup failures for both policy types.

Signed-off-by: bhuvan-somisetty <somisettybhuvan5@gmail.com>
@bhuvan-somisetty

Copy link
Copy Markdown
Contributor Author

cc @YaoZengzeng @LiZhenCheng9527 @hzxuzhonghu @git-malu @FAUST-BENCHOU

Hello maintainers, when you get a chance please take a look at this PR. It populates status fields (ObservedGeneration, Conditions, HomogeneousStatus, and HeterogeneousStatus) for homogeneous and heterogeneous autoscaling policies so their status is no longer left empty in production. All tests are passing.

@bhuvan-somisetty

Copy link
Copy Markdown
Contributor Author

hi @LiZhenCheng9527 PTAL , whenever u get chance

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.

bug: AutoscaleController omits status, conditions, and observedGeneration updates for HomogeneousTarget and HeterogeneousTarget policies

2 participants