-
Notifications
You must be signed in to change notification settings - Fork 697
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
KEP-2170: Adding validation webhook for v2 trainjob #2307
base: master
Are you sure you want to change the base?
Conversation
[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 |
892a40b
to
f1a06c4
Compare
ce983eb
to
736a759
Compare
Pull Request Test Coverage Report for Build 11709371378Details
💛 - Coveralls |
f85da83
to
ba32e68
Compare
ba32e68
to
20136ef
Compare
20136ef
to
0aa9ee0
Compare
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.
Thank you for taking this, and moving this forward.
And Sorry for the delay.
Namespace: new.Namespace, | ||
Name: new.Spec.RuntimeRef.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.
Have you ever seen the isseus when we use the old object names?
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.
Why do we get new
object here and not old
?
@@ -140,3 +143,115 @@ func (j *JobSet) ReconcilerBuilders() []runtime.ReconcilerBuilder { | |||
}, | |||
} | |||
} | |||
|
|||
func (j *JobSet) Validate(oldObj, newObj *kubeflowv2.TrainJob, runtimeInfo *runtime.Info) (admission.Warnings, field.ErrorList) { |
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.
It seems that there are some conflicts between @andreyvelich PR and this.
@akshaychitneni Could you consult with @andreyvelich, then which PRs should we merge into the main, first.
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.
I rebased with @andreyvelich's changes
@@ -31,7 +31,7 @@ func Setup(mgr ctrl.Manager, runtimes map[string]runtime.Runtime) (string, error | |||
return kubeflowv2.TrainingRuntimeKind, err | |||
} | |||
if err := setupWebhookForTrainJob(mgr, runtimes); err != nil { | |||
return "TrainJob", err | |||
return kubeflowv2.TrainJobKind, err |
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.
Nice catch.
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.
Cool! This is what I imagined architechture in my KubeflowJobPipeline framework design phase.
failedCtrlName, err := controllerv2.SetupControllers(mgr, runtimes) | ||
gomega.ExpectWithOffset(1, err).NotTo(gomega.HaveOccurred(), "controller", failedCtrlName) | ||
gomega.ExpectWithOffset(1, failedCtrlName).To(gomega.BeEmpty()) | ||
if startControllers { |
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.
Have you ever seen any issues like null pointer when we start the controllers for webhook testing, right?
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.
I think I have seen but we might not need to start the controllers just to validate create/update requests and leave to reconciler tests to cover reconciliation
0aa9ee0
to
1b675c5
Compare
0e12bb4
to
a3ea261
Compare
9d15d26
to
f4d1430
Compare
fixing runtime Signed-off-by: Akshay Chitneni <[email protected]>
f4d1430
to
a93ffb7
Compare
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.
Thank you for this effort @akshaychitneni!
I left initial comments.
// JobExporter is the Job name for the exporter. | ||
JobExporter string = "exporter" | ||
|
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 can we implement the validation for exporter in the future once we design it as part of: #2245 ?
We should discuss whether we want to use sidecar container or another ReplicatedJob for model checkpointing.
cc @saileshd1402 @akshaychitneni @tenzen-y
// ContainerModelInitializer is the container name for the model initializer. | ||
ContainerModelInitializer string = "model-initializer" | ||
|
||
// ContainerModelExporter is the container name for the model exporter. | ||
ContainerModelExporter string = "model-exporter" |
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.
The same for the container.
@@ -0,0 +1,17 @@ | |||
package runtime |
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.
If it is a runtime util, don't we want to move it under /pkg/runtime.v2/util
@akshaychitneni @tenzen-y ?
return r.framework.RunComponentBuilderPlugins(ctx, jobSetTemplate.DeepCopy(), info, trainJob) | ||
} | ||
|
||
func (r *TrainingRuntime) runtimeInfo( |
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.
Should this be part of Runtime interface:
type Runtime interface { |
And should we name this API more explicit (e.g.
getRuntimeInfo()
or initializeRuntimeInfo()
) ?
Namespace: new.Namespace, | ||
Name: new.Spec.RuntimeRef.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.
Why do we get new
object here and not old
?
numProcPerNodePath := specPath.Child("trainer").Child("numProcPerNode") | ||
if runtimeInfo.MLPolicy.MPI != nil { | ||
if _, err := strconv.Atoi(*newJobObj.Spec.Trainer.NumProcPerNode); err != nil { | ||
allErrs = append(allErrs, field.Invalid(numProcPerNodePath, newJobObj.Spec.Trainer.NumProcPerNode, "should have an int value")) |
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.
I think so, is this value compatible with the k8s API conventions: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md ?
numProcPerNodePath := specPath.Child("trainer").Child("numProcPerNode") | ||
if runtimeInfo.RuntimePolicy.MLPolicy.Torch != nil && newObj.Spec.Trainer.NumProcPerNode != nil { | ||
allowedStringValList := []string{"auto", "cpu", "gpu"} | ||
numProcPerNode := *newObj.Spec.Trainer.NumProcPerNode |
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.
@akshaychitneni @tenzen-y Can't we use CEL for that validation since we just validate values for .nProcPerNode
parameter ?
// TODO: Need to implement validateions for TorchJob. | ||
func (t *Torch) Validate(oldObj, newObj *kubeflowv2.TrainJob) (admission.Warnings, field.ErrorList) { | ||
return nil, nil | ||
func (t *Torch) Validate(runtimeJobTemplate client.Object, runtimeInfo *runtime.Info, oldObj, newObj *kubeflowv2.TrainJob) (admission.Warnings, field.ErrorList) { |
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.
As I mentioned here, we should also validate that TrainJob doesn't have PET_
Trainer envs
// TODO (andreyvelich): Add validation to check that TrainJob doesn't have "PET_" envs. |
return nil, nil | ||
} | ||
|
||
if newObj.Spec.ModelConfig != nil && newObj.Spec.ModelConfig.Input != nil { |
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.
I think, for now we should check the initContainers in JobSet, as I mentioned here: https://github.com/kubeflow/training-operator/blob/master/pkg/runtime.v2/framework/plugins/jobset/builder.go#L87-L89
gomega.Expect(k8sClient.DeleteAllOf(ctx, &kubeflowv2.TrainJob{}, client.InNamespace(ns.Name))).To(gomega.Succeed()) | ||
}) | ||
|
||
ginkgo.When("Creating TrainJob", func() { |
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.
@tenzen-y @akshaychitneni What is right way to test our validations with integration or unit tests ?
Adds validation webhook for v2 trainjob.
Relates to #2209
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 # #2209
Checklist: