Skip to content

Saltnado runner client results in blocking call despite being set-up as Runner.async - #25427

Closed
tony-cocco wants to merge 1 commit into
saltstack:developfrom
tony-cocco:patch-1
Closed

tony-cocco wants to merge 1 commit into
saltstack:developfrom
tony-cocco:patch-1

Conversation

@tony-cocco

Copy link
Copy Markdown

Despite being set up as an asynchronous client, the saltnado call blocks until it returns. The expected behavior is immediately returning object containing a jid, the same response as using client=local_async.

Steps:

  1. POST a command to / using client=runner, example POST body:
    fun=state.orchestrate&client=runner&mods=orchestrate.my_orchestrate&pillar={}

Salt master running on Linux CentOS6. Relevant output of salt --versions-report:

Salt: 2015.5.2
Python: 2.6.6 (r266:84292, Jan 22 2014, 09:42:36)
Jinja2: 2.7.2

A more desirable fix may be to add a new client, runner_async, and convert the current runner to a synchronous model, inline with client=local. For my use case, this fix is perfectly fine as we want everything running async.

The runner client is set up to run jobs asynchronously but currently yields till it returns, defeating the purpose of running it as async. Updated the `_disbatch_runner` to better mirror it's async functionality.
@cachedout

Copy link
Copy Markdown
Contributor

@jacksontj Would you mind having a look at this?

@cachedout cachedout added Core relates to code central or existential to Salt Medium Change pending-discussion The issue or pull request needs more discussion before it can be closed or merged labels Jul 15, 2015
@jacksontj

Copy link
Copy Markdown
Contributor

So this request is a bit confusing, but I think I understand the ask-- so let me recap.

The calls to saltnado with a runner client are non-blocking on the master, but the HTTP request stays open until the response is there (hence your statement "the saltnado call blocks until it returns"). To be clear though-- it is still non-blocking, it just returns more than you want.

From a quick look through the code that is how its documented (runner client returns the full return). This functionality is the same in both the tornado and cherrypy version of the api-- so we can't really change it (let alone the clients!). That being said we can probably add something like runner_async which does what you are looking for. IMO that would be a lot less confusing ;)

@jacksontj jacksontj mentioned this pull request Jul 15, 2015
@jacksontj

Copy link
Copy Markdown
Contributor

PR opened with new runner_async client which will give you that API :)

@whiteinge

Copy link
Copy Markdown
Contributor

👍 for runner_async. That matches the CherryPy module. We'll need support for all the NetapiClient methods in Saltnado before we can retire rest_cherrypy.

jacksontj added a commit to jacksontj/salt that referenced this pull request Jul 15, 2015
@jacksontj

Copy link
Copy Markdown
Contributor

@whiteinge Mind opening a separate issue for those other endpoints? They might take a while, but we can crank them out over time ;) For all of the other ones in saltnado I've had to use localclients etc. directly-- as the API endpoints in netapi were blocking in some way or another. I'll probably want to revisit that now though as tornado is in the core so it would be reasonable to add/change APIs to do some of that stuff ;)

@tony-cocco

Copy link
Copy Markdown
Author

I agree with your recap @jacksontj. However, the difference is a 30s+ REST call and a <1s call. So, while it may truly be non-blocking, the client sits and waits. More aptly, it blocks my promise chain.

+1 to runner_async

Thanks!

@jacksontj

Copy link
Copy Markdown
Contributor

Yea, the intent of saltnado is to make it non-blocking into Salt, not
necessarily to make it nonblocking on the http transaction. In a lot of
cases its actually very useful, because the rest client simply needs to do
the post and all the magic happens. In tornado (or really any non-blocking
framework) maintaining many open sessions isn't expensive-- especially if
they are just waiting for an event to happen (such as the return to show
up).

On Wed, Jul 15, 2015 at 9:10 AM, Anthony Cocco [email protected]
wrote:

I agree with your recap @jacksontj https://github.com/jacksontj.
However, the difference is a 30s+ REST call and a <1s call. So, while it
may truly be non-blocking, the client sits and waits.

+1 to runner_async

Thanks!

—
Reply to this email directly or view it on GitHub
#25427 (comment).

@whiteinge

Copy link
Copy Markdown
Contributor

@jacksontj filed. Definitely make changes as you see fit to RunnerClient and WheelClient to make them truly async on the backend now that Tornado is a core dep.

I'd like to dive in to Saltnado and help with the transition but Salt has my time pretty well tapped for the foreseeable coming months. As you mentioned though, we'll get 'em over time. That interface is stable and doesn't see much churn at all. :-)

@whiteinge

Copy link
Copy Markdown
Contributor

I mentioned this in the above-linked issue but to second it here: The non-async API clients should present a blocking HTTP response regardless of what happens on the backend. The async clients should return an instant response with a JID.

@tony-cocco thanks a ton for diving in here and submitting code! To be consistent with rest_cherrypy and the NetapiClient this is best implemented via support for the runner_async client as in #25457. Closing this in favor of that.

@whiteinge whiteinge closed this Jul 15, 2015
@tony-cocco
tony-cocco deleted the patch-1 branch July 15, 2015 17:53
@tony-cocco

Copy link
Copy Markdown
Author

@whiteinge Completely agree!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Core relates to code central or existential to Salt pending-discussion The issue or pull request needs more discussion before it can be closed or merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants