Fix the issue of no 'failed' field in failed ansible module result#2063
Merged
wangxin merged 3 commits intosonic-net:masterfrom Aug 11, 2020
wangxin:fix-no-failed-field
Merged
Fix the issue of no 'failed' field in failed ansible module result#2063wangxin merged 3 commits intosonic-net:masterfrom wangxin:fix-no-failed-field
wangxin merged 3 commits intosonic-net:masterfrom
wangxin:fix-no-failed-field
Conversation
Signed-off-by: Xin Wang <xiwang5@microsoft.com>
lolyu
reviewed
Aug 7, 2020
lolyu
reviewed
Aug 7, 2020
lolyu
approved these changes
Aug 10, 2020
3 tasks
wangxin
added a commit
that referenced
this pull request
Aug 14, 2020
After PR "#2063 Fix the issue of no 'failed' field in failed ansible module result " is merged, the ansible module result will no longer have the 'failed' field filtered out. We now can count on the 'is_failed' property of ansible module result to tell if it is failed or not. However, just assert that the result is failed if the 'failed' field is in the result dict is not safe now. It's because the 'failed' field may have value 'false'. The reboot function in reboot.py may raise false alarm "DUT was not shutdown". The fix: * Explicitly check the 'is_failed' property of localhost.wait_for result to determine whether the DUT is down or up as expected. Signed-off-by: Xin Wang <xiwang5@microsoft.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of PR
Summary:
Fixes #1941
Type of change
Approach
What is the motivation for this PR?
For failed ansible modules, ansible removes fields including {'failed': True} in the result dict before calling callback function of plugins like pytest_ansible. Because pytest_ansible uses a same callback function for succeeded and failed ansible modules, no field like 'failed' is added back to failed ansible module results by pytest_ansible. If we call
res.is_failed(), it will only return True if the ansible module result has non-zerorcfield.For more details, please refer to:
is_failedproperty of failed result of some ansible modules is False ansible/pytest-ansible#47Related PR:
How did you do it?
The list of keys to be removed from failed ansible module results is pre-defined in module variable
ansible.executor.task_result._IGNORE. This change override this variable to exclude thefailedkey.How did you verify/test it?
Prepared a test script:
Host
10.250.0.101is the vlab-01 vs sonic host. It is up and running. Without this fix, thewait_forcall will pass. With this fix, it will fail as expected. Full log of running this script:The failed ansible module has field
{"failed": true}now.Any platform specific information?
Supported testbed topology if it's a new test case?
Documentation