fix: 修复自动化任务原子性error 导致整个任务失败问题

pull/11532/head
feng 2023-06-25 14:30:52 +08:00 committed by Jiangjie.Bai
parent aa52dd51b1
commit 6a75ece739
1 changed files with 5 additions and 5 deletions

View File

@ -109,21 +109,21 @@ class DefaultCallback:
pass pass
def playbook_on_stats(self, event_data, **kwargs): def playbook_on_stats(self, event_data, **kwargs):
failed = []
error_func = lambda err, task_detail: err + f"{task_detail[0]}: {task_detail[1]['stderr']};" error_func = lambda err, task_detail: err + f"{task_detail[0]}: {task_detail[1]['stderr']};"
for tp in ['dark', 'failures']: for tp in ['dark', 'failures']:
for host, tasks in self.result[tp].items(): for host, tasks in self.result[tp].items():
failed.append(host)
error = reduce(error_func, tasks.items(), '').strip(';') error = reduce(error_func, tasks.items(), '').strip(';')
self.summary[tp][host] = error self.summary[tp][host] = error
failures = list(self.result['failures'].keys())
dark_or_failures = list(self.result['dark'].keys()) + failures
for host, tasks in self.result.get('ignored', {}).items(): for host, tasks in self.result.get('ignored', {}).items():
ignore_errors = reduce(error_func, tasks.items(), '').strip(';') ignore_errors = reduce(error_func, tasks.items(), '').strip(';')
if host in failed: if host in failures:
self.summary['failures'][host] += {ignore_errors} self.summary['failures'][host] += {ignore_errors}
self.summary['ok'] = list(set(self.result['ok'].keys()) - set(failed)) self.summary['ok'] = list(set(self.result['ok'].keys()) - set(dark_or_failures))
self.summary['skipped'] = list(set(self.result['skipped'].keys()) - set(failed)) self.summary['skipped'] = list(set(self.result['skipped'].keys()) - set(dark_or_failures))
def playbook_on_include(self, event_data, **kwargs): def playbook_on_include(self, event_data, **kwargs):
pass pass