diff --git a/jupyterhub/spawner.py b/jupyterhub/spawner.py index 2360af04..6dc495e0 100644 --- a/jupyterhub/spawner.py +++ b/jupyterhub/spawner.py @@ -55,8 +55,11 @@ class Spawner(LoggingConfigurable): will_resume = Bool(False, help="""Whether the Spawner will resume on next start - If a Spawner will resume instead of starting anew (e.g. resuming a Docker container), - API tokens in use when the Spawner stops will not be deleted. + + Default is False where each launch of the Spawner will be a new instance. + If True, an existing Spawner will resume instead of starting anew + (e.g. resuming a Docker container), + and API tokens in use when the Spawner stops will not be deleted. """ ) diff --git a/jupyterhub/user.py b/jupyterhub/user.py index 3079c12f..78bac2f4 100644 --- a/jupyterhub/user.py +++ b/jupyterhub/user.py @@ -235,7 +235,7 @@ class User(HasTraits): # Handle < 0.7 behavior with a warning, assuming info was stored in db by the Spawner. self.log.warning("DEPRECATION: Spawner.start should return (ip, port) in JupyterHub >= 0.7") if spawner.api_token != api_token: - # Spawner re-used an API token, discard the one we just created + # Spawner re-used an API token, discard the unused api_token orm_token = orm.APIToken.find(self.db, api_token) if orm_token is not None: self.db.delete(orm_token) @@ -321,6 +321,8 @@ class User(HasTraits): self.db.delete(self.server) self.server = None if not spawner.will_resume: + # find and remove the API token if the spawner isn't + # going to re-use it next time orm_token = orm.APIToken.find(self.db, api_token) if orm_token: self.db.delete(orm_token)