summaryrefslogtreecommitdiff
path: root/sysutils/salt
diff options
context:
space:
mode:
authorkhorben <khorben>2016-02-16 01:52:34 +0000
committerkhorben <khorben>2016-02-16 01:52:34 +0000
commit37564ef631758ee2efe6a7f8e0904f68564ff030 (patch)
tree5d5f776c97eb01e0c0856460158f7d39b1f5f3a1 /sysutils/salt
parent83a1e16200ee708fe6d08ce8671d86a92fd02956 (diff)
downloadpkgsrc-37564ef631758ee2efe6a7f8e0904f68564ff030.tar.gz
Avoid a crash on NetBSD when not every minion is present
From the pull request pending, #31320: On NetBSD, Salt currently defaults to using lsof(8) to determine which minions are connected. It is however not always available, and even then quite unreliable. I found that just like on FreeBSD, sockstat(1) is a much safer alternative. Unfortunately its output is not exactly the same on NetBSD, where the port delimiter is a dot character instead. As a consequence I have decided to duplicate the relevant function for NetBSD; let me know if I should try to re-use the code supporting FreeBSD instead. See also https://github.com/saltstack/salt/pull/31230.
Diffstat (limited to 'sysutils/salt')
-rw-r--r--sysutils/salt/Makefile4
-rw-r--r--sysutils/salt/distinfo6
-rw-r--r--sysutils/salt/patches/patch-salt_modules_status.py6
-rw-r--r--sysutils/salt/patches/patch-salt_utils_____init____.py21
-rw-r--r--sysutils/salt/patches/patch-salt_utils_network.py90
5 files changed, 120 insertions, 7 deletions
diff --git a/sysutils/salt/Makefile b/sysutils/salt/Makefile
index ab5b88a7ad8..63045f1f89d 100644
--- a/sysutils/salt/Makefile
+++ b/sysutils/salt/Makefile
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.37 2016/02/16 00:00:08 khorben Exp $
+# $NetBSD: Makefile,v 1.38 2016/02/16 01:52:34 khorben Exp $
DISTNAME= salt-2015.8.5
-PKGREVISION= 2
+PKGREVISION= 3
CATEGORIES= sysutils
MASTER_SITES= ${MASTER_SITE_PYPI:=s/salt/}
diff --git a/sysutils/salt/distinfo b/sysutils/salt/distinfo
index 271e211e874..c2248f5d2d2 100644
--- a/sysutils/salt/distinfo
+++ b/sysutils/salt/distinfo
@@ -1,8 +1,10 @@
-$NetBSD: distinfo,v 1.19 2016/02/09 14:23:04 wiz Exp $
+$NetBSD: distinfo,v 1.20 2016/02/16 01:52:34 khorben Exp $
SHA1 (salt-2015.8.5.tar.gz) = f9d2b2dbb0fefc8d9b0b5a762f61f0f1d8998c47
RMD160 (salt-2015.8.5.tar.gz) = 8b17e20f53ff201f135f0bfefeca937828289a01
SHA512 (salt-2015.8.5.tar.gz) = 715709798fd1f4410ef204545a84e34d3ecc0f080905b7ae29ce19d273c1ed6865f56e025e59d2506301970ad05081ff119caec0ced03dcbe5803f9f00eb64f8
Size (salt-2015.8.5.tar.gz) = 6877624 bytes
SHA1 (patch-salt_modules_cron.py) = 2b459a3db4f5370d56b59842b903ef0ebde04c5d
-SHA1 (patch-salt_modules_status.py) = 5253782b046c2f7b809682f52ce4d04dab1c81ac
+SHA1 (patch-salt_modules_status.py) = f444cce79e2b0edd79066d7c78e807556d191f98
+SHA1 (patch-salt_utils_____init____.py) = 61f11da63f26af69334f3eca957d596486396ab0
+SHA1 (patch-salt_utils_network.py) = 8bc298dc2715648e874b94f86f7488e97aff4663
diff --git a/sysutils/salt/patches/patch-salt_modules_status.py b/sysutils/salt/patches/patch-salt_modules_status.py
index 067a07b7bf7..c2a6615a942 100644
--- a/sysutils/salt/patches/patch-salt_modules_status.py
+++ b/sysutils/salt/patches/patch-salt_modules_status.py
@@ -1,10 +1,10 @@
-$NetBSD: patch-salt_modules_status.py,v 1.1 2016/02/04 22:05:36 khorben Exp $
+$NetBSD: patch-salt_modules_status.py,v 1.2 2016/02/16 01:52:34 khorben Exp $
Avoid a crash in "status.diskusage" when not on Linux or FreeBSD
---- salt/modules/status.py.orig 2016-02-04 21:56:06.000000000 +0000
+--- salt/modules/status.py.orig 2016-02-01 19:40:31.000000000 +0000
+++ salt/modules/status.py
-@@ -443,6 +443,8 @@ def diskusage(*args):
+@@ -457,6 +457,8 @@ def diskusage(*args):
ifile = salt.utils.fopen(procf, 'r').readlines()
elif __grains__['kernel'] == 'FreeBSD':
ifile = __salt__['cmd.run']('mount -p').splitlines()
diff --git a/sysutils/salt/patches/patch-salt_utils_____init____.py b/sysutils/salt/patches/patch-salt_utils_____init____.py
new file mode 100644
index 00000000000..b7bb7d2f8cb
--- /dev/null
+++ b/sysutils/salt/patches/patch-salt_utils_____init____.py
@@ -0,0 +1,21 @@
+$NetBSD: patch-salt_utils_____init____.py,v 1.1 2016/02/16 01:52:34 khorben Exp $
+
+Use sockstat(1) on NetBSD
+
+--- salt/utils/__init__.py.orig 2016-02-01 19:40:31.000000000 +0000
++++ salt/utils/__init__.py
+@@ -1664,6 +1664,14 @@ def is_freebsd():
+
+
+ @real_memoize
++def is_netbsd():
++ '''
++ Simple function to return if host is NetBSD or not
++ '''
++ return sys.platform.startswith('netbsd')
++
++
++@real_memoize
+ def is_openbsd():
+ '''
+ Simple function to return if host is OpenBSD or not
diff --git a/sysutils/salt/patches/patch-salt_utils_network.py b/sysutils/salt/patches/patch-salt_utils_network.py
new file mode 100644
index 00000000000..396f15911e4
--- /dev/null
+++ b/sysutils/salt/patches/patch-salt_utils_network.py
@@ -0,0 +1,90 @@
+$NetBSD: patch-salt_utils_network.py,v 1.1 2016/02/16 01:52:34 khorben Exp $
+
+Use sockstat(1) on NetBSD
+
+--- salt/utils/network.py.orig 2016-02-01 19:40:31.000000000 +0000
++++ salt/utils/network.py
+@@ -1180,6 +1180,65 @@ def _freebsd_remotes_on(port, which_end)
+ return remotes
+
+
++def _netbsd_remotes_on(port, which_end):
++ '''
++ Returns set of ipv4 host addresses of remote established connections
++ on local tcp port port.
++
++ Parses output of shell 'sockstat' (FreeBSD)
++ to get connections
++
++ $ sudo sockstat -4
++ USER COMMAND PID FD PROTO LOCAL ADDRESS FOREIGN ADDRESS
++ root python2.7 1456 29 tcp4 *.4505 *.*
++ root python2.7 1445 17 tcp4 *.4506 *.*
++ root python2.7 1294 14 tcp4 127.0.0.1.11813 127.0.0.1.4505
++ root python2.7 1294 41 tcp4 127.0.0.1.61115 127.0.0.1.4506
++
++ $ sudo sockstat -4 -c -p 4506
++ USER COMMAND PID FD PROTO LOCAL ADDRESS FOREIGN ADDRESS
++ root python2.7 1294 41 tcp4 127.0.0.1.61115 127.0.0.1.4506
++ '''
++
++ port = int(port)
++ remotes = set()
++
++ try:
++ cmd = shlex.split('sockstat -4 -c -p {0}'.format(port))
++ data = subprocess.check_output(cmd) # pylint: disable=minimum-python-version
++ except subprocess.CalledProcessError as ex:
++ log.error('Failed "sockstat" with returncode = {0}'.format(ex.returncode))
++ raise
++
++ lines = salt.utils.to_str(data).split('\n')
++
++ for line in lines:
++ chunks = line.split()
++ if not chunks:
++ continue
++ # ['root', 'python2.7', '1456', '37', 'tcp4',
++ # '127.0.0.1.4505-', '127.0.0.1.55703']
++ #print chunks
++ if 'COMMAND' in chunks[1]:
++ continue # ignore header
++ if len(chunks) < 2:
++ continue
++ local = chunks[5].split('.')
++ lport = local.pop()
++ lhost = '.'.join(local)
++ remote = chunks[6].split('.')
++ rport = remote.pop()
++ rhost = '.'.join(remote)
++ if which_end == 'local' and int(lport) != port: # ignore if local port not port
++ continue
++ if which_end == 'remote' and int(rport) != port: # ignore if remote port not port
++ continue
++
++ remotes.add(rhost)
++
++ return remotes
++
++
+ def _openbsd_remotes_on(port, which_end):
+ '''
+ OpenBSD specific helper function.
+@@ -1277,6 +1336,8 @@ def remotes_on_local_tcp_port(port):
+ return _sunos_remotes_on(port, 'local_port')
+ if salt.utils.is_freebsd():
+ return _freebsd_remotes_on(port, 'local_port')
++ if salt.utils.is_netbsd():
++ return _netbsd_remotes_on(port, 'local_port')
+ if salt.utils.is_openbsd():
+ return _openbsd_remotes_on(port, 'local_port')
+ if salt.utils.is_windows():
+@@ -1332,6 +1393,8 @@ def remotes_on_remote_tcp_port(port):
+ return _sunos_remotes_on(port, 'remote_port')
+ if salt.utils.is_freebsd():
+ return _freebsd_remotes_on(port, 'remote_port')
++ if salt.utils.is_netbsd():
++ return _netbsd_remotes_on(port, 'remote_port')
+ if salt.utils.is_openbsd():
+ return _openbsd_remotes_on(port, 'remote_port')
+ if salt.utils.is_windows():