Skip to content

Commit 0cbf27b

Browse files
committed
ref(scheduler): passthrough k8s state if scheduler does not understand it
Reasoning here is that we should be showing people more information when we have not specifically covered the bases instead of potentially more obscure information piece, like "initialized" Also added ContainerCreating as a state to cover a state we had previously not been using for k8s. It got added in 1.2
1 parent 70f319f commit 0cbf27b

3 files changed

Lines changed: 14 additions & 11 deletions

File tree

rootfs/api/models/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ def list_pods(self, *args, **kwargs):
582582
if p['metadata']['labels']['type'] == 'run':
583583
continue
584584

585-
state = self._scheduler.resolve_state(p).name
585+
state = self._scheduler.resolve_state(p)
586586

587587
# follows kubelete convention - these are hidden unless show-all is set
588588
if state in ['down', 'crashed']:

rootfs/scheduler/__init__.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -648,13 +648,14 @@ def resolve_state(self, pod):
648648
return JobState.destroyed
649649

650650
states = {
651-
'Pending': JobState.initialized,
652-
'Starting': JobState.starting,
653-
'Running': JobState.up,
654-
'Terminating': JobState.terminating,
655-
'Succeeded': JobState.down,
656-
'Failed': JobState.crashed,
657-
'Unknown': JobState.error,
651+
'Pending': JobState.initializing.name,
652+
'ContainerCreating': JobState.creating.name,
653+
'Starting': JobState.starting.name,
654+
'Running': JobState.up.name,
655+
'Terminating': JobState.terminating.name,
656+
'Succeeded': JobState.down.name,
657+
'Failed': JobState.crashed.name,
658+
'Unknown': JobState.error.name,
658659
}
659660

660661
# being in a running state can mean a pod is starting, actually running or terminating
@@ -667,7 +668,9 @@ def resolve_state(self, pod):
667668
# is the pod ready to serve requests?
668669
return states[container_status]
669670

670-
return states[pod['status']['phase']]
671+
# if no match was found for deis mapping then passthrough the real state
672+
pod_state = pod['status']['phase']
673+
return states.get(pod_state, pod_state)
671674

672675
def _get_port(self, image):
673676
try:

rootfs/scheduler/states.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33

44
class JobState(enum.Enum):
5-
initialized = 1
6-
created = 2
5+
initializing = 1
6+
creating = 2
77
starting = 3
88
up = 4
99
terminating = 5

0 commit comments

Comments
 (0)