in api-server/tesazure/tesapi/api.py [0:0]
def post(self, task_id):
task = TesTask.get_by_id(task_id)
if not task:
current_app.logger.error("Task cancellation failed: TES task '{task_id}' was not found")
return {'errors': "TES task '{task_id}' was not found"}, 404
if current_app.config['AAD_VERIFY'] is True:
if current_app.config['TASK_ACCESS_RESTRICTIONS'] is not None and task.tenant_id not in [None, jwt_claims['tid']]:
current_app.logger.error("Authorization required to cancel task")
return {'errors': 'Authorization required to cancel task'}, 403
if current_app.config['TASK_ACCESS_RESTRICTIONS'] == 'per-user' and task.user_id not in [None, jwt_claims['sub']]:
current_app.logger.error("Authorization required to cancel task")
return {'errors': 'Authorization required to cancel task'}, 403
else:
if current_app.config['TASK_ACCESS_RESTRICTIONS'] is not None and any(None is not x for x in [task.tenant_id, task.user_id]):
current_app.logger.error("Authorization required to cancel task")
return {'errors': 'Authorization required to cancel task'}, 403
if compute_backend.backend.cancel_task(task.backend_id):
current_app.logger.info(f"TES task '{task_id}' was successfully cancelled")
return "{}"
else:
current_app.logger.error(f"Task cancellation failed: TES task '{task_id}' exists in local cache, but compute backend could not locate backend_id={task.backend_id}")
return {'errors': f"TES task '{task_id}' exists in local cache, but compute backend could not locate it"}, 500