← Back to Pull requests

feat(kueue): map queue selection to CodeFlare local_queue #20

Closed
unknown closed this pull request without merging on Nov 20, 2026 10:38 UTC
View on GitHub
unknown unknown commented on Nov 19, 2026 14:10 UTC
Author

Summary

Makes the API queue selection to CodeFlare local_queue mapping one reusable function and adds live E2E coverage for queue discovery and selection.

Queue checks on submission already landed with Kueue discovery (#16). This PR does not change what a valid request does. It gathers the mapping in one place, closes two gaps found next to it, and adds tests.

Where to look first

The mapping itself is small. Start here:

  • src/training_service/kueue_preflight.py: new resolve_local_queue(api, project, queue_name). A selected queue is returned only after its name, Kueue readiness, project eligibility and caller-visible existence in that project are established. With no selection, the project default applies. None means a confirmed unqueued submission.

  • src/training_service/jobs.py: submission calls the resolver instead of inlining the steps.

  • tests/unit/test_kueue_preflight.py, tests/unit/test_submission.py: successful and rejected mappings.
  • Everything under tests/e2e/ plus tests/unit/test_e2e_tooling.py is live test coverage and can be read separately.

    Behaviour changes

    Two, both small:

    1. POST /projects/{project}/training-jobs now validates the project name like the other endpoints and returns 400 bad_request. Previously a value such as %2e%2e reached the queue lookup.
    2. A LocalQueue lookup answered with an unexpected status (for example 400, 409, 429, 500) now returns 503 backend_unavailable, as docs/kueue-preflight.md describes. Previously it surfaced as submission_unavailable, already_exists or validation_error depending on the status. 401, 403 and 404 are unchanged. This is scoped to the LocalQueue lookup; the namespace read is not changed here.

    The queue name is now validated once, inside the resolver. The result for a malformed name is still 422 validation_error.

    Contract and docs

  • docs/api/openapi.yaml: queue_name description states the name rule and its 422. Bindings regenerated (make generate-server); description text only.

  • docs/kueue-preflight.md: lists the 422 and 400 outcomes and the lookup case for 503.

  • docs/architecture.md: default-queue submissions share the preflight too.
  • E2E additions

  • tests/e2e/test_queues.py: discovery response and outcomes; malformed names (422); missing LocalQueue (404, or 409 where Kueue is unusable); a prepared queue is listed and accepted; --other-project-queue PROJECT/QUEUE proves a queue from another project cannot be selected.

  • New default-queue profile: lifecycle with queue_name omitted must run on the project's annotated default LocalQueue.

  • Queued lifecycles also check queue_name in the job detail and the queue-filtered list.

  • tests/e2e/README.md and coverage.md updated.
  • Validation

  • make check (ruff, format, mypy, 1175 unit tests), make helm-check, make generate-server with no drift.

  • Deployed this branch on an OpenShift cluster with Kueue and NVIDIA GPUs, image built on-cluster:

  • - Full E2E with --queue-profile with-kueue --algorithm-matrix --check-active-delete: 157 passed, 1 failed, 8 skipped. sft, osft and lora_sft each reached SUCCEEDED through the selected queue with an admitted Workload, logs, artifacts and GPU cleanup. Pending and running deletion passed.
    - The one failure is test_algorithm_lifecycle[lora_grpo]: the fixture sends reward_type, which the stock runtime catalog does not expose, so the API returns 422 before queue selection. This is the limitation already described in tests/e2e/README.md.
    - default-queue lifecycle: passed.
    - The matrix ran before the final contract-description edit. On the final build the HTTP suite, the queue tests and a queued lora_sft lifecycle were rerun and passed.
    - Manual checks: non-enrolled project returns 409 kueue_project_excluded even with a retained LocalQueue; a queue from another project is rejected with 404; two default queues return 503; no rejection created a job.

    Not in this PR

  • The 202 receipt does not include queue_name when the project default is applied; the job detail does.

  • The E2E observer reads Kueue resources at v1beta1.
  • <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    New Features
    Submissions can use the project’s default queue when no queue is specified. Selected queues are resolved within the requested project.
    Bug Fixes
    Invalid queue names now return a 422 validation error before queue lookup. Invalid project names return 400, and unexpected queue lookup failures return 503.
    Documentation
    Updated API and architecture guidance to clarify queue name requirements, default queue behavior, and queue-related responses.

    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 607 lines (+455 / -152) across 7 files Reviewer: efazal Review duration: 1227m
    All Vouch review confidence checks passed
    Residual risk 0.20 = Change Risk (0.50) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 607 lines diff across 7 files
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    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.384
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #20"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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: 50.1% (MEDIUM) · Higher = larger blast radius
    50.1%
    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: 60.5% · Lower = rushed or shallow review
    60.5%
    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: 19.8% · Safe to merge
    19.8%