diff --git a/jupyterhub/apihandlers/users.py b/jupyterhub/apihandlers/users.py index c8d6bb7a..27e9bf0f 100644 --- a/jupyterhub/apihandlers/users.py +++ b/jupyterhub/apihandlers/users.py @@ -238,10 +238,11 @@ class UserAPIHandler(APIHandler): await maybe_future(self.authenticator.delete_user(user)) - # Delete the user's storage, if it exists. - # In kubespawner spawner.py, we have delete_forever - # method to delete the user's PVC. - user.spawner.delete_forever() + # allow the spawner to cleanup any persistent resources associated with the user + try: + await user.spawner.delete_forever() + except Exception as e: + self.log.error("Error cleaning up persistent resources: %s" % e) # remove from registry self.users.delete(user) diff --git a/jupyterhub/tests/mocking.py b/jupyterhub/tests/mocking.py index e096b9bc..4342e8d7 100644 --- a/jupyterhub/tests/mocking.py +++ b/jupyterhub/tests/mocking.py @@ -93,8 +93,8 @@ class MockSpawner(SimpleLocalProcessSpawner): def _cmd_default(self): return [sys.executable, '-m', 'jupyterhub.tests.mocksu'] - def delete_forever(self): - return "mocking_this_method" + async def delete_forever(self): + pass use_this_api_token = None