Skip to content

Commit

Permalink
Don't re-use the pod deletion grace period config, use PVC default
Browse files Browse the repository at this point in the history
  • Loading branch information
consideRatio committed May 11, 2021
1 parent 4d7465c commit ea12ea7
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions kubespawner/spawner.py
Original file line number Diff line number Diff line change
Expand Up @@ -2329,7 +2329,7 @@ async def _ensure_not_exists(self, kind, name):
delete = getattr(self.api, "delete_namespaced_{}".format(kind))
read = getattr(self.api, "read_namespaced_{}".format(kind))

# first, attempt to delete the resouce
# first, attempt to delete the resource
try:
self.log.info(f"Deleting {kind}/{name}")
await gen.with_timeout(
Expand Down Expand Up @@ -2577,9 +2577,7 @@ async def _make_delete_pod_request(
else:
raise

async def _make_delete_pvc_request(
self, pvc_name, delete_options, grace_seconds, request_timeout
):
async def _make_delete_pvc_request(self, pvc_name, request_timeout):
"""
Make an HTTP request to delete the given PVC
Expand All @@ -2594,8 +2592,6 @@ async def _make_delete_pvc_request(
self.api.delete_namespaced_persistent_volume_claim,
name=pvc_name,
namespace=self.namespace,
body=delete_options,
grace_period_seconds=grace_seconds,
),
)
return True
Expand Down Expand Up @@ -2815,7 +2811,7 @@ async def _ensure_namespace(self):
self.log.exception("Failed to create namespace %s", self.namespace)
raise

async def delete_forever(self, now=False):
async def delete_forever(self):
"""Called when a user is deleted.
This can do things like request removal of resources such as persistent storage.
Expand All @@ -2824,21 +2820,10 @@ async def delete_forever(self, now=False):
This will only be called once on the user's default Spawner.
Supported by JupyterHub 1.4.0+.
"""
delete_options = client.V1DeleteOptions()

if now:
grace_seconds = 0
else:
grace_seconds = self.delete_grace_period

delete_options.grace_period_seconds = grace_seconds

await exponential_backoff(
partial(
self._make_delete_pvc_request,
self.pvc_name,
delete_options,
grace_seconds,
self.k8s_api_request_timeout,
),
f'Could not delete pvc {self.pvc_name}',
Expand Down

0 comments on commit ea12ea7

Please sign in to comment.