Skip to content

Add name length validations to project creation #1232

Closed

Description

@jcantrill

Ran into an issue where I was able to create project 'foo', but unable to push to the local docker registry because the name was too short. Add name length validations to project creation, server-side, and possibly to the client create project command.

Per @ncdc ref as the current restrictions are in flux:
https://github.com/docker/distribution/blob/master/registry/api/v2/names.go#L16
https://github.com/docker/distribution/blob/master/registry/api/v2/names.go#L20
moby/moby#10392 (comment)
distribution/distribution#241

@derekwaynecarr This would need to go upstream?

Activity

  1. derekwaynecarr commented on Mar 5, 2015

    @derekwaynecarr
    Member

    Origin will proxy the namespace create request in Kube, so in theory, we can provide our own more restrictive validation once the docker registry constraints are better known. In practice, I am not a fan of needing to align project name validation with docker registry validation rules.

    Is it not possible to adapt a project name to a valid docker registry name?

    For example, if the project name is too short, can we not pad it when its used on the registry side?

  2. ncdc commented on Mar 5, 2015

    @ncdc
    Contributor

    @derekwaynecarr we could do that. However, if someone wanted to pull from/push to their image repository in our registry, they'd have to know the padding rules, as docker pull registry.openshift.com/a/myapp will fail.

  3. derekwaynecarr commented on Mar 5, 2015

    @derekwaynecarr
    Member

    If the padding rule is to meet a min-length of 2, it's not a lot of padding, so I am less concerned there.

    I am more concerned on the max length constraint of 30 characters.

    Kube restricts at a much higher level:
    https://github.com/GoogleCloudPlatform/kubernetes/blob/master/pkg/util/validation.go#L52

  4. ncdc commented on Mar 5, 2015

    @ncdc
    Contributor

    I'm not overly concerned about 30; we're working with Docker to get that increased.

  5. derekwaynecarr commented on Mar 5, 2015

    @derekwaynecarr
    Member

    So if we need to provide our own more restrictive validation that a project has a length between 2 and 30 characters, we can do that, but it limits our ability to expose any existing namespaces in Kuberentes as projects if/when Origin runs as pod on an existing Kubernetes cluster.

  6. added
    kind/bug
    on Mar 16, 2015
  7. liggitt commented on May 8, 2015

    @liggitt
    Contributor

    @ncdc what did the length requirements end up being for the v2 registry?

  8. ncdc commented on May 8, 2015

    @ncdc
    Contributor

    @liggitt a Docker image repository is made up of 1 or more components separated by slashes. Each component must be at least 2 characters, and the first character of each component must be alphanumeric. The total length of an image repository's name, including slashes, must be <= 255 characters.

  9. derekwaynecarr commented on May 17, 2015

    @derekwaynecarr
    Member

    We proxy project creation so in theory we could further restrict validation.

    Sent from my iPhone

    On May 16, 2015, at 11:02 PM, Jordan Liggitt [email protected] wrote:

    Also see https://bugzilla.redhat.com/show_bug.cgi?id=1190052

    —
    Reply to this email directly or view it on GitHub.

  10. liggitt commented on May 17, 2015

    @liggitt
    Contributor

    We can, but maybe just on create? Don't want to prevent updating an existing namespace with a short name using the project proxy

  11. ncdc commented on May 19, 2015

    @ncdc
    Contributor

    I'd like to propose that we add validation somewhere that a namespace must be at least 2 characters, and then for ImageStreams, add validation that len(namespace + / + name) <= 255. Thoughts?

  12. liggitt commented on May 19, 2015

    @liggitt
    Contributor

    We can add validation on Project create (but not update) and for ImageStream.

  13. derekwaynecarr commented on May 19, 2015

    @derekwaynecarr
    Member

    A name is immutable post create, so it should not be a concern.

  14. liggitt commented on May 19, 2015

    @liggitt
    Contributor

    if we say a project with a single character name is invalid, that could block a project update to add an annotation to a project that was created as a namespace with a single-character name

  15. liggitt commented on May 19, 2015

    @liggitt
    Contributor

    we can also do namespace validation on image streams... not let them be created in single-character namespaces

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

component/restapikind/bugpriority/P2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions