New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when using multiple grains.list_present with dict types in name #47912
Comments
looks like i'm able to replicate this in older versions of salt as well including 2017.7.2 so this is not a regression. If I run the state the second time it looks like it resolves okay. |
Yes, I found it in 2017.7.2 and test it in 2018 I think it resolve the second time because of this cinematic :
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue. |
Hi, do you have any news about this issue? |
Thank you for updating this issue. It is no longer marked as stale. |
@Popovych49 no one is currently assigned to this issue due to other higher priority issues, so please feel free to push a PR if you are able to. thanks |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue. |
Thank you for updating this issue. It is no longer marked as stale. |
Yeah, so we've run into this issue too. The problem seems to be this logic: https://github.com/saltstack/salt/blob/master/salt/utils/data.py#L852-L854 This relies on ptr[each] throwing a KeyError exception if the key doesn't exist. The problem is that the new YAML loader methods create defaultdict objects which don't throw the KeyError exception if the key doesn't exist but instead return a default empty dictionary. The fix is simple, simply check if the key exists in dict to branch logic instead of relying on the exception being thrown. This patch fixed things for us. I am also including a no-whitespace patch which shows the 2 lines we changed because the real patch indents a block of code and we're patching against 3002.8 so the indented block may not look the same for you. Be sure to change the 2 lines from the no-whitespace patch and indent the same block in your version of salt from the real patch. I did check the latest version of salt as of this comment and this method still depends on the exception being thrown to check if the key doesn't exist. traverse_dict_and_list.patch.txt Hope this is useful. |
This was our test case which failed in a number of different ways before the patch. It always required a few state.apply calls to get all the grains set, but sometimes would fail in a unrecoverable state with a list grain being set to the defaultdict {} and then could never add a value to the list. This should fail for you before the patch and work for you without fail and without repeating state.apply calls, after the patch
|
Ran into this issue as well, adding |
Description of Issue/Question
Hi,
There is a weird behavior of grains.list_present when dict-type in name.
When there is two 'grains.list_present' which follow each other, the second state failed.
The first state create the key of the second state, without the value...
Setup
Steps to Reproduce Issue
Launch the previous sls and you will have the following result.
Versions Report
The text was updated successfully, but these errors were encountered: