Skip to content

Commit

Permalink
Merge pull request #176 from lsst-sqre/master
Browse files Browse the repository at this point in the history
Add check for None as a container status.
  • Loading branch information
minrk committed May 25, 2018
2 parents a7b7374 + d6d0a2d commit b0b1041
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions kubespawner/spawner.py
Original file line number Diff line number Diff line change
Expand Up @@ -1094,8 +1094,14 @@ def poll(self):
"""
Check if the pod is still running.
Returns None if it is, and 1 if it isn't. These are the return values
JupyterHub expects.
Uses the same interface as subprocess.Popen.poll(): if the pod is
still running, returns None. If the pod has exited, return the
exit code if we can determine it, or 1 if it has exited but we
don't know how. These are the return values JupyterHub expects.
Note that a clean exit will have an exit code of zero, so it is
necessary to check that the returned value is None, rather than
just Falsy, to determine that the pod is still running.
"""
# have to wait for first load of data before we have a valid answer
if not self.pod_reflector.first_load_future.done():
Expand All @@ -1104,7 +1110,11 @@ def poll(self):
if data is not None:
if data.status.phase == 'Pending':
return None
for c in data.status.container_statuses:
ctr_stat = data.status.container_statuses
if ctr_stat is None: # No status, no container (we hope)
# This seems to happen when a pod is idle-culled.
return 1
for c in ctr_stat:
# return exit code if notebook container has terminated
if c.name == 'notebook':
if c.state.terminated:
Expand Down

0 comments on commit b0b1041

Please sign in to comment.