Skip to content
Permalink
Browse files

Add a http/2 listener to the daemon

So we can benefit from http headers for authentication, streams multiplexing,
server push, and open the api to standard client-side tools, like wget, curl,
and browsers.

This patch also split the ambiguous --node option into:

* --node <node selector expression>
  nodes the action applies to

* --server <uri>
  server address where to send the request to. ex: https://node2:1215.
  the default https port is 1215, so it can be ommited. The old jsonrpc over
  socket scheme is "raw", so raw://node2 is valid.

The http/2 server implements 2 cascaded auth method for now:

* x509 (user is looked-up in the 'cn' attr)
* cluster secret header (o-secret: xxxxx), which grants root privileges

The "events" handler uses Server-Sent Events (SSE) if the client has set a
"accept: text/event-stream" header, otherwise it uses http/2 server pushes.
The "om node events" command asks for http/2 pushes, web brower apps should
ask for SSE until http/2 server pushes are exposed in javascript.

For now arbitrators and relays comms are forced to use the raw scheme, to
ease transition. Later patches will allow pointing relays and arbitrators
by uri, so the scheme can be switched.

Refactorings:

* daemon_get() replaces daemon_send()
* daemon_stream() replaces both daemon_get_stream() and daemon_get_streams()
* the listener acts as a "get" and "stream" proxy for its peer listeners
* the per-client listener threads now use a ClientHandler class, avoiding
the args/kwargs mess that built-up
  • Loading branch information...
cvaroqui committed Jun 27, 2019
1 parent f9b854b commit cb1337e5f9647f50a28773ddb94d4408ce8fa77e
Showing with 1,395 additions and 695 deletions.
  1. +331 −168 lib/comm.py
  2. +1 −1 lib/data.py
  3. +2 −2 lib/hb_relay.py
  4. +128 −125 lib/node.py
  5. +6 −1 lib/nodemgr_parser.py
  6. +812 −275 lib/osvcd_lsnr.py
  7. +2 −2 lib/osvcd_mon.py
  8. +2 −0 lib/rcGlobalEnv.py
  9. +92 −107 lib/svc.py
  10. +19 −14 lib/svcmon.py

Large diffs are not rendered by default.

@@ -36,7 +36,7 @@ def remote_add_key(self, key, data):
"data": data,
}
}
result = self.daemon_send(req, timeout=5)
result = self.daemon_get(req, timeout=5)
status, error, info = self.parse_result(result)
if info:
print(info)
@@ -114,7 +114,7 @@ def send(self, message):
"msg": message,
},
}
resp = self.daemon_send(request, cluster_name="join", nodename=self.relay, secret=self.secret)
resp = self.daemon_get(request, cluster_name="join", server="raw://"+self.relay, secret=self.secret)
if resp is None:
raise ex.excError("not responding")
if resp.get("status", 1) != 0:
@@ -192,7 +192,7 @@ def receive(self, nodename):
"cluster_id": self.cluster_id,
},
}
resp = self.daemon_send(request, cluster_name="join", nodename=self.relay, secret=self.secret)
resp = self.daemon_get(request, cluster_name="join", server="raw://"+self.relay, secret=self.secret)
if resp is None:
raise ex.excError("no response reading relay slot %s" % nodename)
if resp.get("status", 1) != 0:

0 comments on commit cb1337e

Please sign in to comment.
You can’t perform that action at this time.