Skip to content
Snippets Groups Projects
Commit adef8c41 authored by Jörn Künsemöller's avatar Jörn Künsemöller
Browse files

TMSS-877: Leave subtask in FINISHING state in case feedback is overdue

parent a16bea6f
No related branches found
No related tags found
2 merge requests!634WIP: COBALT commissioning delta,!565TMSS-877: Leave subtask in FINISHING state in case feedback is overdue
......@@ -120,16 +120,13 @@ class HybridFeedbackMessageHandler(TMSSEventMessageHandler):
def before_receive_message(self):
# use TMSSEventMessageHandler template pattern to act perform extra business logic in the loop
self._read_feedback_message_and_process(1)
self._set_subtask_status_to_cancelled_upon_feedback_timeout()
self._detect_and_log_feedback_timeout()
super().before_receive_message()
def _set_subtask_status_to_cancelled_upon_feedback_timeout(self):
def _detect_and_log_feedback_timeout(self):
for subtask_id, wait_timeout_timestamp in list(self._finishing_subtasks.items()):
if datetime.utcnow() > wait_timeout_timestamp:
del self._finishing_subtasks[subtask_id]
logger.warning('cancelling subtask id=%s due to timeout of %s seconds while waiting for feedback', subtask_id, self._feedback_wait_timeout)
self._tmss_client.set_subtask_status(subtask_id, 'cancelling')
self._tmss_client.set_subtask_status(subtask_id, 'cancelled')
logger.warning('Feedback for subtask id=%s is overdue and was expected no later than %s! Cancel it or fix the feedback so that this subtask can proceed.', subtask_id, self._feedback_wait_timeout)
def _read_feedback_message_and_process(self, timeout: float=1):
try:
......
......@@ -184,7 +184,7 @@ def populate_subtask_allowed_state_transitions(apps, schema_editor):
SubtaskAllowedStateTransitions(old_state=SCHEDULED, new_state=CANCELLING),
SubtaskAllowedStateTransitions(old_state=QUEUED, new_state=CANCELLING),
SubtaskAllowedStateTransitions(old_state=STARTED, new_state=CANCELLING),
SubtaskAllowedStateTransitions(old_state=FINISHING, new_state=CANCELLING) # when feedback is not complete after a (1 hour) timeout, then the subtask is cancelled.
SubtaskAllowedStateTransitions(old_state=FINISHING, new_state=CANCELLING) # in case feedback is not arriving, a user might choose to cancel a subtask even in this stage
])
def populate_settings(apps, schema_editor):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment