Skip to content

Commit

Permalink
Fix the h2 request multiplexing for list of nodes
Browse files Browse the repository at this point in the history
Hyper splits the "o-node: n1,n2" header because of the comma.

Use HeaderMap client-side to be more explicit about this happening.
And server-side to rebuild the original selector.

The issue was detected on a "om <path> clear".
  • Loading branch information
cvaroqui committed Jul 16, 2019
1 parent 944f2ce commit 5c535f3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
15 changes: 10 additions & 5 deletions lib/comm.py
Expand Up @@ -20,6 +20,7 @@ class DummyException(Exception):
import ssl
import h2.connection
import hyper
from hyper.common.headers import HTTPHeaderMap
SSLWantReadError = ssl.SSLWantReadError
SSLError = ssl.SSLError
has_ssl = True
Expand Down Expand Up @@ -705,7 +706,7 @@ def h2_daemon_get(self, data, server=None, node=None, with_result=True, silent=F
path = self.h2_path_from_data(data)
headers = self.h2_headers(node=node, secret=secret, af=sp.af)
body = self.h2_body_from_data(data)
headers["Content-Length"] = str(len(body))
headers.update({"Content-Length": str(len(body))})
conn = self.h2c(sp=sp)
method = "GET"
try:
Expand Down Expand Up @@ -816,11 +817,15 @@ def h2_path_from_data(data):
return "/"+data.get("action", "")

def h2_headers(self, node=None, secret=None, af=None):
headers = {}
headers = HTTPHeaderMap()
if node:
headers[Headers.node] = node
if isinstance(node, (tuple, list, set)):
for n in node:
headers.update({Headers.node: n})
else:
headers.update({Headers.node: node})
if secret and af != socket.AF_UNIX:
headers[Headers.secret] = secret
headers.update({Headers.secret: secret})
return headers

@staticmethod
Expand Down Expand Up @@ -862,7 +867,7 @@ def h2_daemon_stream_conn(self, data, server=None, node=None, cluster_name=None,
path = self.h2_path_from_data(data)
headers = self.h2_headers(node=node, secret=secret, af=sp.af)
body = self.h2_body_from_data(data)
headers["Content-Length"] = str(len(body))
headers.update({"Content-Length": str(len(body))})
conn = self.h2c(sp=sp, enable_push=True)
stream_id = conn.request("GET", path, headers=headers, body=body)
#data = resp.read()
Expand Down
14 changes: 13 additions & 1 deletion lib/osvcd_mon.py
Expand Up @@ -2550,6 +2550,18 @@ def get_agg_aborted(self, path):
return False
return True

def get_agg_conf(self, path):
data = Storage()
for inst in self.get_service_instances(path).values():
scale = inst.get("scale")
if scale is not None:
data.scale = scale
scaler_slave = inst.get("scaler_slave")
if scaler_slave:
data.scaler_slave = True
break
return data

def get_agg_deleted(self, path):
if len([True for inst in self.get_service_instances(path).values() if "updated" in inst]) > 0:
return False
Expand Down Expand Up @@ -3414,7 +3426,7 @@ def instance_unprovisioned(self, instance):
return not instance.get("provisioned", False)

def get_agg(self, path):
data = Storage()
data = self.get_agg_conf(path)
data.avail = self.get_agg_avail(path)
data.frozen = self.get_agg_frozen(path)
data.overall = self.get_agg_overall(path)
Expand Down

0 comments on commit 5c535f3

Please sign in to comment.