diff --git a/SAS/TMSS/backend/services/feedback_handling/lib/feedback_handling.py b/SAS/TMSS/backend/services/feedback_handling/lib/feedback_handling.py index bbff5b48f2c88b5e31e3ab167e953a7e07b948d3..a465e6c17d3b87dab56a2f754ac82f522b6837c7 100644 --- a/SAS/TMSS/backend/services/feedback_handling/lib/feedback_handling.py +++ b/SAS/TMSS/backend/services/feedback_handling/lib/feedback_handling.py @@ -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: diff --git a/SAS/TMSS/backend/src/tmss/tmssapp/populate.py b/SAS/TMSS/backend/src/tmss/tmssapp/populate.py index 4968011b312207b95229539a59daf9e4e933a95d..5e8f8d45fa7d38e0744c5b36e7f604e0f3566ed6 100644 --- a/SAS/TMSS/backend/src/tmss/tmssapp/populate.py +++ b/SAS/TMSS/backend/src/tmss/tmssapp/populate.py @@ -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):