Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
172 commits
Select commit Hold shift + click to select a range
3bf28b1
Refactor channel classes to have separate pub/req channels
jacksontj Dec 12, 2014
ce04827
A few hacks to get some basic pubchannel working
jacksontj Jan 3, 2015
e8b3105
Rebase in current develop, and add in recv_noblock
jacksontj Jan 7, 2015
fa94083
Consolidate socketopts into channel
jacksontj Jan 7, 2015
7c93360
More work to remove minion.authenticate()
jacksontj Jan 7, 2015
62d9d3c
Switch remaining uses of sreq to channel
jacksontj Jan 8, 2015
8996493
Misc cleanup after rebase
jacksontj Jan 12, 2015
403c81c
Move daemon init and execution into the same process.
jacksontj Jan 13, 2015
e376b28
Refactor the start_daemon function
jacksontj Jan 13, 2015
064896d
Update commented out version as well
jacksontj Jan 13, 2015
3290c32
Remove some unused imports
jacksontj Jan 13, 2015
87fb069
Implement timeout for PubChannel.recv()
jacksontj Jan 13, 2015
645eaf0
Cleanup print from debugging
jacksontj Jan 13, 2015
7bbfba2
More migration to PubChannel
jacksontj Jan 15, 2015
d406b2e
Add "socket" interface to pub_channel, so we can wire it into regular…
jacksontj Jan 15, 2015
21624eb
Remove all final references to self.socket from minion.py
jacksontj Jan 15, 2015
2b0d1e5
Refactor minion events to be their own class instead of spread throug…
jacksontj Jan 15, 2015
fef2e38
Remove some noe-deprecated and unused functions
jacksontj Jan 15, 2015
10e3ec8
Remove old refs to _init_context_and_poller
jacksontj Jan 15, 2015
5e661b0
Pull all fallback cleanup into its own function
jacksontj Jan 15, 2015
1ffac59
Add local channel to factory
jacksontj Jan 16, 2015
5ae95ff
Rename channel to client
jacksontj Jan 19, 2015
f128e47
Initial migration of master-side ReqChannels
jacksontj Jan 19, 2015
8c66c4e
Initial move of publisher into PubServerChannel
jacksontj Jan 19, 2015
422d1c2
Re-work req_channel in the master daemons, now we don't pass it down …
jacksontj Jan 27, 2015
ea49cbc
Change req_fun default to send (which is encrypted)
jacksontj Jan 27, 2015
0ddd4ec
Migrate _auth logic into the ReqServerChannel
jacksontj Jan 27, 2015
8e0316d
Misc cleanup
jacksontj Jan 27, 2015
0a0caf6
Hacking to fix various things broken in rebase
jacksontj Feb 10, 2015
6fb0ec1
Initial addition of tcp channel
jacksontj Feb 21, 2015
4bd71f9
More hacking to get tcp working
jacksontj Feb 25, 2015
5731a01
Remove testing code
jacksontj Feb 28, 2015
11195c4
Cleanup pubchannel polling
jacksontj Feb 28, 2015
fc83b44
Major overhaul of tcp implementation
jacksontj Feb 28, 2015
374d415
Re-work PubChannel
jacksontj Feb 28, 2015
6d372d7
ReqChannel cleanup
jacksontj Feb 28, 2015
543c56d
Revert register poller, we'll just have the minion exit
jacksontj Feb 28, 2015
5492036
Misc cleanup
jacksontj Feb 28, 2015
fb107b0
Whitespace cleanup
jacksontj Feb 28, 2015
b7f4fc2
Remove rep_hwm (doesn't do anything)
jacksontj Feb 28, 2015
de21707
cleanup
jacksontj Feb 28, 2015
ae0d92a
Don't make a copy of the list to iterate (it might be very large). In…
jacksontj Mar 1, 2015
8815bf3
Fix socket recv_frame
jacksontj Mar 6, 2015
4ff4bfb
Cleanup shutdown of publisher
jacksontj Mar 6, 2015
0b03534
move publisher to IOLoop
jacksontj Mar 7, 2015
2336b33
Allow passing in of header
jacksontj Mar 7, 2015
b1bb0d6
fix typo
jacksontj Mar 7, 2015
5bee564
Switch ReqServer over to IOLoop
jacksontj Mar 7, 2015
9d60629
Add un-tested SaltMessageClient
jacksontj Mar 7, 2015
35977e4
Misc cleanup
jacksontj Mar 7, 2015
c1b41b2
Migrate zeromq channel over to ioloop as well
jacksontj Mar 7, 2015
d2bfe50
Very basic zmq and tcp support
jacksontj Mar 9, 2015
b192602
Switch Req client over to tornado based client
jacksontj Mar 10, 2015
759f5b3
consolidate master-side transport parsing
jacksontj Mar 10, 2015
8750875
Logging cleanup
jacksontj Mar 10, 2015
58c16f2
Rough-in of io_loop in minion
jacksontj Mar 10, 2015
798c062
Misc cleanup to single minion
jacksontj Mar 11, 2015
8ab5fdc
Basic multisyndic working now
jacksontj Mar 11, 2015
58982b0
Cleanup pub channel
jacksontj Mar 11, 2015
54f4760
cleanup
jacksontj Mar 11, 2015
78b69b1
Add scheduler
jacksontj Mar 11, 2015
f22539d
Make SaltMessageClient auto-reconnect
jacksontj Mar 12, 2015
034df05
Last switch over to iter_transport_opts (support 1->N transports)
jacksontj Mar 12, 2015
180408e
Make publisher not wait for writes
jacksontj Mar 12, 2015
71c8dea
loop_interval is a float, lets leave it that way
jacksontj Mar 12, 2015
714e61f
Don't set 'enc' to clear on clear returns, some jobs don't return dicts
jacksontj Mar 13, 2015
5fb59c8
Cleanup some IOLoops
jacksontj Mar 13, 2015
1392cd6
Add timeouts to tcp implementation
jacksontj Mar 13, 2015
e11a914
Add support for un-registering the on_recv
jacksontj Mar 13, 2015
9cda2f0
Cleanup multiminion to work on the ioloop
jacksontj Mar 13, 2015
4dd74a1
Remove Event poller (since we are doing IOLoops now)
jacksontj Mar 13, 2015
9094c10
Since each minion object handles its own events, lets not double send :)
jacksontj Mar 13, 2015
b9d03c5
Remove recv() from pub_channels (now we use on_recv)
jacksontj Mar 13, 2015
4baec17
Remove unecessary imports
jacksontj Mar 13, 2015
00021ce
Pylint
jacksontj Mar 13, 2015
d619dfb
Add initial req_channel tests
jacksontj Mar 13, 2015
1a88eee
Add basic Pub channel tests
jacksontj Mar 13, 2015
8c7ee31
Begin work on async auth/pub/req channels.
jacksontj Mar 16, 2015
de26e7e
Handle timeouts in auth/pub connect
jacksontj Mar 20, 2015
6ab5da8
Cleanup async
jacksontj Mar 20, 2015
bdbf6a3
misc cleanup
jacksontj Mar 20, 2015
bfeb3bf
Misc cleanup to get the minion to use async sign_in
jacksontj Mar 21, 2015
6410b40
We aren't doing singleton module loaders, lets not clear what we just…
jacksontj Mar 21, 2015
bdc5d6d
Remove threading from MultiMinion
jacksontj Mar 21, 2015
2c36c95
Cleanup
jacksontj Mar 21, 2015
50fc615
More cleanup
jacksontj Mar 21, 2015
a998eb0
Make destroy properly unload things
jacksontj Mar 21, 2015
181b12c
Remove threading from MultiSyndic
jacksontj Mar 21, 2015
cd2c816
Fix syndic event forwarding
jacksontj Mar 21, 2015
b470346
Change pubchannel over in zeromq
jacksontj Mar 21, 2015
a68cf08
Remove remnants of old Sync pub channel
jacksontj Mar 21, 2015
9ec426b
Add basic Asyncpubchannel tests to zmq
jacksontj Mar 21, 2015
2ce0582
Add unregister tests
jacksontj Mar 21, 2015
b1ca45d
Refactor pub tests
jacksontj Mar 21, 2015
c855770
Fix misc tests
jacksontj Mar 21, 2015
540710c
Cleanup shutdown of tests
jacksontj Mar 21, 2015
e04ef8b
Always attempt to send errors to clients
jacksontj Mar 21, 2015
98b53bd
Fix mocking, not quite sure how this magic mock works
jacksontj Mar 21, 2015
30f9d37
Merge cleanup
jacksontj Mar 23, 2015
c755328
Fix rebase collisions
jacksontj Mar 23, 2015
fd4fff8
Misc cleanup
jacksontj Mar 24, 2015
cade95a
Make Sync wrapper for async req channels
jacksontj Mar 24, 2015
f7c7551
Remove sleep from saltmessageclient
jacksontj Mar 25, 2015
952d724
Switch tcp req channel over to async auth libraries
jacksontj Mar 25, 2015
c6245c8
Reset asyncauth singleton in tests
jacksontj Mar 25, 2015
e89da4e
Make AsyncAuth singleton per io_loop
jacksontj Mar 26, 2015
aac2337
Move syncwrapper to utils-- since we'll have more uses for it
jacksontj Mar 26, 2015
8ec0729
Change the Auth base class to AsyncAuth
jacksontj Mar 26, 2015
49603ff
Add weakref to SAuth
jacksontj Mar 26, 2015
d325de0
Fix exceptional case where no timeout is set
jacksontj Mar 26, 2015
b625b01
Properly bubble up auth failures to the future
jacksontj Mar 27, 2015
cb92263
Attempt to return nice errors even if it wasn't properly msgpackd
jacksontj Mar 27, 2015
61eb58c
Migrate zeromq req channel to async interfaces
jacksontj Mar 29, 2015
98842a8
Fix zmq pub channels
jacksontj Mar 29, 2015
b330052
Better message_id handling
jacksontj Mar 31, 2015
e372de4
Cleanup auth future, and pass io_loop to instance
jacksontj Mar 31, 2015
9affc2d
Overwrite the current IOLoop for blocking calls
jacksontj Apr 1, 2015
e17824a
Change _handle_payload to return a future.
jacksontj Apr 1, 2015
ec4a777
Share creds between all channels (if you can).
jacksontj Apr 1, 2015
02995a1
Fix calls to send() to not specify a callback of int
jacksontj Apr 2, 2015
d626d83
Handle case where we miss first sign-in
jacksontj Apr 2, 2015
d87c62b
Make transport unit tests pull configs from test suite instead of fro…
jacksontj Apr 2, 2015
bedde63
SNDTIMEO is not implemented in pyzmq, and since we are using linger t…
jacksontj Apr 2, 2015
3b5281f
Term context of AsyncEventPublisher on destroy()
jacksontj Apr 2, 2015
2781cb8
Make sure to hand out RAET channels on the old interface
jacksontj Apr 3, 2015
0363cf3
Simplify TCP wire protocol
jacksontj Apr 3, 2015
396f021
More cleanup of tcp wire framing-- pushing msgpacks down a layer
jacksontj Apr 3, 2015
b673dcf
Lint cleanup
jacksontj Apr 3, 2015
1e38bd1
Fix merge
jacksontj Apr 3, 2015
dfd606a
Add tornado dependancy
jacksontj Apr 3, 2015
d21e180
Fix race condition in integration test startup
jacksontj Apr 4, 2015
cb02d0e
Remove "close()" api-- just use a destructor
jacksontj Apr 4, 2015
0f4126a
Cleanup AsyncEvent publisher
jacksontj Apr 8, 2015
f5e2650
Add basic tests for asyncEventpublisher
jacksontj Apr 8, 2015
bf97e8c
Make sure to close server processes after each test.
jacksontj Apr 8, 2015
348118f
Mock/stub out _send_pub in ClearFuncs
jacksontj Apr 8, 2015
098515b
Pylint
jacksontj Apr 8, 2015
9ad56d4
Pylint
jacksontj Apr 8, 2015
171bd32
Pylint cleanup in TCP transport module
jacksontj Apr 8, 2015
cc06dd6
Pylint
jacksontj Apr 8, 2015
2683843
pylint cleanup
jacksontj Apr 8, 2015
a30a0f8
pylint cleanup
jacksontj Apr 8, 2015
4ee8c2e
pylint cleanup
jacksontj Apr 8, 2015
5c7df14
pylint cleanup
jacksontj Apr 8, 2015
6b3d1bc
pylint cleanup
jacksontj Apr 8, 2015
f6e239a
pylint cleanup
jacksontj Apr 8, 2015
10ec334
pylint cleanup
jacksontj Apr 8, 2015
a2bc334
pylint cleanup
jacksontj Apr 8, 2015
7a3cca4
pylint cleanup
jacksontj Apr 8, 2015
e0e8868
Clean up flo zmq deed, since we have changed the MWorker
jacksontj Apr 8, 2015
1f963df
pylint cleanup
jacksontj Apr 8, 2015
4f46fa3
pylint cleanup
jacksontj Apr 8, 2015
11e8a15
pylint cleanup
jacksontj Apr 8, 2015
6a34d1d
Remove AES key initing-- since we are mocking out _send_pub
jacksontj Apr 8, 2015
f07840f
pylint cleanup
jacksontj Apr 8, 2015
ce850a3
pylint cleanup
jacksontj Apr 8, 2015
c47685f
Correct comment of wire-protocol
jacksontj Apr 8, 2015
3b7170d
Add initial transport docs
jacksontj Apr 8, 2015
92ff4ff
typo fixing!
jacksontj Apr 8, 2015
7674b1f
pylint cleanup
jacksontj Apr 8, 2015
a85de89
pylint cleanup
jacksontj Apr 8, 2015
106f091
pylint cleanup
jacksontj Apr 8, 2015
7433194
fix typo
jacksontj Apr 8, 2015
3971b72
Remove unused imports
jacksontj Apr 8, 2015
48095e1
More proactive cleanup in sync wrapper
jacksontj Apr 9, 2015
069af4b
Destructors for the transport classes
jacksontj Apr 9, 2015
88ad56c
Make sure to close sockets on deletion of pubchannels as well
jacksontj Apr 9, 2015
8ff37b3
Check for FDs attached to the IOLoops after test runs
jacksontj Apr 10, 2015
6cd6055
Add workaround to a bug in pyzmq's stream.close()
jacksontj Apr 10, 2015
66016ed
pylint
jacksontj Apr 10, 2015
df0c170
Set a linger of 0 on the stream's socket, and dont try to close twice
jacksontj Apr 10, 2015
4c5ac66
pylint cleanup
jacksontj Apr 10, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions doc/topics/transports/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
==============
Salt Transport
==============

