Skip to content

Abstracted Transport - #22453

Merged
cachedout merged 172 commits into
saltstack:developfrom
jacksontj:transport
Apr 13, 2015
Merged

cachedout merged 172 commits into
saltstack:developfrom
jacksontj:transport

Conversation

@jacksontj

Copy link
Copy Markdown
Contributor

This is a massive overhaul of the entire transport system within salt (this is the one I mentioned @ SaltConf)

The basic idea in this PR is to abstract out the transport within salt-- since Salt shouldn't care how the bits are shipped to the minion, just that they can and will be. To do this I've taken the "channel" idea and run with it. To do this I've created a "reqchannel" and a "pubchannel" these 2 classes encapsulate the 2 types of messages that salt cares about. For each channel type there are server and client implementations, which means that adding a new transport is simply implementing a base-class and configuring the master.

Now that there is an interface to write transport to I also created a basic TCP implementation which uses the same auth as the current zeromq implementation.

In addition to the abstraction of transport this also introduces tornado as an async programming framework (read: ioloop). This means that we can actually run N transports on a master simultaneously. In addition to making all transport async-- this means we can now make API calls within the master/minion async-- meaning a given MWorker thread could actually have multiple requests in-flight (unlike the single request at a time of today).

In addition to running multiple transports at once this also means we can remove the threading we've been using in MultiMinion and Syndics-- and just use the IOLoop.

There is going to need to be some transition to the new Async interfaces, but this PR includes wrappers which make the async interfaces sync friendly-- so it should be 100% backwards compatible. This just means that if you want your module/runner/etc. to be async (meaning the thread can do something else) you'd have to switch your calls to channels (which are very uncommon) to the async versions.

Before we merge this in I'll need to finish up the docs, but I want to get this opened sooner rather than later to get other people's eyes on it.

jacksontj added 30 commits April 7, 2015 20:51
These daemon processes aren't all thread safe, so having the test suite init then fork is disingenuous since that isn't supported anyways.
A bit more clear since there are client and server-side classes
This is an attempt to pull all transport/crypto logic out of the core master classes.

Once this is completed we should be able to re-use all of this code for all transport types
…the stack, the master-side funcs need to return a dict of opts which specify which send_func to use
@s0undt3ch

Copy link
Copy Markdown
Contributor

I installed tornado to get rid of the import failure :)

@s0undt3ch

Copy link
Copy Markdown
Contributor

None of the lint failures are related to this change.

However, if you find some free time, since saltnado is also your work, could you clean those up? probably best in a different PR.

@jacksontj

Copy link
Copy Markdown
Contributor Author

@s0undt3ch #22555 should be our lint fix, I can pull them into this branch to clear the lint failures if we want, but its probably not necessary ;)

@cachedout

Copy link
Copy Markdown
Contributor

OK, buckle up. Here we go. :]

cachedout pushed a commit that referenced this pull request Apr 13, 2015
@cachedout
cachedout merged commit 6a11ead into saltstack:develop Apr 13, 2015
@s0undt3ch

Copy link
Copy Markdown
Contributor

WooHooo!

@whiteinge

Copy link
Copy Markdown
Contributor

straps in and throws his hands in the air

\o/

@cachedout

Copy link
Copy Markdown
Contributor

@jacksontj

Copy link
Copy Markdown
Contributor Author

Hmm, odd that we didn't see that in jenkins yea? If you guys need help looking into stuff I should have some time today :)

@cachedout

Copy link
Copy Markdown
Contributor

Yeah, odd that we didn't see that before. I have no explanation for that. :]

If you have a minute and can look, it's always very appreciated. :]

@jacksontj

Copy link
Copy Markdown
Contributor Author

@cachedout Are those 2 easily reproducible on Ubuntu? I ran stuff again locally and I'm unable to repro locally... If so maybe time for another VM ;)

@jacksontj

Copy link
Copy Markdown
Contributor Author

Also, is there a way to see log output from those test failures?

@cachedout

Copy link
Copy Markdown
Contributor

Yes. The build artficats for the two errors listed above are here, respective to the order listed originally:

ClearReqTest:
https://jenkins.saltstack.com/job/salt-linode-ubuntu14.04/1404/

NestedSubTest
https://jenkins.saltstack.com/job/salt-linode-ubuntu14.10/97/

You can also use 'Console View' on the left of each of those to get results from the test runner itself. If that's not enough, I can spin up a VM and see if I can get these errors to re-occur. I haven't seen them before this, though, so perhaps they are transient? We'll see. :]

@jacksontj

Copy link
Copy Markdown
Contributor Author

Hmm, for both of there there is absolutely nothing in the logs:

17:36:12,705 [salttesting.xmlunit                                 :76  ][DEBUG   ] >>>>> START >>>>> unit.transport.zeromq_test.ClearReqTestCases.test_basic
17:36:14,733 [salttesting.xmlunit                                 :90  ][DEBUG   ] <<<<< END <<<<<<< unit.transport.zeromq_test.ClearReqTestCases.test_basic
17:16:10,845 [salttesting.xmlunit                                 :90  ][DEBUG   ] <<<<< END <<<<<<< unit.utils.event_test.TestSaltEvent.test_event_nested_subs
17:16:10,846 [salttesting.xmlunit                                 :76  ][DEBUG   ] >>>>> START >>>>> unit.utils.event_test.TestSaltEvent.test_event_no_timeout

