Skip to content

Commit 544f492

Browse files
authored
fix(scheduler): in scheduler::run check if pod state is an object or a string before acing on it (#957)
Fixes #956
1 parent c91f361 commit 544f492

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

rootfs/scheduler/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ def run(self, namespace, name, image, entrypoint, command, **kwargs):
482482
# check if it is possible to get logs
483483
state = self.pod_state(self.get_pod(namespace, name).json())
484484
# States below up do not have logs
485-
if state < PodState.up:
485+
if not isinstance(state, PodState) or state < PodState.up:
486486
return exit_code, 'Could not get logs. Pod is in state {}'.format(str(state))
487487

488488
# grab log information
@@ -666,6 +666,13 @@ def _set_image_secret(self, data, namespace, **kwargs):
666666
data['imagePullSecrets'] = [{'name': secret_name}]
667667

668668
def pod_state(self, pod):
669+
"""
670+
Resolve Pod state to an internally understandable format and returns a
671+
PodState object that can be used for comparison or name can get gotten
672+
via .name
673+
674+
However if no match is found then a text representation is returned
675+
"""
669676
# See "Pod Phase" at http://kubernetes.io/docs/user-guide/pod-states/
670677
if pod is None:
671678
return PodState.destroyed

0 commit comments

Comments
 (0)