-
Notifications
You must be signed in to change notification settings - Fork 972
feat(operator): enforce RFC 1035 validation for TrainJob name #2767
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,19 +45,6 @@ func TestValidateCreate(t *testing.T) { | |
| wantError: nil, | ||
| wantWarnings: nil, | ||
| }, | ||
| "invalid trainjob name with uppercase letters": { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had assumed this test would/could be kept?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @astefanutti Just to clarify—now that the validation is enforced in the CRD using CEL, do we still need to keep the Go/webhook logic and its related unit tests? I moved the tests out of the webhook layer because the validation logic now lives in the CRD, so the webhook no longer performs this check. Could you please advise whether it’s better to keep both the Go logic and tests (alongside the CEL rule and integration test), or just rely on CEL + integration tests?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @juniemariam that makes sense. Yes an integration test could be useful. |
||
| obj: testingutil.MakeTrainJobWrapper("default", "Invalid-job-name"). | ||
| RuntimeRef(trainer.SchemeGroupVersion.WithKind(trainer.ClusterTrainingRuntimeKind), "test-runtime"). | ||
| Obj(), | ||
| wantError: field.ErrorList{ | ||
| &field.Error{ | ||
| Type: field.ErrorTypeInvalid, | ||
| Field: "metadata.name", | ||
| BadValue: "Invalid-job-name", | ||
| }, | ||
| }, | ||
| wantWarnings: nil, | ||
| }, | ||
| "unsupported runtime": { | ||
| obj: testingutil.MakeTrainJobWrapper("default", "valid-job-name"). | ||
| RuntimeRef(trainer.SchemeGroupVersion.WithKind(trainer.ClusterTrainingRuntimeKind), "unsupported-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.
would using
!format.dns1123Label().validate(self.metadata.name).hasValue()be slightly better?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.
Thanks for the suggestion @astefanutti ! I initially tried using the format library expression as recommended in the Kubernetes docs (e.g., !format.dns1035Label().validate(self.metadata.name).hasValue()), but it failed to pass the CEL cost estimation and could not be applied due to cost budget errors in the CRD. Hence I changed to regex check
Please let me know if you'd like me to try any other alternatives or if this existing approach works for now.
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.
@juniemariam thanks for the explanation. That looks good to me as it is.