Skip to content

Commit

Permalink
Enable topics for tcp transport
Browse files Browse the repository at this point in the history
  • Loading branch information
dwoz committed Dec 14, 2021
1 parent f856b5f commit fae15bf
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
18 changes: 18 additions & 0 deletions salt/channel/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -794,9 +794,11 @@ def wrap_payload(self, load):
log.debug("Signing data packet")
payload["sig"] = salt.crypt.sign_message(master_pem_path, payload["load"])
int_payload = {"payload": salt.payload.dumps(payload)}

# add some targeting stuff for lists only (for now)
if load["tgt_type"] == "list":
int_payload["topic_lst"] = load["tgt"]

# If topics are upported, target matching has to happen master side
match_targets = ["pcre", "glob", "list"]
if self.transport.topic_support and load["tgt_type"] in match_targets:
Expand All @@ -811,6 +813,22 @@ def wrap_payload(self, load):
int_payload["topic_lst"] = match_ids
else:
int_payload["topic_lst"] = load["tgt"]

## From TCP transport
# if load["tgt_type"] == "list" and not self.opts.get("order_masters", False):
# if isinstance(load["tgt"], str):
# # Fetch a list of minions that match
# _res = self.ckminions.check_minions(
# load["tgt"], tgt_type=load["tgt_type"]
# )
# match_ids = _res["minions"]

# log.debug("Publish Side Match: %s", match_ids)
# # Send list of miions thru so zmq can target them
# int_payload["topic_lst"] = match_ids
# else:
# int_payload["topic_lst"] = load["tgt"]

return int_payload

def publish(self, load):
Expand Down
2 changes: 1 addition & 1 deletion salt/transport/tcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1309,7 +1309,7 @@ def publish_payload(self, package, topic_list=None):
log.error("TCP PubServer sending payload: %s \n\n %r", package, topic_list)
payload = salt.transport.frame.frame_msg(package)
to_remove = []
if topic_list and False:
if topic_list:
for topic in topic_list:
sent = False
for client in list(self.clients):
Expand Down
6 changes: 0 additions & 6 deletions tests/unit/utils/test_thin.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,8 +470,6 @@ def test_get_tops(self):
]
if salt.utils.thin.has_immutables:
base_tops.extend(["immutables"])
if thin.crypt:
base_tops.append(thin.crypt.__name__)
tops = []
for top in thin.get_tops(extra_mods="foo,bar"):
if top.find("/") != -1:
Expand Down Expand Up @@ -569,8 +567,6 @@ def test_get_tops_extra_mods(self):
]
if salt.utils.thin.has_immutables:
base_tops.extend(["immutables"])
if thin.crypt:
base_tops.append(thin.crypt.__name__)
libs = salt.utils.thin.find_site_modules("contextvars")
foo = {"__file__": os.sep + os.path.join("custom", "foo", "__init__.py")}
bar = {"__file__": os.sep + os.path.join("custom", "bar")}
Expand Down Expand Up @@ -676,8 +672,6 @@ def test_get_tops_so_mods(self):
]
if salt.utils.thin.has_immutables:
base_tops.extend(["immutables"])
if thin.crypt:
base_tops.append(thin.crypt.__name__)
libs = salt.utils.thin.find_site_modules("contextvars")
with patch("salt.utils.thin.find_site_modules", MagicMock(side_effect=[libs])):
with patch(
Expand Down

0 comments on commit fae15bf

Please sign in to comment.