I wonder if we just provoked some race condition (zeromq has many..)

@cachedout

Copy link
Copy Markdown
Contributor

That would not surprise me even a little bit. :] The thing to do here may be to wait until we get a little more information from the test suite and see which tests continue to be unstable and then try to come up with an easier-to-reproduce test case.

@jacksontj

Copy link
Copy Markdown
Contributor Author

Yea, that might be good. Especially if its specific platforms which show the failures all the time-- we have found weird bugs in the python bindings before which only manifest in some distros (due to versioning).

@cachedout

Copy link
Copy Markdown
Contributor

Indeed. I'll keep an eye on it and start to look for patterns that might be useful.

@s0undt3ch

Copy link
Copy Markdown
Contributor

There's also salt-runtests.log in the build artifacts if Jenkins was able to download it.

@cachedout

Copy link
Copy Markdown
Contributor

@s0undt3ch I think that's what he pasted the logs from, actually.

@s0undt3ch

Copy link
Copy Markdown
Contributor

Oh! :)

@cachedout

Copy link
Copy Markdown
Contributor

Looks like we're having problems on Ubuntu 10 and Ubuntu 12. Seems to be related to pyzmq 13.x.

https://gist.github.com/rallytime/e8c08f3de470b17ee8c1

We're looking into it as well, but just a heads up.

@jacksontj

Copy link
Copy Markdown
Contributor Author

@rallytime @cachedout Looks like the name for ZMQIOloop (in the pyzmq bindings) came about in v14.0.0 (before that it was simply IOLoop), if we need to support v13.0.0 we'll have to make some helper function to conditionally import it with the old name. IMO we should just upgrade it ;)

@s0undt3ch

Copy link
Copy Markdown
Contributor

We should still support v13.x... Not every user will be willing to update pyzmq unless its packaged, even though we still have some time before we release this code in a major release.

We already advise users to upgrade to v14.x but so far we're not forcing anyone...

@jacksontj

Copy link
Copy Markdown
Contributor Author

Ok, then we'll need to conditionally import... I can throw together a PR in just a minute ;) Assuming the old named one works the same ;)

Comment thread salt/transport/zeromq.py

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any specific reason why we don't init the self.stream reference on the class'es __init__ method?

The reason I ask this is because while writing a py.test plugin which should get a salt master and minion running, and because my current test is just to make sure they are up, ie, no interaction besides connecting has happened before the daemons are shutdown, I'm getting the following error:

Exception TypeError: "'NoneType' object is not callable" in <bound method Minion.__del__ of <salt.minion.Minion object at 0x7fa5747fa710>> ignored

Somewhere on the teardown code of, I think zmq, zmq.eventloop.zmqstream becomes None, and, at that stage, in this stream method, we can't even import zmq.eventloop.zmqstream.

However, if I instantiate the stream on class initialization, I no longer get the error.

Before submitting a pull request I just wanted to know why the deferred initialization on the zmqstream...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not know the specific reason for this, nor can I think of one offhand
but @jacksontj would be the one to provide the best insight here.

On Tue, Oct 20, 2015 at 2:04 AM, Pedro Algarvio [email protected]
wrote:

In salt/transport/zeromq.py
#22453 (comment):

  •    '''
    
  •    messages_len = len(messages)
    
  •    # if it was one message, then its old style
    
  •    if messages_len == 1:
    
  •        payload = self.serial.loads(messages[0])
    
  •    # 2 includes a header which says who should do it
    
  •    elif messages_len == 2:
    
  •        payload = self.serial.loads(messages[1])
    
  •    else:
    
  •        raise Exception(('Invalid number of messages ({0}) in zeromq pub'
    
  •                         'message from master').format(len(messages_len)))
    
  •    ret = yield self._decode_payload(payload)
    
  •    raise tornado.gen.Return(ret)
    
  • @Property
  • def stream(self):

Any specific reason why we don't init the self.stream reference on the
class'es init method?

The reason I ask this is because while writing a py.test plugin which
should get a salt master and minion running, and because my current test is
just to make sure they are up, ie, no interaction besides connecting has
happened before the daemons are shutdown, I'm getting the following error:

Exception TypeError: "'NoneType' object is not callable" in <bound method Minion.del of <salt.minion.Minion object at 0x7fa5747fa710>> ignored

Somewhere on the teardown code of, I think zmq, zmq.eventloop.zmqstream
becomes None, and, at that stage, in this stream method, we can't even
import zmq.eventloop.zmqstream.

However, if I instantiate the stream on class initialization, I no longer
get the error.

Before submitting a pull request I just wanted to know why the deferred
initialization on the zmqstream...

—
Reply to this email directly or view it on GitHub
https://github.com/saltstack/salt/pull/22453/files#r42465926.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A simple test.ping will create the stream instance, so, for now, I've sidestepped the issue but my question is still valid.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just simply lazy creation of the socket. This is really just a holdover of what was done before (we didn't make it until it was needed). We can change it up, but we'd have to make sure that all clients of this class are okay with the socket being inited when the class is (since zmq isn't process/thread safe).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My problem is very particular and seems unrelated to the regular workflow, so, lets leave it alone, at least while an issue regarding regular salt workflow comes up. I can just issue a test.ping(which I actually do need to) for what I'm currently working on...

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.