|
22 | 22 | from webargs import fields, validate
|
23 | 23 | from webargs.flaskparser import use_args, use_kwargs
|
24 | 24 | from reana_commons.config import WORKFLOW_TIME_FORMAT
|
| 25 | +from reana_commons.utils import build_unique_component_name |
25 | 26 | from reana_db.database import Session
|
26 | 27 | from reana_db.models import RunStatus, User, UserWorkflow, Workflow, WorkflowResource
|
27 | 28 | from reana_db.utils import (
|
|
48 | 49 | use_paginate_args,
|
49 | 50 | )
|
50 | 51 |
|
| 52 | +from reana_workflow_controller.k8s import check_pod_by_prefix |
| 53 | + |
51 | 54 | START = "start"
|
52 | 55 | STOP = "stop"
|
53 | 56 | DELETED = "deleted"
|
@@ -398,7 +401,20 @@ def get_workflows(args, paginate=None): # noqa
|
398 | 401 | if int_session:
|
399 | 402 | workflow_response["session_type"] = int_session.type_.name
|
400 | 403 | workflow_response["session_uri"] = int_session.path
|
| 404 | + int_session_pod_name_prefix = build_unique_component_name( |
| 405 | + "run-session", int_session.workflow[0].id_ |
| 406 | + ) |
| 407 | + if int_session.status == RunStatus.created: |
| 408 | + pod_status = check_pod_by_prefix( |
| 409 | + pod_name_prefix=int_session_pod_name_prefix |
| 410 | + ) |
| 411 | + if pod_status == "Running": |
| 412 | + int_session.status = RunStatus.running |
| 413 | + db_session = Session.object_session(int_session) |
| 414 | + db_session.commit() |
| 415 | + |
401 | 416 | workflow_response["session_status"] = int_session.status.name
|
| 417 | + |
402 | 418 | # Skip workflow if type is interactive and there is no session
|
403 | 419 | elif type_ == "interactive":
|
404 | 420 | continue
|
|
0 commit comments