-
Notifications
You must be signed in to change notification settings - Fork 706
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
commonize job name validation #2315
base: master
Are you sure you want to change the base?
commonize job name validation #2315
Conversation
Signed-off-by: Harshvir Potpose <[email protected]>
[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.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@@ -0,0 +1,16 @@ | |||
package utils |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add some unit tests for this function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/hold
@@ -71,8 +70,9 @@ func (w *Webhook) ValidateDelete(context.Context, runtime.Object) (admission.War | |||
|
|||
func validateJAXJob(job *trainingoperator.JAXJob) field.ErrorList { | |||
var allErrs field.ErrorList | |||
if errors := apimachineryvalidation.NameIsDNS1035Label(job.ObjectMeta.Name, false); len(errors) != 0 { | |||
allErrs = append(allErrs, field.Invalid(field.NewPath("metadata").Child("name"), job.Name, fmt.Sprintf("should match: %v", strings.Join(errors, ",")))) | |||
err := utils.ValidateJobName(job.ObjectMeta.Name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commonize does not have value since we already use the Kube validations lib here.
My expectations are commonizing replicaSpec validations:
training-operator/pkg/webhooks/pytorch/pytorchjob_webhook.go
Lines 93 to 109 in 7c5ea70
func validateSpec(spec trainingoperator.PyTorchJobSpec) (admission.Warnings, field.ErrorList) { | |
var allErrs field.ErrorList | |
var warnings admission.Warnings | |
if spec.ElasticPolicy != nil && spec.ElasticPolicy.NProcPerNode != nil { | |
elasticNProcPerNodePath := specPath.Child("elasticPolicy").Child("nProcPerNode") | |
nprocPerNodePath := specPath.Child("nprocPerNode") | |
warnings = append(warnings, fmt.Sprintf("%s is deprecated, use %s instead", elasticNProcPerNodePath.String(), nprocPerNodePath.String())) | |
if spec.NprocPerNode != nil { | |
allErrs = append(allErrs, field.Forbidden(elasticNProcPerNodePath, fmt.Sprintf("must not be used with %s", nprocPerNodePath))) | |
} | |
} | |
allErrs = append(allErrs, validatePyTorchReplicaSpecs(spec.PyTorchReplicaSpecs)...) | |
return warnings, allErrs | |
} | |
func validatePyTorchReplicaSpecs(rSpecs map[trainingoperator.ReplicaType]*trainingoperator.ReplicaSpec) field.ErrorList { |
91032c8
to
9094503
Compare
What this PR does / why we need it:
Which issue(s) this PR fixes (optional, in
Fixes #<issue number>, #<issue number>, ...
format, will close the issue(s) when PR gets merged):Fixes #2054
Checklist: