Repository navigation
fix(api): reject TrainJob env names and resources that Pods cannot accept - #4293
Open
harshrajdebug wants to merge 1 commit into
Open
harshrajdebug wants to merge 1 commit into
harshrajdebug wants to merge 1 commit into
Conversation
…ot accept Signed-off-by: Harsh Raj <harshrajdebug@gmail.com>
Contributor
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
A TrainJob with an env var name containing
=, or with resource requests above its limits, is admitted today. JobSet then fails to create its Jobs (JobCreationFailedevent only), and the TrainJob never starts and gets no condition. Details and the kind reproduction are in #4292.This PR adds
validatePodFieldsto the TrainJob validating webhook. It checks the env names and resource requirements the user sets directly:spec.trainer.envandspec.trainer.resourcesPerNodespec.initializer.dataset.envandspec.initializer.model.envenvandresourcesof containers and init containers inspec.runtimePatchesEnv names use
validation.IsRelaxedEnvVarName, so only names that are invalid on every supported Kubernetes version are rejected. For resources, a request above the limit of the same resource is rejected; a request with no limit is still accepted.On update the check runs only if the old object passes it, the same pattern used for the DRA feature gate fields. A TrainJob admitted before this check existed can still be suspended or have its patches changed, while an update that adds an invalid runtime patch is rejected.
The check does not look at values merged from the runtime template, for example a TrainJob request above a limit that only the runtime sets. That case needs the merged Pod spec and is left out of this change.
Tests:
TestValidateCreatecovers every field with an invalid value and checks the field paths, plus a case where requests equal limits or have no limit.TestValidateUpdatecovers an update that adds an invalid patch and an update of an already-invalid TrainJob.test/integration/webhooks): trainer envA=B, requests above limits, and dataset initializer envA=Bare rejected; valid names includingmy.config-1and equal requests and limits are accepted. The three rejection entries fail on master.go test ./pkg/..., the webhook (92) and controller (54) integration suites, andgolangci-lint run ./...pass 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 #4292
Checklist: