Closed prometheanfire closed 4 years ago
Best reviewed: commit by commit
Powered by Pull Assistant. Last update aae2b5e ... aae2b5e. Read the comment docs.
@prometheanfire Thanks for the PR. There are a couple of angles to explore here.
Your description is clear enough but it would be helpful if you could provide an example of one of the files that has been affected. Just the contents after the first run and then the second run. Ideally, where reasonable, I'd be interested in taking your feedback and reproducing this using Kitchen, so that it can be avoided in the longer-term as well.
It would also be useful if you could provide the details of the environment you're running this in, with the output of salt -V
for both your master and minion.
Reference: https://github.com/saltstack-formulas/bind-formula/issues/146.
While this PR isn't using dictsort
, we'd need to ensure that sort
wouldn't result in similar (or other) problems. Besides, as discussed in the linked issue, this may all be unnecessary with Python 3.6+. It's important to determine whether this solution is a stop-gap or is actually required for the foreseeable future. If the latter, then I'm sure other formulas would be affected by this problem as well.
Confirming, .items()|sort
can result in the same errors as |dictsort
. Followed on from the testing done for the bind-formula
issue linked above:
It's not required for py36+ when sorting dicts, but I think lists are still unsorted so it would be required there. It was my understanding that the sort jinja filter worked the same in all python versions, if not, I guess I'm just disappointed.
It's not required for py36+ when sorting dicts, but I think lists are still unsorted so it would be required there. It was my understanding that the sort jinja filter worked the same in all python versions, if not, I guess I'm just disappointed.
@prometheanfire Actually, this isn't a Jinja issue but a change in Python (3) itself, as mentioned in https://github.com/saltstack-formulas/bind-formula/issues/146. Jinja's |sort
filter is just using Python's sorted()
function after all.
In terms of lists (without |sort
), then they are always rendered in the order that's been defined (i.e. in the pillar). So this shouldn't ever result in idempotency issues, since the ordering will be as received. The end-user is always able to order their lists in any way they please. Actually, forcing a sort on these may result in frustration, where end-users would prefer to order things themselves.
ok, in that case I'll close this for now, I could have sworn that my authorized keys were being reordered every salt run but cannot reproduce.
@prometheanfire Please don't be disheartened by this closed PR; discussions like these are important for the overall developmental quality of these formulas. If it feels like wasted effort, there's a couple of ways to mitigate against that:
#formulas
channel in Slack.I'm not disheartened at all, sorry if it came off that way. I have a bunch of reviews and am used to having to redo them a few times. I'll probably work on the module.run stuff in the linux formula next
@prometheanfire Good to hear, catch up to you in the next PR.
PR progress checklist (to be filled in by reviewers)
What type of PR is this?
Primary type
[build]
Changes related to the build system[chore]
Changes to the build process or auxiliary tools and libraries such as documentation generation[ci]
Changes to the continuous integration configuration[feat]
A new feature[fix]
A bug fix[perf]
A code change that improves performance[refactor]
A code change that neither fixes a bug nor adds a feature[revert]
A change used to revert a previous commit[style]
Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc.)Secondary type
[docs]
Documentation changes[test]
Adding missing or correcting existing testsDoes this PR introduce a
BREAKING CHANGE
?No.
Describe the changes you're proposing
When specifying file content using a for loop, to make sure the content does not change every time (using unsorted lists or dictionaries), pipe the for loop through a sort to normalize it.
Pillar / config required to test the proposed changes
not beyond what is already there
Debug log showing how the proposed changes work
It sorts file contents so ordering doesn't change when the state is applied multiple times.
Documentation checklist
README
(e.g.Available states
).pillar.example
.Testing checklist
state_top
).