mirror of
https://github.com/ansible/awx.git
synced 2026-02-16 18:50:04 -03:30
cancel job if receptor no longer knows about the work item
lint
This commit is contained in:
@@ -3168,6 +3168,11 @@ class AWXReceptorJob:
|
|||||||
logger.warn(f"Could not launch pod for {log_name}. Exceeded quota.")
|
logger.warn(f"Could not launch pod for {log_name}. Exceeded quota.")
|
||||||
self.task.update_model(self.task.instance.pk, status='pending')
|
self.task.update_model(self.task.instance.pk, status='pending')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# if we did not exceed the quota, continue with shutting down the job
|
||||||
|
resultsock.shutdown(socket.SHUT_RDWR)
|
||||||
|
resultfile.close()
|
||||||
|
|
||||||
# If ansible-runner ran, but an error occured at runtime, the traceback information
|
# If ansible-runner ran, but an error occured at runtime, the traceback information
|
||||||
# is saved via the status_handler passed in to the processor.
|
# is saved via the status_handler passed in to the processor.
|
||||||
if state_name == 'Succeeded':
|
if state_name == 'Succeeded':
|
||||||
@@ -3251,10 +3256,21 @@ class AWXReceptorJob:
|
|||||||
|
|
||||||
@cleanup_new_process
|
@cleanup_new_process
|
||||||
def cancel_watcher(self, processor_future):
|
def cancel_watcher(self, processor_future):
|
||||||
|
receptor_ctl = get_receptor_ctl()
|
||||||
while True:
|
while True:
|
||||||
if processor_future.done():
|
if processor_future.done():
|
||||||
return processor_future.result()
|
return processor_future.result()
|
||||||
|
|
||||||
|
# cancel job if receptor no longer knows about work item
|
||||||
|
try:
|
||||||
|
receptor_ctl.simple_command(f'work status {self.unit_id}')
|
||||||
|
except RuntimeError:
|
||||||
|
self.task.instance.result_traceback = traceback.format_exc()
|
||||||
|
self.task.instance.save(update_fields=['result_traceback'])
|
||||||
|
|
||||||
|
result = namedtuple('result', ['status', 'rc'])
|
||||||
|
return result('error', 1)
|
||||||
|
|
||||||
if self.task.cancel_callback():
|
if self.task.cancel_callback():
|
||||||
result = namedtuple('result', ['status', 'rc'])
|
result = namedtuple('result', ['status', 'rc'])
|
||||||
return result('canceled', 1)
|
return result('canceled', 1)
|
||||||
|
|||||||
Reference in New Issue
Block a user