Relax get_failed_containers() filter
When Ansible is run in check mode, the async_results are missing some keys from regular runs, so we can't really tell if the container has finished and failed; let's just skip it. Closes-Bug: #1871397 Change-Id: I5f99c8e5392326fc8274ca3278966cddd49e0c3d
This commit is contained in:
parent
e0d073b936
commit
bc25dd663e
|
@ -398,8 +398,13 @@ class FilterModule(object):
|
|||
"""
|
||||
failed = []
|
||||
for item in async_results:
|
||||
if item['failed'] or not item['finished']:
|
||||
async_result_item = item['create_async_result_item']
|
||||
for k, v in async_result_item['container_data'].items():
|
||||
failed.append(k)
|
||||
try:
|
||||
if item['failed'] or not item['finished']:
|
||||
async_result_item = item['create_async_result_item']
|
||||
for k, v in async_result_item['container_data'].items():
|
||||
failed.append(k)
|
||||
except KeyError:
|
||||
# if Ansible is run in check mode, the async_results items will
|
||||
# not contain failed or finished keys.
|
||||
continue
|
||||
return failed
|
||||
|
|
|
@ -870,6 +870,15 @@ class TestHelperFilters(tests_base.TestCase):
|
|||
"finished": 0,
|
||||
"results_file": "/root/.ansible_async/316140143697.17616",
|
||||
"started": 1
|
||||
},
|
||||
{
|
||||
"ansible_job_id": "3161822143697.17616",
|
||||
"ansible_loop_var": "container_data",
|
||||
"changed": True,
|
||||
"create_async_result_item": {},
|
||||
"finished": 0,
|
||||
"results_file": "/root/.ansible_async/316143697.17616",
|
||||
"started": 1
|
||||
}
|
||||
]
|
||||
expected_list = ['memcached', 'mysql']
|
||||
|
|
Loading…
Reference in New Issue