salt icon indicating copy to clipboard operation
salt copied to clipboard

Argument lists for module calls through publish.publish does not work any more

Open mikn opened this issue 12 years ago • 16 comments

According to the documentation here: http://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.publish.html#salt.modules.publish.publish You're supposed to be able to send in a comma-separated list in a string that will be matched against the positional arguments that the module call you're making. This no longer works. I traced it to this commit: https://github.com/saltstack/salt/commit/36fa800821173a4bb1efc950d92b58602c232304 And this issue: #13294 It seems that the argument parser was switched out to a YAML-like parsing style. This lead me to trying a few other types of syntax including YAML style "[item1, item2]" and Python style "['item1', 'item2']" without success. I will locally revert the publish module since it seems that this is a larger issue than just a simple patch.

mikn avatar Nov 20 '14 13:11 mikn

@mikn Thanks for the report. Can you post the output of salt --versions-report and also an example of what command you were using? This will definitely help us to replicate this issue. I suspect you are now running on 2014.7.0, but I just want to make sure. What version were you running on when this was working as you expected?

rallytime avatar Nov 20 '14 17:11 rallytime

versions-report

$ salt --versions-report
           Salt: 2014.7.0
         Python: 2.7.3 (default, Mar 13 2014, 11:03:55)
         Jinja2: 2.6
       M2Crypto: 0.21.1
 msgpack-python: 0.1.10
   msgpack-pure: Not Installed
       pycrypto: 2.6
        libnacl: Not Installed
         PyYAML: 3.10
          ioflo: Not Installed
          PyZMQ: 13.1.0
           RAET: Not Installed
            ZMQ: 3.2.3
           Mako: 0.7.0

This behaved as expected in 2014.1.13...

The syntax I'm using is salt-call --log-level quiet publish.publish '*' deploy.publish 'first,secondparameter,third' Where deploy is a custom module.

mikn avatar Nov 21 '14 12:11 mikn

Thanks for the extra info, @mikn! We'll take a look here.

rallytime avatar Nov 21 '14 20:11 rallytime

Further testing shows that this affects the RAET transport as well and that the decoding of the arg parameter seems to happen at some other point (I suggest here: https://github.com/saltstack/salt/blob/develop/salt/daemons/flo/core.py#L1260) Of course, this only proves that the issue lies within salt.utils.args.parse_args. I'm not sure I have enough time to understand the nitty gritties of this, but I could construct the pull request needed to fix it with some guidance.

My initial thought is that the method parse_input isn't even made to parse the type of argument list received from and specified in the docs for the publish module. What I do not know is what other types of argument lists that pass through proc_run in the RAET case, where the solution belongs or if there is an argument specification that would actually right now work (though, judging by parse_input it is already expecting a split array for its first input).

mikn avatar Dec 05 '14 08:12 mikn

Right. So, after messing around a bit, I managed to figure out that RAET had its own publish module. I removed the list surrounding the yamlify of the arg-list and everything started working magically. I'm not sure that's intended, but it would make sense if that is the fix.

mikn avatar Dec 05 '14 12:12 mikn

I am also running into this issue. @mikn, Can you provide the details of your workaround?

luxi2001 avatar Feb 19 '15 09:02 luxi2001

@luxi2001 The problem lies on this row: https://github.com/saltstack/salt/blob/2014.7/salt/modules/publish.py#L58 It breaks if you want to send more than one argument in. So, what you need to do is something like this (untested code) instead of that single line:

    parsed_args = salt.utils.args.yamlify_arg(arg)
    if isinstance(parsed_args, list):
        arg = parsed_args
    else:
        arg = [parsed_args]

The syntax for a yaml list is slightly different, too. You need to do [value, value, value] and not just value, value, value as it was before. If the values contain commas, you must quote them too, like: ['value, hi', value, 'value, test'] to make it work properly.

If you're using RAET, you must change that line in raet_publish.py and not publish.py :) I will hopefully have time to push a proper fix for this on Tuesday some time!

mikn avatar Feb 22 '15 13:02 mikn

@mikn, is this line also affected? It came in on the same commit.

jfindlay avatar Feb 24 '15 19:02 jfindlay

@mikn, I hope it's fine with you that I've fixed this according to your suggestions.

jfindlay avatar Feb 24 '15 23:02 jfindlay

Oh, of course! Today was a very busy day and I have not validated it completely, but if you feel like it solved your problem and you've tested the four main scenarios (no arguments, one argument, list of arguments and keyword arguments), all is good! On 25 Feb 2015 00:15, "jfindlay" [email protected] wrote:

@mikn https://github.com/mikn, I hope it's fine with you that I've fixed this according to your suggestions.

— Reply to this email directly or view it on GitHub https://github.com/saltstack/salt/issues/18317#issuecomment-75869666.

mikn avatar Feb 24 '15 23:02 mikn

Will this be backported to 2014.7? @rallytime

ryan-lane avatar Mar 09 '15 17:03 ryan-lane

it should be. @jfindlay please backport if needed

thatch45 avatar Mar 09 '15 17:03 thatch45

@ryan-lane, so, there are two parts to this fix:

  • #20992
  • #21047

Both were originally merged into 2014.7 and have both since made it through 2015.2 into develop.

jfindlay avatar Mar 09 '15 21:03 jfindlay

so the next question then is when a new release of 2014.7 will be available with this fix, for those of us who steal the salt ppa packages.

apergos avatar Mar 10 '15 13:03 apergos

@apergos This fix will be available in 2014.7.3, as I don't think this made it into 2014.7.2. However, I am not sure when that release is planned to come out yet. It should be within the next couple of weeks or so.

rallytime avatar Mar 10 '15 15:03 rallytime

we can hang on for two weeks (hope the packages come real soon after that). thanks!

apergos avatar Mar 10 '15 16:03 apergos