Skip to content
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

Delete named PVCs if they contain {user_server} #873

Merged
merged 1 commit into from
Nov 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion kubespawner/spawner.py
Original file line number Diff line number Diff line change
Expand Up @@ -3807,7 +3807,7 @@ async def delete_forever(self):
self.log.info(f"Not deleting pvc for {log_name}: {self.pvc_name}")
return

if self.name and '{servername}' not in self.pvc_name_template:
if self.name and '{user_server}' 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.

I'm not confident about what makes sense here, it seems like we want to ensure that we don't delete a named servers PVC if its shared. Due to that, should we maybe instead check for either servername and user_server?

Is servername still accepted, or was it removed entirely?

Copy link
Member Author

@manics manics Nov 15, 2024

Choose a reason for hiding this comment

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

The check is inverted so we're only deleting if pvc_name_template contains {user_server}.

We could also delete the PVC if the template contains {servername} as in KubeSpawner 6 but strictly speaking this isn't completely safe, since if (for some unknown reason) an admin wanted all users to share the same volume based on servername (and ignoring username) we'd incorrectly delete the PVC.

There's also the problem of future maintenance- the more conditions we add the more likely it is to break in future.

Copy link
Member

Choose a reason for hiding this comment

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

Good thinking, thank you for being so thorough @manics!!

# named server has the same PVC as the default server
# don't delete the default server's PVC!
self.log.info(
Expand Down