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

avoid failure to delete pods that don’t exist #196

Merged
merged 1 commit into from
Jul 1, 2018
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
27 changes: 20 additions & 7 deletions kubespawner/spawner.py
Original file line number Diff line number Diff line change
Expand Up @@ -1360,6 +1360,10 @@ def stop(self, now=False):
if not self.events.stopped():
self.events.stop()
self.events = None

if self.pod_name not in self.pods:
self.log.info("No pod %s to delete", self.pod_name)
return
delete_options = client.V1DeleteOptions()

if now:
Expand All @@ -1371,13 +1375,22 @@ def stop(self, now=False):

delete_options.grace_period_seconds = grace_seconds
self.log.info("Deleting pod %s", self.pod_name)
yield self.asynchronize(
self.api.delete_namespaced_pod,
name=self.pod_name,
namespace=self.namespace,
body=delete_options,
grace_period_seconds=grace_seconds
)
try:
yield self.asynchronize(
self.api.delete_namespaced_pod,
name=self.pod_name,
namespace=self.namespace,
body=delete_options,
grace_period_seconds=grace_seconds,
)
except ApiException as e:
if e.status == 404:
self.log.warning(
"No pod %s to delete. Assuming already deleted.",
self.pod_name,
)
else:
raise
yield exponential_backoff(
lambda: self.pod_reflector.pods.get(self.pod_name, None) is None,
'pod/%s did not disappear in %s seconds!' % (self.pod_name, self.start_timeout),
Expand Down