One of fundamental features of Salt is remote execution. Salt has two basic
"channels" for communicating with minions. Each channel requires a
client (minion) and a server (master) implementation to work within Salt. These
pairs of channels will work together to implement the specific message passing
required by the channel interface.


Pub Channel
===========
The pub channel, or publish channel, is how a master sends a job (payload) to a
minion. This is a basic pub/sub paradigm, which has specific targeting semantics.
All data which goes across the publish system should be encrypted such that only
members of the Salt cluster can decrypt the publishes.


Req Channel
===========
The req channel is how the minions send data to the master. This interface is
primarily used for fetching files and returning job returns. The req channels
have two basic interfaces when talking to the master. ``send`` is the basic
method that guarantees the message is encrypted at least so that only minions
attached to the same master can read it-- but no guarantee of minion-master
confidentiality, wheras the ``crypted_transfer_decode_dictentry`` method does
guarantee minion-master confidentiality.


.. toctree::

zeromq
tcp
raet/index
45 changes: 45 additions & 0 deletions doc/topics/transports/tcp.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
=============
TCP Transport
=============

The "tcp" transport is an implementation of Salt's channels using raw tcp sockets.
Since this isn't using a pre-defined messaging library we will describe the wire
protocol, message semantics, etc. in this document.


Wire Protocol
=============
This implementation over TCP focuses on flexibility over absolute efficiency.
This means we are okay to spend a couple of bytes of wire space for flexibility
in the future. That being said, the wire framing is quite efficient and looks
like:

