Skip to content

Conversation

manics
Copy link
Member

@manics manics commented Feb 26, 2025

Closes #880

I've expanded test_delete_pvc to test changes in the pvc template.

if (
not self.name
and '{user_server}' not in self.pvc_name_template
and '{username}' not in self.pvc_name_template
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for leaving this hanging for so long, but these aren't the only username-sensitive template fields (anymore). We could remove the leading { on both and it would capture {escaped_username}, {safe_user_server}, etc.. There is also the userid field.

Another, looser check would be to look for the strings username and user_server without the bran.

Another, more rigorous check is to use Formatter.parse to extract the fields and check them directly, rather than substring matching:

from string import Formatter

format_fields = [f[1] for f in Formatter().parse(s) if f[1] is not None]
user_sensitive = False
for (_literal_text, field_name, _format_spec, _conversion) in Formatter().parse(template):
    if field_name and 'user' in field_name:
        # template is user-sensitive
        user_sensitive = True

Otherwise, 👍 to the change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Backlog
Development

Successfully merging this pull request may close these issues.

Kubespawner deletes PVC even if the pvcNameTemplate doesn't include username
2 participants