@@ -84,22 +84,19 @@ def on_message(self, body, message):
84
84
Session .query (Workflow )
85
85
.filter (
86
86
Workflow .id_ == workflow_uuid ,
87
- Workflow .status .in_ (ALIVE_STATUSES ),
88
87
)
89
88
.one_or_none ()
90
89
)
91
- if workflow :
90
+ if workflow and workflow . status in ALIVE_STATUSES :
92
91
next_status = body_dict .get ("status" )
93
92
if next_status :
94
93
next_status = RunStatus (next_status )
95
94
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 } "
99
96
)
100
97
101
- logs = body_dict .get ("logs" ) or ""
102
98
if workflow .can_transition_to (next_status ):
99
+ logs = body_dict .get ("logs" ) or ""
103
100
_update_workflow_status (workflow , next_status , logs )
104
101
if "message" in body_dict and body_dict .get ("message" ):
105
102
msg = body_dict ["message" ]
@@ -113,17 +110,21 @@ def on_message(self, body, message):
113
110
f" from status { workflow .status } to"
114
111
f" { next_status } ."
115
112
)
116
- elif workflow_uuid :
113
+ elif workflow and workflow . status not in ALIVE_STATUSES :
117
114
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..."
121
122
)
122
123
except REANAWorkflowControllerError as rwce :
123
124
logging .error (rwce , exc_info = True )
124
125
except SQLAlchemyError as sae :
125
126
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 } "
127
128
)
128
129
logging .error (sae , exc_info = True )
129
130
except Exception as e :
0 commit comments