-
Notifications
You must be signed in to change notification settings - Fork 834
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
feat: pipeline and model name validation #5872
feat: pipeline and model name validation #5872
Conversation
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 some minor changes are needed around the regex given what k8s supports (and corresponding test cases), but this lgtm as a structure otherwise.
import "regexp" | ||
|
||
func CheckName(name string) bool { | ||
ok, err := regexp.Match("^[a-zA-Z0-9][a-zA-Z0-9-_]*[a-zA-Z0-9]$", []byte(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.
The spec on what names are allowed in k8s is this one: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/
k8s will already reject all names that don't obey the regex: [a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*
(this is the regex that kubectl reports when trying to create a resource with an invalid name). In particular, upper-case letters and underscores are also excluded.
We'll still want to do this validation explicitly so that we deal in an uniform way with k8s and non-k8s deployments.
Beyond k8s's existing validation, we want to reserve the .
for Seldon -- this is because internally we do header-based routing and a pipeline's name (for example) is referred to as '[name].pipeline`.
I'm not sure why we don't just trim the element after the last dot when post-processing such names (and allow dots in user-provided names). I don't have the context on whether there are any other reasons why we might reserve the .
, but perhaps we take this as a separate issue to investigate.
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, some more investigation is necessary. It would be great to have this validation aligned with k8s.
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.
lgtm
Pipelines and models with dots in their names cause problems, as the scheduler will trim the name from the first occurrence of the dot, when attempting to retrieve the resource.
Adding some validation to model and pipeline names to highlight this scenerio and return descriptive error messages.
Only alphanumeric names with underscores and hyphens are valid.
It's probably worth starting with the
utils/validate_test.go
file.TODO :