Introduce "module.xrun"#39891
Conversation
thatch45
left a comment
There was a problem hiding this comment.
This looks great, I never liked the module.run interface. I think this is significantly cleaner
|
@thatch45 thanks! :) Before @cachedout pointed me to the Lint, I am already fixing it!! |
|
@cachedout I do not understand Lint error of W1699 against |
rallytime
left a comment
There was a problem hiding this comment.
Very nice! This will be great to have.
I only have one small request: Can you add this new option to the Nitrogen Release Notes? I think people will find this useful and will want to know about it!
whiteinge
left a comment
There was a problem hiding this comment.
Might be worth adding a deprecation notice to module.run for this release or the next.
Given how heavily used it is we might not want to actually put it on a deprecation path but rather just add a notice to that docstring -- the 'ol file.sed treatment. 😉
|
@rallytime I added release notes and hopefully it is correct. @whiteinge I added decorator-based deprecation (and also fixed it is now working for state modules as well). Now it will simply be using new Hint for packagers: create a |
|
@cachedout by now all the issues were addressed. If you think those two lints are just misbehaviour of custom scripts (at my side it doesn't hurt for Python 3 actually), then we are clean to merge. |
|
@isbm sorry my comment above wasn't very clear. I strongly think that we should not deprecate the old Thoughts from the Core team? Agree/disagree? |
|
@whiteinge But this is what exactly is happening. Add to your minion config: use_deprecated:
- module.runAnd you will have the old one. All is needed to be done is to package it properly. E.g. we will ship something like So let's just slowly migrate the world. Two years should be enough to write |
|
Both good points, I think that slowly moving the world would be a good idea, we could easily make sure that the comment returned from module.run specifies that it is going to be deprecated... |
|
I can't speak directly to pros/cons of relying on package upgrades to put that config file in place. Personally, I'd prefer an opt-in rather than an opt-out for such a core module. That said, I'll defer to the Core team since they will be on the front lines of any user upgrade problems. |
|
I would also prefer for opt-in, we do not have the luxury that SUSE has of dictating how the platform is going to be used unfortunately :( |
|
@whiteinge @thatch45 no problems for opt-in. I will change that in the entire mechanism, so all the deprecation will work always on opt-in with "nag messages" to the log. Good point! But now is 1:00AM in Germany, so let me fix that tomorrow CEST. :-) |
|
@thatch45 @whiteinge specially for your preference! Have a nice weekend, guys. P.S. Hmm, nice deprecation mechanism we've just got, BTW... |
There was a problem hiding this comment.
Could potentially overwrite the ret['comment'] & ret['result'] from a previous loop iteration where it fails, depending on the content of the SLS file and the order of the dict.
This would mask a failure under some circumstances when test=True.
There was a problem hiding this comment.
Oh, knapp, you're right. And I forgot to update docstring. Give me a sec...
|
@ScoreUnder done! |
15bdcd6 to
55ab664
Compare
terminalmage
left a comment
There was a problem hiding this comment.
I think the config options can be better retrieved using config.get. There are also a number of things I noticed in the RST that we can clean up.
There was a problem hiding this comment.
Should be "has dropped".
There was a problem hiding this comment.
This can be expressed better in RST using:
.. note::
It is necessary to explicitly turn on the new behavior (see below)
There was a problem hiding this comment.
@thatch45 Did we ever make a firm decision on whether to use US or international spelling for words ending in -or/-our?
There was a problem hiding this comment.
Not american here, sry.
There was a problem hiding this comment.
I honestly don't care which we use, but I think that we should choose one for consistency across the docs.
There was a problem hiding this comment.
They are mixed in the docs. I agree we should pick a style but since we haven't, I see no reason to block on this.
There was a problem hiding this comment.
In that case, yes I definitely agree.
There was a problem hiding this comment.
This should be
Please keep in mind that the old syntax will no longer be supported in the ``Oxygen`` release of Salt.
There was a problem hiding this comment.
The note here could also be put in a .. note:: RST block.
I don't understand this note though, to be honest. Are you suggesting that all minions should have their config files edited? Have you considered using config.get to get these configuration options? It checks grains and pillar as well as the minion config file. This would allow for this option to be turned on simply by editing the pillar data (or using grains.setval to set the value in the minion's /etc/salt/grains). Both of these options seem less intrusive IMO than editing all minions' config files.
There was a problem hiding this comment.
@terminalmage good point on grains. I will extend that, but with a different PR, since I would like to have a different tests for it.
There was a problem hiding this comment.
This would read better as:
To enable the new behavior, add the following to the minion config file:
|
Final call for comments on this one. Otherwise, everything is looking good for a merge. |
|
@cachedout What do you want to do about the PY3 lint errors for the changes in https://jenkins.saltstack.com/job/PR/job/salt-pr-lint-n/9449/violations/file/salt/states/module.py/ |
|
@rallytime I already asked this 5 days ago: please advice what it does mean. Because the code is not incompatible with Python 3 as lint claims. I would think that the script/lint check is flawed, as it does not provide even the reason and proposed fix. Just complaining and complaining wrong (unless I am missing something). Suggestions? I can fix it in 5 minutes, but if I know what... |
|
@isbm Right, all good points. For the record, and so everyone doesn't have to click around and find it, the console output for the PY3 violation displays the following: But, as you stated, this should be working in both versions. If this is something wrong with our linter, then we need to address that. I am thinking @s0undt3ch or @cachedout should provide some direction on this. |
|
@rallytime Hmm. I don't think this is needed fix: the only difference that |
36070a8 to
5592b49
Compare
|
@cachedout OK, today I re-based it one more time against |
|
@isbm That's all I think we need. If the tests pass, I'll merge it. |
|
@cachedout it is all @rallytime 's fault. 😆 (no, not really: thanks for adding unit tests for |
What does this PR do?
Adds a feature:
module.xrunfor states.Motivation
Current way of calling Salt modules with
module.runhas pretty cumbersome interface along with the fact it has also reserved words. This leads to a strange states, something like:Or even worse:
This led to the reasoning make it easier and simpler to use, throw away
m_prefix (this just sucks, sorry). Also write better unit tests. 😄 So the above can be done something like this:Look, Ma! No
m_prefix! How about another example:One more thing you can do (optionally, of course, you don't have to):
😎
Tests written?
Yes