Fix pr review nits

This commit is contained in:
Daniel A. Wozniak 2023-07-25 12:18:07 -07:00 committed by Gareth J. Greenaway
parent d23f40cce9
commit a04fe85ffa
5 changed files with 41 additions and 23 deletions

View file

@ -645,7 +645,7 @@ class AsyncPushChannel:
# FIXME for now, just UXD
# Obviously, this makes the factory approach pointless, but we'll extend later
salt.utils.versions.warn_until(
3008,
3009,
"AsyncPushChannel is deprecated. Use zeromq or tcp transport instead.",
)
import salt.transport.ipc
@ -664,7 +664,7 @@ class AsyncPullChannel:
If we have additional IPC transports other than UXD and TCP, add them here
"""
salt.utils.versions.warn_until(
3008,
3009,
"AsyncPullChannel is deprecated. Use zeromq or tcp transport instead.",
)
import salt.transport.ipc

View file

@ -26,7 +26,7 @@ log = logging.getLogger(__name__)
warn_until(
3008,
3009,
"This module is deprecated. Use zeromq or tcp transport instead.",
)

View file

@ -739,7 +739,7 @@ class MessageClient:
source_port=None,
):
salt.utils.versions.warn_until(
3008,
3009,
"MessageClient has been deprecated and will be removed.",
)
self.opts = opts
@ -1351,15 +1351,24 @@ class TCPPublishServer(salt.transport.base.DaemonizedPublishServer):
"close",
]
def __init__(self, opts, **kwargs):
def __init__(
self,
opts,
pub_host=None,
pub_port=None,
pub_path=None,
pull_host=None,
pull_port=None,
pull_path=None,
):
self.opts = opts
self.pub_sock = None
self.pub_host = kwargs.get("pub_host", None)
self.pub_port = kwargs.get("pub_port", None)
self.pub_path = kwargs.get("pub_path", None)
self.pull_host = kwargs.get("pull_host", None)
self.pull_port = kwargs.get("pull_port", None)
self.pull_path = kwargs.get("pull_path", None)
self.pub_host = pub_host
self.pub_port = pub_port
self.pub_path = pub_path
self.pull_host = pull_host
self.pull_port = pull_port
self.pull_path = pull_path
@property
def topic_support(self):

View file

@ -620,7 +620,7 @@ class AsyncReqMessageClient:
:param IOLoop io_loop: A Tornado IOLoop event scheduler [tornado.ioloop.IOLoop]
"""
salt.utils.versions.warn_until(
3008,
3009,
"AsyncReqMessageClient has been deprecated and will be removed.",
)
self.opts = opts
@ -812,24 +812,31 @@ class PublishServer(salt.transport.base.DaemonizedPublishServer):
"close",
]
def __init__(self, opts, **kwargs):
def __init__(
self,
opts,
pub_host=None,
pub_port=None,
pub_path=None,
pull_host=None,
pull_port=None,
pull_path=None,
):
self.opts = opts
pub_host = kwargs.get("pub_host", None)
pub_port = kwargs.get("pub_port", None)
pub_path = kwargs.get("pub_path", None)
self.pub_host = pub_host
self.pub_port = pub_port
self.pub_path = pub_path
if pub_path:
self.pub_uri = f"ipc://{pub_path}"
else:
self.pub_uri = f"tcp://{pub_host}:{pub_port}"
pull_host = kwargs.get("pull_host", None)
pull_port = kwargs.get("pull_port", None)
pull_path = kwargs.get("pull_path", None)
self.pull_host = pull_host
self.pull_port = pull_port
self.pull_path = pull_path
if pull_path:
self.pull_uri = f"ipc://{pull_path}"
else:
self.pull_uri = f"tcp://{pull_host}:{pull_port}"
self.ctx = None
self.sock = None
self.daemon_context = None
@ -890,7 +897,7 @@ class PublishServer(salt.transport.base.DaemonizedPublishServer):
log.info("Starting the Salt Publisher on %s", self.pub_uri)
pub_sock.bind(self.pub_uri)
if "ipc://" in self.pub_uri:
pub_path = self.pub_uri.replace("ipc:", "")
pub_path = self.pub_uri.replace("ipc:/", "")
os.chmod( # nosec
pub_path,
0o600,
@ -898,7 +905,7 @@ class PublishServer(salt.transport.base.DaemonizedPublishServer):
log.info("Starting the Salt Puller on %s", self.pull_uri)
pull_sock.bind(self.pull_uri)
if "ipc://" in self.pull_uri:
pull_path = self.pull_uri.replace("ipc:", "")
pull_path = self.pull_uri.replace("ipc:/", "")
os.chmod( # nosec
pull_path,
0o600,

View file

@ -61,6 +61,7 @@ def master_config(sock_dir):
yield conf
@pytest.mark.skip_on_windows(reason="Unix socket not available on win32")
def test_master_ipc_server_unix(master_config, sock_dir):
assert master_config.get("ipc_mode") != "tcp"
server = salt.transport.ipc_publish_server("master", master_config)
@ -68,6 +69,7 @@ def test_master_ipc_server_unix(master_config, sock_dir):
assert server.pull_path == str(sock_dir / "master_event_pull.ipc")
@pytest.mark.skip_on_windows(reason="Unix socket not available on win32")
def test_minion_ipc_server_unix(minion_config, sock_dir):
minion_config["id"] = "foo"
id_hash = hashlib.sha256(