← Back to Pull requests

test: add HPA autoscaling conformance test for KAR-0057 #104

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Oct 17, 2026 12:17 UTC
Author

Summary

This PR adds TestHPAAutoscaling, an automated conformance test for KAR-0057: Effective HPA Autoscaling for AI Workloads.

The test verifies that Kubernetes HorizontalPodAutoscaler (HPA) correctly scales accelerator-backed workloads using a custom per-Pod metric.

The implementation focuses specifically on HPA behavior rather than duplicating accelerator allocation checks covered by KAR-0051.

Refs #57, #96.

What the Test Covers

The test creates a Deployment whose Pods request an accelerator through DRA or a device plugin, depending on the configured -allocation-mode.

Each Pod performs a startup device check and exposes a controllable custom metric representing a synthetic inference queue depth.

The test uses an autoscaling/v2 HPA with a Pods metric and an AverageValue target of 10.

1. Baseline and negative control

  • Creates a Deployment with one replica.

  • Verifies the Pod becomes Running and Ready.

  • Confirms the custom metrics API reports the baseline metric value of 1.

  • Verifies the HPA reconciles at one replica.

  • Confirms the HPA maintains one replica while the metric remains below target.
  • 2. Scale-up

  • Raises the custom metric to 100.

  • Verifies the HPA scales the Deployment to the configured maximum replica count.

  • Confirms the resulting Pods become Running and Ready.

  • Confirms the custom metrics API reports the updated value for all expected Pods.
  • 3. Scale-down

  • Lowers the custom metric to 2.

  • Verifies the HPA scales the Deployment back to one replica.

  • Confirms the remaining Pod is Running and Ready.
  • 4. Cleanup

  • Removes the test HPA and Deployment.

  • Waits for workload Pods to be removed.

  • Checks that allocated DRA ResourceClaims are released during cleanup.

  • Removes the test namespace.
  • The test verifies HPA autoscaling behavior for accelerator-backed workloads. It does not benchmark inference performance or independently validate accelerator allocation correctness.

    Custom Metrics Requirements

    The test relies on an existing custom metrics pipeline supplied by the platform. It does not install or replace the platform's custom metrics adapter.

    The -hpa-custom-metric-name flag identifies the custom metric used for validation.

    If the platform supports HorizontalPodAutoscaler, it must support custom-metrics-based scaling for this requirement.

    pod_autoscaling may be marked N/A only when the platform does not support HPA itself.

    The test is skipped under -short and when the required custom metric is not configured.

    Configuration details and integration requirements are documented in test/README.md.

    Changes Addressing Maintainer Review

    Thank you to @janetkuo for the detailed review and suggestions.

    This revision addresses all five review comments:

    1. HPA applicability: Updated the skip message and documentation to clarify that N/A applies only when HPA itself is unsupported.

    2. Accelerator allocation checks: Removed detailed DRA and device-plugin allocation validation. The test retains accelerator resource requests, the container startup device check, and Running/Ready verification.

    3. Scale-down verification: Removed redundant Pod deletion and ResourceClaim-release assertions from the scale-down phase. Resource cleanup remains verified separately.

    4. Unit test simplification: Removed simCluster, TestHPAScenario, and simulation-only helpers. Retained pure-helper unit tests and focused tests for error classification and cleanup.

    5. Documentation: Updated the KAR-0057 README to describe the implemented test without pending/proposed wording and aligned test/README.md with the revised implementation.

    An additional correction strengthens the negative-control observation-gap handling, with a focused regression test.

    The revision reduces unnecessary complexity while preserving the core KAR-0057 validation behavior.

    Validation

    The maintainer-review revision was reported to pass the following local checks:

  • go test -v -short -count=1 ./test — 393 passed, 0 failed, 7 skipped.

  • go test -race -short -count=1 ./test — Passed.

  • go vet ./test — Passed.

  • make lint — No issues reported.

  • Repeated targeted HPA tests — Passed.
  • The final observation-gap correction additionally passed formatting, source-integrity, and patch-application checks. The full local Go suite has not been independently rerun after that correction.

    Upstream CI on the latest commit:

  • EasyCLA — Passed.

  • pull-ai-conformance-verify — Passed.

  • pull-ai-conformance-e2e-gcp — Pending at the time of this update.
  • Remaining Validation

    Real end-to-end validation of the HPA scenario on a Kubernetes cluster with two GPUs and a working custom metrics adapter is still pending.

    The existing upstream GCP E2E environment does not provide the custom metrics adapter needed to exercise this opt-in scenario.

    Once the required environment is available, real-cluster results can be added to this PR.

    Scope

    The changes are limited to:

  • test/hpa_autoscaling_test.go

  • test/hpa_autoscaling_unit_test.go

  • test/README.md

  • kars/0057-hpa-autoscaling-for-ai-workloads/README.md
  • Unrelated upstream functionality, including KAR-0061, remains unchanged.

    This PR is ready for further maintainer review. Feedback and suggestions are welcome.

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: janetkuo Review duration: 12770m
    All Vouch review confidence checks passed
    Residual risk 0.28 = Change Risk (0.52) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #104"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 27.7% · Safe to merge
    27.7%