local_batch through salt-api

96 views
Skip to first unread message

Christian McHugh

unread,
Jul 5, 2015, 3:32:53 AM7/5/15
to salt-...@googlegroups.com
Greetings,

This used to work for me, but I've had a heck of a time with it recently. I am trying to kick off a batch job through the salt api, but it doesn't seem to be batching. 

Here's the json I'm working with:
[{"arg": ["sleep 4; echo testing"],"batch":"1","client":"local_batch","expr_form":"glob","fun":"cmd.run","tgt":"*"}]

and here's the post:
curl -k https://localhost:8000/minions -H 'Accept: application/json' -H "X-Auth-Token: $TOKEN" -H 'Content-Type: application/json' -d "$JSON"

It looks like that command comes back for two hosts in ~5 seconds. Since it should be running with a batch size of 1, and each host should sleep for 4 seconds, it doesn't appear to be working. 

I can run salt '*' -b 1 cmd.run 'sleep 4; echo done' which takes about 9 seconds, so I know it is capable of working. Additionally, I seem to be able to post that json to localhost:8000/ (without the minions endpoint) and it comes back in just over 8 seconds. That's expected, but I would also think that /minions should queue up the job and return a jid. 

Might this be a bug, or am I doing something wacky? 

Thanks all!

Seth House

unread,
Jul 8, 2015, 12:23:25 AM7/8/15
to salt users list
The `/minions` end-point is hard-coded to use the `local_async` client
[1]. Sending the HTTP call to the root end-point is correct for using
the `local_batch` client since batch runs _must_ be performed
synchronously.

[1] http://docs.saltstack.com/en/latest/ref/netapi/all/salt.netapi.rest_cherrypy.html#post--minions
Reply all
Reply to author
Forward
0 new messages