Surface errors when launching jobs through Receptor

This will raise errors such as:

exec: "ansible-runner": executable file not found in $PATH
This commit is contained in:
Shane McDonald 2020-11-21 11:01:09 -05:00 committed by Shane McDonald
parent fd92ba0c0b
commit be8168b555

View File

@ -1529,10 +1529,12 @@ class BaseTask(object):
receptor_ctl = ReceptorControl('/var/run/receptor/receptor.sock')
result = receptor_ctl.submit_work(worktype=worktype,
payload=sockout.makefile('rb'))
unit_id = result['unitid']
sockin.close()
sockout.close()
resultsock, resultfile = receptor_ctl.get_work_results(result['unitid'],
resultsock, resultfile = receptor_ctl.get_work_results(unit_id,
return_socket=True,
return_sockfile=True)
@ -1547,7 +1549,7 @@ class BaseTask(object):
def cancel_watcher(processor_future):
while True:
if processor_future.done():
return
return processor_future.result()
if self.cancel_callback():
result = namedtuple('result', ['status', 'rc'])
@ -1569,11 +1571,15 @@ class BaseTask(object):
res = list(first_future.done)[0].result()
if res.status == 'canceled':
receptor_ctl.simple_command(f"work cancel {result['unitid']}")
receptor_ctl.simple_command(f"work cancel {unit_id}")
resultsock.shutdown(socket.SHUT_RDWR)
resultfile.close()
elif res.status == 'error':
# TODO: There should be a more efficient way of getting this information
receptor_work_list = receptor_ctl.simple_command("work list")
raise RuntimeError(receptor_work_list[unit_id]['Detail'])
receptor_ctl.simple_command(f"work release {result['unitid']}")
receptor_ctl.simple_command(f"work release {unit_id}")
status = res.status
rc = res.rc