.. code-block:: text
len(payload) msgpack({'head': SOMEHEADER, 'body': SOMEBODY})

The wire protocol is basically two parts, the length of the payload and a payload
(which is a msgpack'd dict). Within that payload we have two items "head" and "body".
Head contains header information (such as "message id"). The Body contains the
actual message that we are sending. With this flexible wire protocol we can
implement any message semantics that we'd like-- including multiplexed message
passing on a single socket.


Crypto
======
The current implementation uses the same crypto as the ``zeromq`` transport.


Pub Channel
===========
For the pub channel we send messages without "message ids" which the remote end
interprets as a one-way send.

.. note::
As of today we send all publishes to all minions and rely on minion-side filtering.


Req Channel
===========
For the req channel we send messages with a "message id". This "message id" allows
us to multiplex messages across the socket.
26 changes: 26 additions & 0 deletions doc/topics/transports/zeromq.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
================
Zeromq Transport
================

.. note::

Zeromq is the current default transport within Salt

Zeromq is a messaging library with bindings into many languages. Zeromq implements
a socket interface for message passing, with specific semantics for the socket type.


Pub Channel
===========
The pub channel is implemented using zeromq's pub/sub sockets. By default we don't
use zeromq's filtering, which means that all publish jobs are sent to all minions
and filtered minion side. Zeromq does have publisher side filtering which can be
enabled in salt using :conf_master:`zmq_filtering`.


Req Channel
===========
The req channel is implemented using zeromq's req/rep sockets. These sockets
enforce a send/recv pattern, which forces salt to serialize messages through these
socket pairs. This means that although the interface is asynchronous on the minion
we cannot send a second message until we have recieved the reply of the first message.
1 change: 1 addition & 0 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ msgpack-python > 0.3
PyYAML
MarkupSafe
requests >= 1.0.0
tornado >= 4.0
24 changes: 11 additions & 13 deletions salt/auth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
# Import salt libs
import salt.config
import salt.loader
import salt.transport.client
import salt.utils
import salt.utils.minions
import salt.payload
Expand Down Expand Up @@ -337,20 +338,17 @@ def __init__(self, opts):

def _send_token_request(self, load):
if self.opts['transport'] == 'zeromq':
sreq = salt.payload.SREQ(
'tcp://{0}:{1}'.format(
salt.utils.ip_bracket(self.opts['interface']),
self.opts['ret_port']),
opts=self.opts
)
tdata = sreq.send('clear', load)
return tdata
master_uri = 'tcp://' + salt.utils.ip_bracket(self.opts['interface']) + \
':' + str(self.opts['ret_port'])
channel = salt.transport.client.ReqChannel.factory(self.opts,
crypt='clear',
master_uri=master_uri)
return channel.send(load)

elif self.opts['transport'] == 'raet':
sreq = salt.transport.Channel.factory(
self.opts)
sreq.dst = (None, None, 'local_cmd')
tdata = sreq.send(load)
return tdata
channel = salt.transport.client.ReqChannel.factory(self.opts)
channel.dst = (None, None, 'local_cmd')
return channel.send(load)

def cli(self, eauth):
'''
Expand Down
2 changes: 1 addition & 1 deletion salt/cli/caller.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def factory(opts, **kwargs):
ttype = opts['pillar']['master']['transport']

# switch on available ttypes
if ttype == 'zeromq':
if ttype in ('zeromq', 'tcp'):
return ZeroMQCaller(opts, **kwargs)
elif ttype == 'raet':
return RAETCaller(opts, **kwargs)
Expand Down
6 changes: 4 additions & 2 deletions salt/cli/daemons.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ def prepare(self):
self.setup_logfile_logger()
logger.info('Setting up the Salt Master')

if self.config['transport'].lower() == 'zeromq':
# TODO: AIO core is separate from transport
if self.config['transport'].lower() in ('zeromq', 'tcp'):
if not verify_socket(self.config['interface'],
self.config['publish_port'],
self.config['ret_port']):
Expand Down Expand Up @@ -224,7 +225,8 @@ def prepare(self):
)
)
migrations.migrate_paths(self.config)
if self.config['transport'].lower() == 'zeromq':
# TODO: AIO core is separate from transport
if self.config['transport'].lower() in ('zeromq', 'tcp'):
# Late import so logging works correctly
import salt.minion
# If the minion key has not been accepted, then Salt enters a loop
Expand Down
6 changes: 4 additions & 2 deletions salt/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ def get_local_client(
if opts['transport'] == 'raet':
import salt.client.raet
return salt.client.raet.LocalClient(mopts=opts)
elif opts['transport'] == 'zeromq':
# TODO: AIO core is separate from transport
elif opts['transport'] in ('zeromq', 'tcp'):
return LocalClient(mopts=opts, skip_perm_errors=skip_perm_errors)


Expand Down Expand Up @@ -826,7 +827,8 @@ def get_returns_no_block(
for tag in tags_regex:
tag_search.append(re.compile(tag))
while True:
if self.opts.get('transport') == 'zeromq':
# TODO: this is a check of event type, NOT transport type!
if self.opts.get('transport') in ('zeromq', 'tcp'):
try:
raw = event.get_event_noblock()
if gather_errors:
Expand Down
Loading