jupyterhub / kubespawner

Kubernetes spawner for JupyterHub
https://jupyterhub-kubespawner.readthedocs.io
BSD 3-Clause "New" or "Revised" License
541 stars 303 forks source link

PVCs fail to be created if a username does not begin with a "safe" character #706

Closed m-bull closed 1 year ago

m-bull commented 1 year ago

Bug description

PVCs fail to be created if a username does not begin with a "safe" character (set(string.ascii_lowercase + string.digits)).

If a username begins with a "non-safe" character, when it is url-encoded here, it may end up beginning with a -.

This is subsequently included as a PVC label value, which is not allowed.

Expected behaviour

PVC creates successfully even if usernames begin with "unsafe" characters.

Actual behaviour

PVC fails to create with the following message:

HTTP response body: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"PersistentVolumeClaim \"claim--53cott-40stackhpc-2ecom\" is invalid: metadata.labels: Invalid value: \"-53cott-40stackhpc-2ecom\": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue',  or 'my_value',  or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')","reason":"Invalid","details":{"name":"claim--53cott-40stackhpc-2ecom","kind":"PersistentVolumeClaim","causes":[{"reason":"FieldValueInvalid","message":"Invalid value: \"-53cott-40stackhpc-2ecom\": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue',  or 'my_value',  or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')","field":"metadata.labels"}]},"code":422}

How to reproduce

Spawn a singleuser notebook with an attached PVC and a username that begins with an uppercase letter.

Your personal set up

  - name: jupyterhub
    version: 2.0.0
    repository: https://jupyterhub.github.io/helm-chart/
welcome[bot] commented 1 year ago

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively. welcome You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! :wave:
Welcome to the Jupyter community! :tada:

manics commented 1 year ago

This is a known issue, please follow https://github.com/jupyterhub/kubespawner/issues/498