Skip to content
Snippets Groups Projects
Commit 13d76fde authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

Task #10902: wait for radb/otdb task status to by in sync

parent a4782c83
No related branches found
No related tags found
No related merge requests found
......@@ -452,15 +452,26 @@ def putTask(task_id):
#the status change will propagate automatically into radb via other services (by design)
otdbrpc.taskSetStatus(task['otdb_id'], updatedTask['status'])
#block until radb and mom task status are equal to otdb task status (with timeout)
#we expect the status in otdb/radb to eventually become what we asked for...
expected_statuses = set([updatedTask['status']])
#except for the prescheduled status, because then the resource assigner tries
#to schedule the task, and it will end up in either 'scheduled', 'conflict', 'error' state.
if updatedTask['status'] == 'prescheduled':
expected_statuses = set(['scheduled', 'conflict', 'error'])
#block until radb and mom task status are equal to the expected_statuses (with timeout)
start_wait = datetime.utcnow()
while True:
task = radb().getTask(otdb_id=task['otdb_id'])
details = momqueryrpc.getObjectDetails(task['mom_id']).get(task['mom_id'])
logger.info('new:%s radb:%s mom:%s', updatedTask['status'], task['status'], details['object_status'])
otdb_status = otdbrpc.taskGetStatus(task['otdb_id'])
logger.info('waiting for otdb/radb task status to be in [%s].... otdb:%s radb:%s',
', '.join(expected_statuses), otdb_status, task['status'])
if task['status'] == updatedTask['status'] and details['object_status'] == updatedTask['status']:
if (task['status'] in expected_statuses and
otdb_status in expected_statuses):
break
if datetime.utcnow() - start_wait > timedelta(seconds=10):
......
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