Skip to content

add kwargs to be passed from grains.setval to saltutil.refresh_grains#56020

Closed
jtraub91 wants to merge 1 commit intosaltstack:masterfrom
jtraub91:set_val_refresh_pillar_fix
Closed

add kwargs to be passed from grains.setval to saltutil.refresh_grains#56020
jtraub91 wants to merge 1 commit intosaltstack:masterfrom
jtraub91:set_val_refresh_pillar_fix

Conversation

@jtraub91
Copy link
Copy Markdown
Contributor

What does this PR do?

Allows kwargs to be passed thru to grains.setval

What issues does this PR fix or reference?

This allows the user to specify refresh_pillar=False

@jtraub91 jtraub91 requested a review from a team as a code owner January 29, 2020 19:24
@ghost ghost requested a review from cmcmarrow January 29, 2020 19:24
@jtraub91 jtraub91 changed the title add kwargs add kwargs to be passed from grains.setval to saltutil.refresh_grains Jan 29, 2020
@Akm0d Akm0d added Grains needs-testcase PR needs test cases written, or the issue is about a bug/feature that needs test cases labels Jan 30, 2020
@Akm0d Akm0d added this to the Approved milestone Jan 30, 2020
@max-arnold
Copy link
Copy Markdown
Contributor

How a user (who is not familiar with the code) is supposed to discover that it is possible to pass refresh_pillar=False to these functions?

@alan-cugler
Copy link
Copy Markdown
Contributor

This does not need test case since its a bug fix not a new feature request.

As for user discovery of possible key:value to pass, that can be added in a one liner to the docs.

@waynew
Copy link
Copy Markdown
Contributor

waynew commented Jan 31, 2020

This does not need test case since its a bug fix not a new feature request.

(Un)fortunately that statement is incorrect.

Tests are required for bug fixes to prevent regressions. If we can't reproduce a problem with a test case, it's likely that we haven't fully understood the problem.

Adding tests that exhibit the existing problem will at least notify us if we re-introduce that problem in the future.

@jtraub91
Copy link
Copy Markdown
Contributor Author

The "problem" that's occurring is that pillar is refreshed when setting grains with set_val. I added the ability to pass kwargs as a "quick fix" to allow for bypassing the pillar refresh. I would argue that the bigger issue is that the default behavior of saltutil.refresh_grains is to also refresh the pillar. Changing this would likely break things for people, however..

@sagetherage
Copy link
Copy Markdown
Contributor

talking to @Ch3LL if this is intended https://github.com/saltstack/salt/blob/master/salt/modules/saltutil.py#L383-L385 and the better fix would be to add refresh_pillar as a specific kwarg, and yes as @waynew stated please add a test

@DmitryKuzmenko
Copy link
Copy Markdown
Contributor

@jtraub91 are you able to follow up the suggestions?

@DmitryKuzmenko
Copy link
Copy Markdown
Contributor

@jtraub91 please let me know if I can help here.

@jtraub91
Copy link
Copy Markdown
Contributor Author

jtraub91 commented Apr 6, 2020

@DmitryKuzmenko I can re-implement this by specifying refresh_pillar as a specific kwarg, but I still don't think this warrants a new test case. Not sure what I would even test in that scenario.

@DmitryKuzmenko
Copy link
Copy Markdown
Contributor

@jtraub91 yes please if possible.
What about test, no problem with it. All you need is just to add a test to tests/unit/modules/test_grains.py that mocks saltutil.refresh_grains and checks it's called with proper refresh_pillar value.

@jtraub91
Copy link
Copy Markdown
Contributor Author

jtraub91 commented Apr 7, 2020

@DmitryKuzmenko Ok. Will do.

@DmitryKuzmenko
Copy link
Copy Markdown
Contributor

Thank you!

jtraub91 added a commit to jtraub91/salt that referenced this pull request Apr 7, 2020
jtraub91 added a commit to jtraub91/salt that referenced this pull request Apr 7, 2020
jtraub91 added a commit to jtraub91/salt that referenced this pull request Apr 7, 2020
jtraub91 added a commit to jtraub91/salt that referenced this pull request Apr 7, 2020
@jtraub91
Copy link
Copy Markdown
Contributor Author

jtraub91 commented Apr 7, 2020

Changes have been pushed. Not sure why it's saying "unknown repository" above, so I opened a new PR to resolve this. Further discussion should ensure there (#56573) and this PR can be closed.

@DmitryKuzmenko
Copy link
Copy Markdown
Contributor

@jtraub91 am I right we can close this now?

@jtraub91
Copy link
Copy Markdown
Contributor Author

jtraub91 commented Apr 8, 2020

@DmitryKuzmenko Yes and let's make sure we get #56573 merged.

@DmitryKuzmenko
Copy link
Copy Markdown
Contributor

I will.

dwoz pushed a commit that referenced this pull request Apr 26, 2020
dwoz pushed a commit that referenced this pull request Apr 26, 2020
dwoz pushed a commit that referenced this pull request Apr 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Grains needs-testcase PR needs test cases written, or the issue is about a bug/feature that needs test cases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants