Skip to content

fix(api): reject OptimizationJob trainer env that trial TrainJobs cannot accept - #4286

Open
rshdhere wants to merge 1 commit into
kubeflow:masterfrom
rshdhere:fix-optimizationjob-template-env
Open

rshdhere wants to merge 1 commit into
kubeflow:masterfrom
rshdhere:fix-optimizationjob-template-env

Conversation

@rshdhere

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

The OptimizationJob controller adds one KUBEFLOW_TRAINER_OPT_<parameter> env var per parameter to trainJobTemplate.spec.trainer.env when it creates a trial. If the template already sets one of those names, or its env vars plus the parameters go over TrainJob's limit of 128, every trial is rejected by the API server. The controller then retries forever and the OptimizationJob never fails, so it looks healthy but never starts. This PR adds two CEL rules on OptimizationJobSpec that reject both cases when the job is created.

  • Reserve the KUBEFLOW_TRAINER_OPT_ prefix in the template's trainer env. This also stops prefixed template env vars from showing up in status.result.parameters.
  • Cap the template's trainer env plus parameters at 128.
  • Add webhook integration tests for both rules, including the exact 128 boundary.

Builds on #4248, which adds optimizationjob_test.go and the MakeOptimizationJobWrapper defaults. Only the last commit is new here. I'll rebase once #4248 merges.

AI-assisted: used for investigating the bug, drafting the fix and tests; all changes reviewed, built and tested locally.

Which issue(s) this PR fixes (optional, in Fixes #<issue number>, #<issue number>, ... format, will close the issue(s) when PR gets merged):
Fixes #4285

Checklist:

  • Docs included if any changes are user facing

@google-oss-prow

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 electronic-waste 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

…not accept

The controller appends one KUBEFLOW_TRAINER_OPT_<parameter> env var per
parameter to trainJobTemplate.spec.trainer.env when it creates a trial.
TrainJob's trainer.env is a map keyed by name with at most 128 items, so a
template that already sets a prefixed name, or whose env plus parameters
exceed 128, produces trials the API server always rejects. The controller
then retries forever and the OptimizationJob never gets a Failed condition.

Reject both cases when the OptimizationJob is created: reserve the
KUBEFLOW_TRAINER_OPT_ prefix in the template's trainer env, and cap the
template's trainer env plus parameters at 128.

Fixes kubeflow#4285

Signed-off-by: raashed <mohammedraashed10@gmail.com>
@rshdhere
rshdhere force-pushed the fix-optimizationjob-template-env branch from cf38a94 to e327ccf Compare October 21, 2026 02:55
@google-oss-prow google-oss-prow Bot added size/M and removed size/L labels Oct 21, 2026
@akshaychitneni

akshaychitneni commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

/milestone v2.4

@akshaychitneni akshaychitneni added this to the v2.4 milestone Oct 23, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Needs Triage

Development

Successfully merging this pull request may close these issues.

OptimizationJob accepts trainer env vars its trials can't use, then stalls without failing

2 participants