You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ConfirmedSalt engineer has confirmed bug/feature - often including a MCVECorerelates to code central or existential to SaltGrainsbugbroken, incorrect, or confusing behaviormust-fixseverity-medium3rd level, incorrect or bad functionality, confusing and lacks a work around
I noticed that using the 'grains' state multiple times results in duplicate list items. One would expect that the grains state immediately updates the roles grains after modifying it.
Ok, this bug is actually more complex, I just noted that the return from the first state has the items from the second state included in its output?!
While visually confusing, this is not an issue. This happens because the stategrains.list_present returns the output of the modulegrains.append. The modulegrains.append is working with the "global" grains object and thus is returning the same dictionary instance each time. At the expense of additional memory this "visual bug" can be easily fixed by making a deep copy of the return from grains.append. I'm not sure it's worth it.
However, it is worth considering the fact that grains.append is returning an object that (I believe) is actually present in the grains. Accidental direct modifications to that object could be reflected in the grains without any of the safeguards of the grain functions. /shrug
ConfirmedSalt engineer has confirmed bug/feature - often including a MCVECorerelates to code central or existential to SaltGrainsbugbroken, incorrect, or confusing behaviormust-fixseverity-medium3rd level, incorrect or bad functionality, confusing and lacks a work around
Activity
jfindlay commentedon Feb 23, 2016
@githubcdr, thanks for reporting. What version of salt are you using?
githubcdr commentedon Feb 23, 2016
2015.8.7
jfindlay commentedon Feb 23, 2016
@githubcdr, I get the following results on 2015.8.3 and 2015.8.7.
Check for duplicate grains during list insertion
43 remaining items
barneysowood commentedon Sep 4, 2025
Ok, this bug is actually more complex, I just noted that the return from the first state has the items from the second state included in its output?!
Also, applying the state again does the right thing..
❯ sudo salt-call grains.get roles local: - elliptic - parabolic - hyperbolic - hyperbolic - diabolic ❯ sudo salt-call state.apply grains-present local: ---------- ID: roles Function: grains.list_present Result: True Comment: Value ['elliptic', 'parabolic', 'hyperbolic'] is already in grain roles Started: 15:32:27.186966 Duration: 1.901 ms Changes: ---------- ID: additional-roles Function: grains.list_present Name: roles Result: True Comment: Value ['hyperbolic', 'diabolic'] is already in grain roles Started: 15:32:27.189092 Duration: 1.059 ms Changes: Summary for local ------------ Succeeded: 2 Failed: 0 ------------ Total states run: 2 Total run time: 2.960 msfix various bugs in list_present
fix various bugs in list_present
fix various bugs in list_present
fix various bugs in list_present
fix various bugs in list_present
Sxderp commentedon Oct 6, 2025
While visually confusing, this is not an issue. This happens because the state
grains.list_presentreturns the output of the modulegrains.append. The modulegrains.appendis working with the "global" grains object and thus is returning the same dictionary instance each time. At the expense of additional memory this "visual bug" can be easily fixed by making a deep copy of the return fromgrains.append. I'm not sure it's worth it.However, it is worth considering the fact that
grains.appendis returning an object that (I believe) is actually present in the grains. Accidental direct modifications to that object could be reflected in the grains without any of the safeguards of the grain functions. /shrugfix various bugs in list_present
fix various bugs in list_present
fix various bugs in list_present
fix various bugs in list_present
fix various bugs in list_present
fix various bugs in list_present