diff --git a/components/crud-web-apps/jupyter/backend/apps/common/status.py b/components/crud-web-apps/jupyter/backend/apps/common/status.py index c2a2a6fe1..6d0abe7d3 100644 --- a/components/crud-web-apps/jupyter/backend/apps/common/status.py +++ b/components/crud-web-apps/jupyter/backend/apps/common/status.py @@ -133,7 +133,7 @@ def get_status_from_container_state(notebook): # If the Notebook is initializing, the status will be waiting waiting_state = container_state["waiting"] - if ["reason"] == 'PodInitializing': + if waiting_state.get("reason") == 'PodInitializing': status_phase = status.STATUS_PHASE.WAITING status_message = waiting_state.get("reason", "Undetermined reason.") return status_phase, status_message diff --git a/components/crud-web-apps/jupyter/backend/apps/common/status_test.py b/components/crud-web-apps/jupyter/backend/apps/common/status_test.py index 157409195..1e789afea 100644 --- a/components/crud-web-apps/jupyter/backend/apps/common/status_test.py +++ b/components/crud-web-apps/jupyter/backend/apps/common/status_test.py @@ -34,7 +34,7 @@ def test_ready_container_state(self): (None, None) ) - def test_no_message_container_state(self): + def test_pod_initializing_container_state(self): container_state = { "status": { "containerState": { @@ -45,8 +45,41 @@ def test_no_message_container_state(self): } } + self.assertEqual( + status.get_status_from_container_state(container_state), + ("waiting", "PodInitializing") + ) + + def test_no_message_container_state(self): + container_state = { + "status": { + "containerState": { + "waiting": { + "reason": "ImagePullBackOff", + } + } + } + } + self.assertEqual( status.get_status_from_container_state(container_state), ("warning", - "PodInitializing: No available message for container state.") + "ImagePullBackOff: No available message for container state.") + ) + + def test_waiting_container_state_with_message(self): + container_state = { + "status": { + "containerState": { + "waiting": { + "reason": "ImagePullBackOff", + "message": "Back-off pulling image", + } + } + } + } + + self.assertEqual( + status.get_status_from_container_state(container_state), + ("warning", "ImagePullBackOff: Back-off pulling image") )