-
Notifications
You must be signed in to change notification settings - Fork 443
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
validate studyJob when first reconcile it #308
Conversation
/assign @richardsliu @YujiOshima |
@hougangliu Thanks! |
it would be nice if some unit tests can be added for valid/invalid studyjob specs. May be, we can take this in a separate PR |
pkg/controller/studyjob/utils.go
Outdated
@@ -30,3 +41,72 @@ func createWorkerJobObj(kind string) runtime.Object { | |||
} | |||
return nil | |||
} | |||
|
|||
func generateRandid() string { | |||
// UUID isn't quite handy in the Go world |
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.
Can we use something like this? https://godoc.org/github.com/google/uuid
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.
yes, sure. I can update it.
@@ -103,7 +103,7 @@ func getWorkerManifest(c katibapi.ManagerClient, studyID string, trial *katibapi | |||
} | |||
var wid string | |||
if dryrun { | |||
wid = "validation" | |||
wid = generateRandid() |
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.
Is this necessary?
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.
yes, if I don't change it, a worker template with Name "validation" will be taken as valid by mistake.
pkg/controller/studyjob/utils.go
Outdated
return err | ||
} | ||
|
||
studyID := generateRandid() |
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.
Do we need to generate id here if we are just validating the spec?
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.
Actually studyId and trialID can be hard-code here for now. I can hard-code it here.
Thanks for your comment
Sure, thanks |
k8s.io/apimachinery/pkg/util/uuid is used in kubernetes source code
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: richardsliu The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Fixes: #297
This change is