Context: The JupyterHub config that we are developing uses KubeSpawner to create pods for individual users. Currently each user gets a volume mount based on an Amazon EFS volume with a subpath for that particular user.
Problem: The idle-culler is used to kill the pods after a certain period of time. But a problem arises when the idle-culler is used. When a user pod is culled the next user that logs in gets the correct user details for that pod except that it gets the mounted subpath from the most recent culled user, which is very much a problem, so we disabled the idle-culler.
We validated the subPath that is fed to the KubeSpawner.volume_mounts and this is correct. Next to that, every time any variable is set with user details we deleted the variable after the KubeSpawner applies it to ensure all variables are cleard for the next user. Though, with the idle-culler enabled, the volume_mount subPath in the created pod still gets access to the most recent culled subPath.
Question: How to find the exact issue that influences the KubeSpawner?
The applicable jupyterhub_config.py
is as follows:
...
class authHandler(BaseHandler):
def get(self):
userid = self.user_authenticated(user)
...
c.KubeSpawner.storage_class = 'jhub-sc'
pvc_name_template = 'claim-jhub-users'
volume_name_template = 'volume-jhub-users'
c.KubeSpawner.pvc_name_template = pvc_name_template
c.KubeSpawner.volumes = [{
'name': volume_name_template,
'persistentVolumeClaim': {
'claimName': pvc_name_template
}
}]
c.KubeSpawner.volume_mounts = [{
'mountPath': '/mnt',
'name': volume_name_template,
'subPath': 'users/' + str(userid),
'readOnly': False
}]
...
...
...
c.JupyterHub.services = [
{
'name': 'idle-culler',
'admin': True,
'command': [
sys.executable,
'-m', 'jupyterhub_idle_culler',
'--remove-named-servers=True',
'--timeout=600'
],
}
]