@@ -84,22 +84,19 @@ def on_message(self, body, message):
8484 Session .query (Workflow )
8585 .filter (
8686 Workflow .id_ == workflow_uuid ,
87- Workflow .status .in_ (ALIVE_STATUSES ),
8887 )
8988 .one_or_none ()
9089 )
91- if workflow :
90+ if workflow and workflow . status in ALIVE_STATUSES :
9291 next_status = body_dict .get ("status" )
9392 if next_status :
9493 next_status = RunStatus (next_status )
9594 logging .info (
96- " [x] Received workflow_uuid: {0} status: {1}" .format (
97- workflow_uuid , next_status
98- )
95+ f" [x] Received workflow_uuid: { workflow_uuid } status: { next_status } "
9996 )
10097
101- logs = body_dict .get ("logs" ) or ""
10298 if workflow .can_transition_to (next_status ):
99+ logs = body_dict .get ("logs" ) or ""
103100 _update_workflow_status (workflow , next_status , logs )
104101 if "message" in body_dict and body_dict .get ("message" ):
105102 msg = body_dict ["message" ]
@@ -113,17 +110,21 @@ def on_message(self, body, message):
113110 f" from status { workflow .status } to"
114111 f" { next_status } ."
115112 )
116- elif workflow_uuid :
113+ elif workflow and workflow . status not in ALIVE_STATUSES :
117114 logging .warning (
118- "Event for not alive workflow {workflow_uuid} received:\n "
119- "{body}\n "
120- "Ignoring ..." .format (workflow_uuid = workflow_uuid , body = body )
115+ f"Event for not alive workflow { workflow .id_ } with DB status { workflow .status } received:\n "
116+ f"{ body } \n Ignoring..."
117+ )
118+ else :
119+ logging .warning (
120+ f"Event for workflow { workflow_uuid } that doesn't exist received:\n "
121+ f"{ body } \n Ignoring..."
121122 )
122123 except REANAWorkflowControllerError as rwce :
123124 logging .error (rwce , exc_info = True )
124125 except SQLAlchemyError as sae :
125126 logging .error (
126- f"Something went wrong while querying the database for workflow: { workflow . id_ } "
127+ f"Something went wrong while querying the database for workflow: { workflow_uuid } "
127128 )
128129 logging .error (sae , exc_info = True )
129130 except Exception as e :
0 commit comments