pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

pkg/53278: sysutils/salt 2018.3.0 immediately crashes



>Number:         53278
>Category:       pkg
>Synopsis:       sysutils/salt 2018.3.0 immediately crashes
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri May 11 15:50:00 +0000 2018
>Originator:     Travis Paul
>Release:        current
>Organization:
>Environment:
NetBSD n7.local 7.1.2 NetBSD 7.1.2 (GENERIC.201803151611Z) amd64
>Description:
Salt version 2018.3.0, in pkgsrc current does not work on NetBSD 7.1.2. The salt and salt-master commands crash immediately:

# salt
Traceback (most recent call last):
... [snip] ...
  File "/opt/pkg/lib/python2.7/site-packages/salt/grains/core.py", line 458, in _bsd_memdata
    grains['swap_total'] = int(swap_total) // 1024 // 1024
ValueError: invalid literal for int() with base 10: "sysctl: second level name 'swap_total' in 'vm.swap_total' is invalid"

These commands attempt to get the available swap space but crash due to not having a special case for NetBSD.  They try to get the value of a nonexistent "vm.swap_total" sysctl.

Upstream has fixed this issue by checking for swap in the same way as OpenBSD[1]. However, this does not work if the system has no configured swap space and the commands still crash with:

# salt-master
Traceback (most recent call last):
... [snip] ...
  File "/opt/pkg/lib/python2.7/site-packages/salt/grains/core.py", line 458, in _bsd_memdata
    grains['swap_total'] = int(swap_total) // 1024 // 1024
ValueError: invalid literal for int() with base 10: 'swap'

The attached patch fixes both issues and has been approved upstream [2] but is not yet merged (at the time of writing.)

[1] https://github.com/saltstack/salt/blob/bd184a257f3488175b0626a170e93433ec77e79e/salt/grains/core.py#L460
[2] https://github.com/saltstack/salt/pull/47600
>How-To-Repeat:
Install salt 2018.3.0 from pkgsrc, attempt to run the either salt or salt-master command.
>Fix:
See patches below (created with cvs diff -Nu)
Also uploaded the patch file here: https://gist.github.com/travispaul/cf2f163b3889b3ff63f548ef3bf7c315:

Index: distinfo
===================================================================
RCS file: /cvsroot/pkgsrc/sysutils/salt/distinfo,v
retrieving revision 1.34
diff -u -r1.34 distinfo
--- distinfo    13 Apr 2018 07:58:22 -0000      1.34
+++ distinfo    11 May 2018 15:42:29 -0000
@@ -4,4 +4,5 @@
 RMD160 (salt-2018.3.0.tar.gz) = 54ea78736292c97367c4b34b586bce25b434ecce
 SHA512 (salt-2018.3.0.tar.gz) = 3d64a4d12d4ff7effe644b682b138d8f49fd00523e9cfe3e80bebff9c944a089fb41cbac92e63139633425f49c1eebeb99145290a0bdd1b4f306da86abe9b2e5
 Size (salt-2018.3.0.tar.gz) = 13448567 bytes
+SHA1 (patch-salt_grains_core.py) = 011772f5f82c57833b82f7825b1bac201e42d024
 SHA1 (patch-salt_version.py) = 1827dac3609a938fae38ee5dfd2a873c9723dfbd
Index: patches/patch-salt_grains_core.py
===================================================================
RCS file: patches/patch-salt_grains_core.py
diff -N patches/patch-salt_grains_core.py
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-salt_grains_core.py   11 May 2018 15:42:29 -0000
@@ -0,0 +1,25 @@
+$NetBSD$
+
+Prevent crash on NetBSD and OpenBSD when no swap is configured.
+https://github.com/saltstack/salt/pull/47600
+
+--- salt/grains/core.py.orig   2018-05-11 13:12:38.000000000 +0000
++++ salt/grains/core.py
+@@ -450,11 +450,13 @@ def _bsd_memdata(osdata):
+             mem = __salt__['cmd.run']('{0} -n hw.physmem64'.format(sysctl))
+         grains['mem_total'] = int(mem) // 1024 // 1024
+
+-        if osdata['kernel'] == 'OpenBSD':
++        if osdata['kernel'] in ['OpenBSD', 'NetBSD']:
+             swapctl = salt.utils.path.which('swapctl')
+-            swap_total = __salt__['cmd.run']('{0} -sk'.format(swapctl)).split(' ')[1]
+-        else:
+-            swap_total = __salt__['cmd.run']('{0} -n vm.swap_total'.format(sysctl))
++            swap_data = __salt__['cmd.run']('{0} -sk'.format(swapctl))
++            if swap_data == 'no swap devices configured':
++                swap_total = 0
++            else:
++                swap_total = swap_data.split(' ')[1]
+         grains['swap_total'] = int(swap_total) // 1024 // 1024
+     return grains
+


Home | Main Index | Thread Index | Old Index