-
Notifications
You must be signed in to change notification settings - Fork 698
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] Support managed by external controller (#2203)
* Introduce ManagedBy field to RunPolicy that is used by each Kubeflow Job Spec Signed-off-by: Michal Szadkowski <[email protected]> * Update Kubeflow JOb manifests Signed-off-by: Michal Szadkowski <[email protected]> * Update Kubeflow Jobs Reconcile to use ManagedBy field to decide if skip the process Signed-off-by: Michal Szadkowski <[email protected]> * job controller test Signed-off-by: Michal Szadkowski <[email protected]> * spec validation webhook Signed-off-by: Michal Szadkowski <[email protected]> * add manageBy maxLenght const Signed-off-by: Michal Szadkowski <[email protected]> * generate new manifest Signed-off-by: Michal Szadkowski <[email protected]> * revert webhook formatting Signed-off-by: Michal Szadkowski <[email protected]> * Move allowed controllers constants in one place Signed-off-by: Michal Szadkowski <[email protected]> * Make validatation for allowed managedBy values Signed-off-by: Michal Szadkowski <[email protected]> * Update after controllers constants move Signed-off-by: Michal Szadkowski <[email protected]> * Update jobs controller tests Signed-off-by: Michal Szadkowski <[email protected]> * Update validateManagedBy webhook Signed-off-by: Michal Szadkowski <[email protected]> * Remove validation for the length of ManagedBy field Signed-off-by: Michal Szadkowski <[email protected]> * Update after code review Signed-off-by: Michal Szadkowski <[email protected]> * Update ManagedBy comment Signed-off-by: Michal Szadkowski <[email protected]> * E2E tests for managedBy Signed-off-by: Michal Szadkowski <[email protected]> * Update generated files and manifests Signed-off-by: Michal Szadkowski <[email protected]> * Rework after code review Signed-off-by: Michal Szadkowski <[email protected]> * Revert kustomization change Signed-off-by: Michal Szadkowski <[email protected]> * Update job_test and logging Signed-off-by: Michal Szadkowski <[email protected]> * Provide immutability check for ManagedBy Signed-off-by: Michal Szadkowski <[email protected]> * Avoid making copy of runPolicy Signed-off-by: Michal Szadkowski <[email protected]> * Split RunPolicy validators to Update and Create Signed-off-by: Michal Szadkowski <[email protected]> * Fix the naming and call validate always Signed-off-by: Michal Szadkowski <[email protected]> * Update tests Signed-off-by: Michal Szadkowski <[email protected]> --------- Signed-off-by: Michal Szadkowski <[email protected]>
- Loading branch information
Showing
54 changed files
with
835 additions
and
45 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package util | ||
|
||
import ( | ||
v1 "github.com/kubeflow/training-operator/pkg/apis/kubeflow.org/v1" | ||
|
||
apivalidation "k8s.io/apimachinery/pkg/api/validation" | ||
"k8s.io/apimachinery/pkg/util/sets" | ||
"k8s.io/apimachinery/pkg/util/validation/field" | ||
) | ||
|
||
var supportedJobControllers = sets.New( | ||
v1.MultiKueueController, | ||
v1.KubeflowJobsController) | ||
|
||
func ValidateRunPolicy(runPolicy *v1.RunPolicy) field.ErrorList { | ||
errs := field.ErrorList{} | ||
if runPolicy.ManagedBy != nil { | ||
manager := *runPolicy.ManagedBy | ||
if !supportedJobControllers.Has(manager) { | ||
fieldPath := field.NewPath("spec", "runPolicy", "managedBy") | ||
errs = append(errs, field.NotSupported(fieldPath, manager, supportedJobControllers.UnsortedList())) | ||
} | ||
} | ||
return errs | ||
} | ||
|
||
func ValidateRunPolicyUpdate(oldRunPolicy, newRunPolicy *v1.RunPolicy) field.ErrorList { | ||
oldManager := oldRunPolicy.ManagedBy | ||
newManager := newRunPolicy.ManagedBy | ||
fieldPath := field.NewPath("spec", "runPolicy", "managedBy") | ||
return apivalidation.ValidateImmutableField(newManager, oldManager, fieldPath) | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.