Skip to content

fix: E2E improvements and pending-aware saturation scaling - #549

Merged
clubanderson merged 1 commit into
mainfrom
fix/model-label-mismatch
Jan 9, 2026
Merged

fix: E2E improvements and pending-aware saturation scaling#549
clubanderson merged 1 commit into
mainfrom
fix/model-label-mismatch

Conversation

@clubanderson

@clubanderson clubanderson commented Jan 8, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR adds pending-aware scaling to prevent cascade scale-ups and fixes E2E test stability issues.

Changes

Pending-Aware Saturation Scaling

  • Add PendingReplicas field to VariantState interface to track pods that are starting but not yet ready
  • Detect pending replicas by comparing spec.replicas vs status.readyReplicas in the saturation engine
  • Skip additional scale-up decisions when pending replicas exist, preventing cascade scaling that wastes resources
  • Prevents the autoscaler from repeatedly triggering scale-ups while pods are still loading models

Namespace Collision Fix

  • Fix model grouping in saturation engine to include namespace in the group key
  • Prevents incorrect metric aggregation when the same model is deployed in multiple namespaces

E2E Test Stability

  • Add deployment stability check before starting load generation tests
  • Wait for spec.replicas == status.replicas == status.readyReplicas (no pods in transition)
  • Remove workaround that dynamically adjusted baseline during tests
  • Ensures tests measure scale-up from a truly stable baseline state

Kind Emulator Improvements

  • Add utility functions for running kubectl commands and getting pod metrics
  • Improve test infrastructure reliability

Test Plan

  • Unit tests pass (make test)
  • Local E2E tests pass (make test-e2e)
  • OpenShift E2E tests pass (CI)
  • Verified pending-aware logic triggers correctly under load
  • Verified deployment stability check prevents race conditions

EPP Pod Readiness Analysis

Analysis of the EPP (Endpoint Picker) codebase to validate the pending-aware scaling heuristic.

Key Finding: EPP Only Routes to Ready Pods

1. Pod Readiness Check (pkg/epp/util/pod/pod.go)

func IsPodReady(pod *corev1.Pod) bool {
    if !pod.DeletionTimestamp.IsZero() {
        return false  // Being deleted = not ready
    }
    // Check for PodReady condition = True
    for _, condition := range pod.Status.Conditions {
        if condition.Type == corev1.PodReady {
            return condition.Status == corev1.ConditionTrue
        }
    }
    return false
}

2. Pod Reconciler (pkg/epp/controller/pod_reconciler.go:91-102)

func (c *PodReconciler) updateDatastore(logger logr.Logger, pod *corev1.Pod) {
    if !podutil.IsPodReady(pod) || !c.Datastore.PoolLabelsMatch(pod.Labels) {
        c.Datastore.PodDelete(pod.Name)  // NOT READY → REMOVE from routing pool
    } else {
        c.Datastore.PodUpdateOrAddIfNotExist(pod)  // READY → ADD to routing pool
    }
}

3. Pod Resync (pkg/epp/datastore/datastore.go:330-334)

for _, pod := range podList.Items {
    if !podutil.IsPodReady(&pod) {
        continue  // Skip non-ready pods entirely
    }
    // ... add to datastore
}

Implications for WVA Pending-Aware Scaling

EPP Behavior WVA Impact
Non-ready pods are excluded from routing pool Traffic only goes to ready pods
Pending pods receive zero traffic Queue builds on ready pods only
Pod becomes ready → immediately added to pool New capacity comes online instantly

Validation of WVA Heuristic

Our pending-aware scaling is correct because:

  1. EPP won't route to pending pods - So when WVA sees queue buildup, it's only on ready pods
  2. Scaling up while pending exists is wasteful - The pending pod will add capacity once ready, but EPP can't use it yet
  3. Waiting for pending→ready is the right call - Once ready, EPP immediately routes traffic, reducing queue pressure

Potential edge case to consider:

  • If a pending pod takes too long to become ready (model loading), the ready pods may become severely overloaded
  • WVA could consider a timeout: "if pending for >X minutes, scale up anyway"

Bottom line: EPP's behavior validates our pending-aware heuristic. EPP only routes to ready pods, so waiting for pending pods to become ready before scaling further is correct.

Copilot AI review requested due to automatic review settings January 8, 2026 19:43

Copilot AI left a comment

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.

Pull request overview

This PR fixes a label mismatch between vLLM pods and the WVA ServiceMonitor selector by ensuring the llm-d.ai/model label is set to match the deployment name during E2E setup.

  • Updates the deploy_llm_d_infrastructure() function to set the model label via yq before deploying llm-d components
  • Addresses a default label value issue in the llm-d-modelservice chart that prevented proper ServiceMonitor selection

Copilot AI review requested due to automatic review settings January 8, 2026 20:55

Copilot AI left a comment

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.

Pull request overview

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

Comment thread test/utils/e2eutils.go Outdated
Comment thread test/utils/e2eutils.go Outdated
Copilot AI review requested due to automatic review settings January 8, 2026 21:04

Copilot AI left a comment

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.

Pull request overview

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

Comment thread test/utils/e2eutils.go Outdated
Comment thread test/e2e-openshift/sharegpt_scaleup_test.go Outdated
Copilot AI review requested due to automatic review settings January 8, 2026 21:11

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread test/utils/e2eutils.go
Copilot AI review requested due to automatic review settings January 8, 2026 21:30

Copilot AI left a comment

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.

Pull request overview

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

Comment thread test/utils/e2eutils.go Outdated
Comment thread internal/engines/saturation/engine.go Outdated
Copilot AI review requested due to automatic review settings January 8, 2026 21:44

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Comment thread test/e2e-openshift/sharegpt_scaleup_test.go Outdated
Comment thread deploy/kind-emulator/setup.sh Outdated
Comment thread test/utils/e2eutils.go Outdated
Comment thread test/utils/e2eutils.go Outdated
Copilot AI review requested due to automatic review settings January 8, 2026 21:47
@clubanderson
clubanderson force-pushed the fix/model-label-mismatch branch from ec39c3c to faf9243 Compare January 8, 2026 21:47

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Comment thread internal/engines/saturation/engine.go
Copilot AI review requested due to automatic review settings January 8, 2026 22:08

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comment thread test/utils/e2eutils.go
Copilot AI review requested due to automatic review settings January 8, 2026 22:22

Copilot AI left a comment

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.

Pull request overview

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

Comment thread test/e2e-openshift/sharegpt_scaleup_test.go Outdated
Comment thread internal/engines/saturation/engine.go
Copilot AI review requested due to automatic review settings January 8, 2026 22:52

Copilot AI left a comment

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.

Pull request overview

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

Comment thread test/utils/e2eutils.go Outdated
Comment thread internal/saturation/analyzer.go Outdated
@clubanderson clubanderson changed the title fix: Set model label to match deployment name in E2E setup fix: E2E improvements and pending-aware saturation scaling Jan 9, 2026
@clubanderson
clubanderson force-pushed the fix/model-label-mismatch branch from 33283a1 to f0aa474 Compare January 9, 2026 00:23
Copilot AI review requested due to automatic review settings January 9, 2026 00:23

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Comment thread internal/saturation/analyzer.go Outdated
@clubanderson
clubanderson force-pushed the fix/model-label-mismatch branch 2 times, most recently from bda0b48 to c40f9f7 Compare January 9, 2026 00:35

@asm582 asm582 left a comment

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.

Address review

@asm582 asm582 left a comment

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.

Need design input

Comment thread internal/engines/saturation/engine.go Outdated
@clubanderson
clubanderson requested review from asm582 and Copilot January 9, 2026 16:52
@clubanderson
clubanderson force-pushed the fix/model-label-mismatch branch from b2e2993 to 99538c7 Compare January 9, 2026 17:01

Copilot AI left a comment

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.

Pull request overview

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

Comment thread test/e2e-openshift/sharegpt_scaleup_test.go Outdated
Comment thread internal/saturation/analyzer.go
Comment thread internal/engines/saturation/engine.go Outdated
Copilot AI review requested due to automatic review settings January 9, 2026 18:01

Copilot AI left a comment

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.

Pull request overview

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

Comment thread test/utils/e2eutils.go
Comment thread internal/saturation/analyzer.go Outdated
Comment thread internal/engines/saturation/engine.go

@asm582 asm582 left a comment

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.

Please add PR link to codebase and let all E2Es pass.

Copilot AI review requested due to automatic review settings January 9, 2026 18:08

Copilot AI left a comment

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.

Pull request overview

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

Comment thread test/utils/e2eutils.go
Comment thread test/e2e-openshift/sharegpt_scaleup_test.go
Copilot AI review requested due to automatic review settings January 9, 2026 19:10

Copilot AI left a comment

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.

Pull request overview

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

Comment thread test/e2e-openshift/sharegpt_scaleup_test.go
Comment thread internal/saturation/analyzer.go
@clubanderson
clubanderson force-pushed the fix/model-label-mismatch branch from 4c77192 to cd68e67 Compare January 9, 2026 19:22
Copilot AI review requested due to automatic review settings January 9, 2026 19:25
@clubanderson
clubanderson force-pushed the fix/model-label-mismatch branch from cd68e67 to 23ba8b0 Compare January 9, 2026 19:25

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Comment thread test/utils/e2eutils.go Outdated
Comment thread test/e2e-openshift/sharegpt_scaleup_test.go
Comment thread internal/saturation/analyzer.go Outdated
Comment thread internal/engines/saturation/engine.go Outdated
Comment thread deploy/kind-emulator/setup.sh Outdated
@clubanderson
clubanderson force-pushed the fix/model-label-mismatch branch from 23ba8b0 to 09b00f2 Compare January 9, 2026 19:30
This PR adds pending replica awareness to the saturation scaling engine
and improves E2E test stability through better load generation tuning.

Key changes:
- Add PendingReplicas field to VariantReplicaState to track pods that exist
  but are not yet ready (CurrentReplicas - ReadyReplicas)
- Prevent cascade scaling by blocking scale-up when replicas are pending
- Add getVariantKey helper for namespace-safe variant identification
- Make Prometheus URL and TLS verification configurable via env vars
- Add namespace validation to prevent PromQL injection
- Tune load generation parameters to achieve ~2-3 replica scale-up target
- Add per-model token configuration for sustained saturation testing
- Use safe type assertion for Prometheus query results

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
@clubanderson
clubanderson force-pushed the fix/model-label-mismatch branch from 09b00f2 to bc9948f Compare January 9, 2026 19:33
@clubanderson
clubanderson merged commit 14e2bd8 into main Jan 9, 2026
6 checks passed
github-actions Bot added a commit that referenced this pull request Jan 9, 2026
…etheus env config

Document three key enhancements from PR #549:

1. Pending Replica Awareness & Cascade Scaling Prevention
   - Add comprehensive explanation of pending replica tracking
   - Document how WVA prevents excessive scale-up during pod startup
   - Include timeline examples showing before/after behavior
   - Update saturation-analyzer.md and saturation-scaling-config.md

2. Prometheus Configuration via Environment Variables
   - Document new environment variable configuration method
   - Provide complete reference table for all Prometheus env vars
   - Explain configuration priority (env vars → ConfigMap)
   - Add TLS configuration examples for production and development
   - Update integrations/prometheus.md and user-guide/configuration.md

3. PromQL Injection Prevention
   - Document security enhancements for query parameter escaping
   - Explain namespace validation to prevent injection attacks
   - Provide examples of attack prevention mechanisms
   - Emphasize multi-tenant security considerations

Additional changes:
- Create CHANGELOG-v0.5.0.md with detailed feature descriptions
- Update Key Principles section with pending replica awareness
- Add Environment Variables section to configuration guide
- Enhance Prometheus integration documentation structure

These documentation updates ensure developers understand the new
features, security improvements, and configuration options introduced
in the latest release.
clubanderson pushed a commit that referenced this pull request Jan 9, 2026
…etheus env config (#566)

Document three key enhancements from PR #549:

1. Pending Replica Awareness & Cascade Scaling Prevention
   - Add comprehensive explanation of pending replica tracking
   - Document how WVA prevents excessive scale-up during pod startup
   - Include timeline examples showing before/after behavior
   - Update saturation-analyzer.md and saturation-scaling-config.md

2. Prometheus Configuration via Environment Variables
   - Document new environment variable configuration method
   - Provide complete reference table for all Prometheus env vars
   - Explain configuration priority (env vars → ConfigMap)
   - Add TLS configuration examples for production and development
   - Update integrations/prometheus.md and user-guide/configuration.md

3. PromQL Injection Prevention
   - Document security enhancements for query parameter escaping
   - Explain namespace validation to prevent injection attacks
   - Provide examples of attack prevention mechanisms
   - Emphasize multi-tenant security considerations

Additional changes:
- Create CHANGELOG-v0.5.0.md with detailed feature descriptions
- Update Key Principles section with pending replica awareness
- Add Environment Variables section to configuration guide
- Enhance Prometheus integration documentation structure

These documentation updates ensure developers understand the new
features, security improvements, and configuration options introduced
in the latest release.

Co-authored-by: Update Docs Bot <github-actions[bot]@users.noreply.github.com>
ev-shindin pushed a commit to ev-shindin/workload-variant-autoscaler that referenced this pull request Jan 14, 2026
…#549)

This PR adds pending replica awareness to the saturation scaling engine
and improves E2E test stability through better load generation tuning.

Key changes:
- Add PendingReplicas field to VariantReplicaState to track pods that exist
  but are not yet ready (CurrentReplicas - ReadyReplicas)
- Prevent cascade scaling by blocking scale-up when replicas are pending
- Add getVariantKey helper for namespace-safe variant identification
- Make Prometheus URL and TLS verification configurable via env vars
- Add namespace validation to prevent PromQL injection
- Tune load generation parameters to achieve ~2-3 replica scale-up target
- Add per-model token configuration for sustained saturation testing
- Use safe type assertion for Prometheus query results

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
ev-shindin pushed a commit to ev-shindin/workload-variant-autoscaler that referenced this pull request Jan 14, 2026
…etheus env config (llm-d#566)

Document three key enhancements from PR llm-d#549:

1. Pending Replica Awareness & Cascade Scaling Prevention
   - Add comprehensive explanation of pending replica tracking
   - Document how WVA prevents excessive scale-up during pod startup
   - Include timeline examples showing before/after behavior
   - Update saturation-analyzer.md and saturation-scaling-config.md

2. Prometheus Configuration via Environment Variables
   - Document new environment variable configuration method
   - Provide complete reference table for all Prometheus env vars
   - Explain configuration priority (env vars → ConfigMap)
   - Add TLS configuration examples for production and development
   - Update integrations/prometheus.md and user-guide/configuration.md

3. PromQL Injection Prevention
   - Document security enhancements for query parameter escaping
   - Explain namespace validation to prevent injection attacks
   - Provide examples of attack prevention mechanisms
   - Emphasize multi-tenant security considerations

Additional changes:
- Create CHANGELOG-v0.5.0.md with detailed feature descriptions
- Update Key Principles section with pending replica awareness
- Add Environment Variables section to configuration guide
- Enhance Prometheus integration documentation structure

These documentation updates ensure developers understand the new
features, security improvements, and configuration options introduced
in the latest release.

Co-authored-by: Update Docs Bot <github-actions[bot]@users.noreply.github.com>
mamy-CS pushed a commit to mamy-CS/inferno-autoscaler that referenced this pull request Feb 10, 2026
…#549)

This PR adds pending replica awareness to the saturation scaling engine
and improves E2E test stability through better load generation tuning.

Key changes:
- Add PendingReplicas field to VariantReplicaState to track pods that exist
  but are not yet ready (CurrentReplicas - ReadyReplicas)
- Prevent cascade scaling by blocking scale-up when replicas are pending
- Add getVariantKey helper for namespace-safe variant identification
- Make Prometheus URL and TLS verification configurable via env vars
- Add namespace validation to prevent PromQL injection
- Tune load generation parameters to achieve ~2-3 replica scale-up target
- Add per-model token configuration for sustained saturation testing
- Use safe type assertion for Prometheus query results

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
mamy-CS pushed a commit to mamy-CS/inferno-autoscaler that referenced this pull request Feb 10, 2026
…etheus env config (llm-d#566)

Document three key enhancements from PR llm-d#549:

1. Pending Replica Awareness & Cascade Scaling Prevention
   - Add comprehensive explanation of pending replica tracking
   - Document how WVA prevents excessive scale-up during pod startup
   - Include timeline examples showing before/after behavior
   - Update saturation-analyzer.md and saturation-scaling-config.md

2. Prometheus Configuration via Environment Variables
   - Document new environment variable configuration method
   - Provide complete reference table for all Prometheus env vars
   - Explain configuration priority (env vars → ConfigMap)
   - Add TLS configuration examples for production and development
   - Update integrations/prometheus.md and user-guide/configuration.md

3. PromQL Injection Prevention
   - Document security enhancements for query parameter escaping
   - Explain namespace validation to prevent injection attacks
   - Provide examples of attack prevention mechanisms
   - Emphasize multi-tenant security considerations

Additional changes:
- Create CHANGELOG-v0.5.0.md with detailed feature descriptions
- Update Key Principles section with pending replica awareness
- Add Environment Variables section to configuration guide
- Enhance Prometheus integration documentation structure

These documentation updates ensure developers understand the new
features, security improvements, and configuration options introduced
in the latest release.

Co-authored-by: Update Docs Bot <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants