Skip to content
Snippets Groups Projects

Remove old task retry mechanism

Merged Valentin Rigal requested to merge drop-old-restart into master
All threads resolved!
1 file
+ 7
7
Compare changes
  • Side-by-side
  • Inline
@@ -183,14 +183,14 @@ class TaskTinySerializer(TaskSerializer):
def validate_state(self, state):
"""
Only allow a user to manually stop or retry a task
Only allow a user to manually stop a task
"""
allowed_transitions = {
state: [State.Pending] for state in FINAL_STATES
}
allowed_transitions.update({State.Running: [State.Stopping]})
if self.instance and state not in allowed_transitions.get(self.instance.state, []):
raise ValidationError(f"Transition from state {self.instance.state} to state {state} is forbidden.")
if (
self.instance
and self.instance.state != state
and (self.instance.state != State.Running or state != State.Stopping)
):
raise ValidationError("State can only be updated from running to stopping")
return state
def update(self, instance: Task, validated_data) -> Task:
Loading