From Yaniv Bronhaim <ybronhei(a)redhat.com>:
Yaniv Bronhaim has uploaded a new change for review.
Change subject: Adding abrt dependency and introduce configurator for it
......................................................................
Adding abrt dependency and introduce configurator for it
- Adding spec requirement for abrt addons to replace current coredump
kernel reports (see RFE for more info)
- Adding abrt conf files
- Removing logrotate config for coredump folder - assuming that abrt
takes care for not flooding in reports (need to be verified)
- Adding tests
Change-Id: I1ca5e66c9f029be75483b86414e328d074c7e454
Bug-Url:
https://bugzilla.redhat.com/show_bug.cgi?id=917062
Signed-off-by: Yeela Kaplan <ykaplan(a)redhat.com>
Signed-off-by: Yaniv Bronhaim <ybronhei(a)redhat.com>
---
M init/systemd/85-vdsmd.preset
M init/vdsmd_init_common.sh.in
M lib/vdsm/tool/configurators/Makefile.am
A lib/vdsm/tool/configurators/abrt.py
M static/usr/lib/systemd/system/vdsmd.service.in
M tests/Makefile.am
M tests/toolTests.py
A tests/toolTests_CCPP.conf
A tests/toolTests_abrt-action-save-package-data.conf
A tests/toolTests_abrt.conf
A tests/toolTests_vmcore.conf
M vdsm.spec.in
M vdsm/vdsm-logrotate
13 files changed, 268 insertions(+), 64 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/60/75660/1
diff --git a/init/systemd/85-vdsmd.preset b/init/systemd/85-vdsmd.preset
index 6da4332c..482d0ea 100644
--- a/init/systemd/85-vdsmd.preset
+++ b/init/systemd/85-vdsmd.preset
@@ -6,6 +6,8 @@
enable vdsm-network.service
enable vdsm-network-init.service
enable mom-vdsm.service
+enable abrt-vmcore
+enable kdump
disable ksmtuned.service
diff --git a/init/vdsmd_init_common.sh.in b/init/vdsmd_init_common.sh.in
index c935cb9..f00666b 100755
--- a/init/vdsmd_init_common.sh.in
+++ b/init/vdsmd_init_common.sh.in
@@ -1,5 +1,6 @@
#!/bin/sh
# Copyright 2013 IBM, Inc.
+# Copyright 2017 Redhat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -35,13 +36,7 @@
}
task_configure_coredump() {
- local conf_file="@CONFDIR(a)/vdsm.conf"
- local getconfitem="@VDSMDIR@/get-conf-item"
-
- if "${getconfitem}" "${conf_file}" vars core_dump_enable false |
- tr A-Z a-z | grep -q true; then
- echo "/var/log/core/core.%p.%t.dump" >
/proc/sys/kernel/core_pattern
- fi
+ echo "|/usr/libexec/abrt-hook-ccpp %s %c %p %u %g %t %e %i" >
/proc/sys/kernel/core_pattern
}
task_configure_vdsm_logs() {
diff --git a/lib/vdsm/tool/configurators/Makefile.am
b/lib/vdsm/tool/configurators/Makefile.am
index ad23bac..0d2be52 100644
--- a/lib/vdsm/tool/configurators/Makefile.am
+++ b/lib/vdsm/tool/configurators/Makefile.am
@@ -1,5 +1,5 @@
#
-# Copyright 2014 Red Hat, Inc.
+# Copyright 2014-2017 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -21,6 +21,7 @@
dist_configurators_PYTHON = \
__init__.py \
+ abrt.py \
certificates.py \
libvirt.py \
multipath.py \
diff --git a/lib/vdsm/tool/configurators/abrt.py b/lib/vdsm/tool/configurators/abrt.py
new file mode 100644
index 0000000..f843b16
--- /dev/null
+++ b/lib/vdsm/tool/configurators/abrt.py
@@ -0,0 +1,128 @@
+# Copyright 2017 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
+from __future__ import absolute_import
+import sys
+import os
+
+from . import MAYBE, NO
+from vdsm.tool import confutils
+from vdsm import constants
+
+CONF_VERSION = '4.20.0'
+
+
+def configure():
+ confutils.remove_conf(FILES, CONF_VERSION)
+ for conf_file, content in FILES.items():
+ content['configure'](content, CONF_VERSION)
+
+
+def isconfigured():
+ """
+ Check if abrt is already configured for vdsm
+ """
+ ret = MAYBE
+
+ for path in (confutils.get_persisted_files(FILES)):
+ if not confutils.open_config(path, CONF_VERSION).hasConf():
+ ret = NO
+
+ if ret == MAYBE:
+ sys.stdout.write("abrt is already configured for vdsm\n")
+ else:
+ sys.stdout.write("abrt is not configured for vdsm\n")
+ return ret
+
+
+FILES = {
+ 'ABRT_CONF': {
+ 'path': os.path.join(
+ constants.SYSCONF_PATH,
+ 'abrt/abrt.conf'
+ ),
+ 'configure': confutils.add_section,
+ 'removeConf': confutils.remove_section,
+ 'persisted': True,
+ 'fragments': [
+ {
+ 'conditions': {},
+ 'content': {
+ 'DumpLocation': '/var/tmp/abrt',
+ 'AutoreportingEvent': 'report_uReport',
+ 'MaxCrashReportsSize': '1000',
+ 'AutoreportingEnabled': 'yes'
+ },
+ },
+ ]
+ },
+ 'CCPP_CONF': {
+ 'path': os.path.join(
+ constants.SYSCONF_PATH,
+ 'abrt/plugins/CCpp.conf'
+ ),
+ 'configure': confutils.add_section,
+ 'removeConf': confutils.remove_section,
+ 'persisted': True,
+ 'fragments': [
+ {
+ 'conditions': {},
+ 'content': {
+ 'MakeCompatCore': 'no',
+ 'SaveBinaryImage': 'no',
+ 'CreateCoreBacktrace': 'yes',
+ 'SaveFullCore': 'no',
+ },
+ },
+ ]
+ },
+ 'VMCORE_CONF': {
+ 'path': os.path.join(
+ constants.SYSCONF_PATH,
+ 'abrt/plugins/vmcore.conf'
+ ),
+ 'configure': confutils.add_section,
+ 'removeConf': confutils.remove_section,
+ 'persisted': True,
+ 'fragments': [
+ {
+ 'conditions': {},
+ 'content': {
+ 'CopyVMcore': 'no',
+ },
+ },
+ ]
+ },
+ 'PKG_CONF': {
+ 'path': os.path.join(
+ constants.SYSCONF_PATH,
+ 'abrt/abrt-action-save-package-data.conf'
+ ),
+ 'configure': confutils.add_section,
+ 'removeConf': confutils.remove_section,
+ 'persisted': True,
+ 'fragments': [
+ {
+ 'conditions': {},
+ 'content': {
+ 'OpenGPGCheck': 'no'
+ },
+ },
+ ]
+ }
+}
diff --git a/static/usr/lib/systemd/system/vdsmd.service.in
b/static/usr/lib/systemd/system/vdsmd.service.in
index 659f8ce..828d9ce 100644
--- a/static/usr/lib/systemd/system/vdsmd.service.in
+++ b/static/usr/lib/systemd/system/vdsmd.service.in
@@ -6,7 +6,7 @@
After=multipathd.service libvirtd.service iscsid.service rpcbind.service \
supervdsmd.service sanlock.service vdsm-network.service
Conflicts=libvirt-guests.service
-Wants=mom-vdsm.service ovirt-imageio-daemon.service
+Wants=mom-vdsm.service ovirt-imageio-daemon.service abrtd.service
[Service]
Type=simple
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 1970b7b..00c31c2 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -329,6 +329,9 @@
lvs_3386c6f2-926f-42c4-839c-38287fac8998.out \
lvs_f9e55e18-67c4-4377-8e39-5833ca422bef.out \
mem_info.out \
+ toolTests_abrt-action-save-package-data.conf \
+ toolTests_abrt.conf \
+ toolTests_CCPP.conf \
toolTests_empty.conf \
toolTests_lconf_ssl.conf \
toolTests_libvirtd.conf \
@@ -336,6 +339,7 @@
toolTests_qemu_ssl.conf \
toolTests_vdsm_no_ssl.conf \
toolTests_vdsm_ssl.conf \
+ toolTests_vmcore.conf \
$(NULL)
dist_vdsmtests_PYTHON = \
diff --git a/tests/toolTests.py b/tests/toolTests.py
index 0f065db..ff722f1 100644
--- a/tests/toolTests.py
+++ b/tests/toolTests.py
@@ -20,6 +20,7 @@
from vdsm.tool import configurator
from vdsm.tool.configurators import YES, NO, MAYBE, InvalidConfig, InvalidRun
from vdsm.tool.configfile import ConfigFile, ParserWrapper
+from vdsm.tool.configurators import abrt
from vdsm.tool.configurators import libvirt
from vdsm.tool import UsageError
from vdsm.tool import upgrade
@@ -36,7 +37,20 @@
dirName = os.path.dirname(os.path.realpath(__file__))
-FakeFiles = libvirt.FILES
+FakeLibvirtFiles = libvirt.FILES
+FakeAbrtFiles = abrt.FILES
+
+
+# helpers
+def _setConfig(obj, *configurations):
+ for file_, type_ in configurations:
+ with open(os.path.join(dirName,
+ 'toolTests_%s.conf' % type_)) as template:
+ data = template.read()
+ data = data % {
+ 'LATEST_CONF_VERSION': libvirt.CONF_VERSION}
+ with open(obj.test_env[file_], 'w') as testConf:
+ testConf.write(data)
class MockModuleConfigurator(object):
@@ -293,6 +307,68 @@
"remove-config")
+class AbrtModuleConfigureTests(TestCase):
+ srcPath = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
+ test_env = {}
+
+ def setUp(self):
+ self._test_dir = tempfile.mkdtemp()
+ self.test_env['ABRT_CONF'] = self._test_dir + '/abrt.conf'
+ self.test_env['CCPP_CONF'] = self._test_dir + '/CCPP.conf'
+ self.test_env['VMCORE_CONF'] = self._test_dir + '/vmcore.conf'
+ self.test_env['PKG_CONF'] = self._test_dir + \
+ '/abrt-action-save-package-data.conf'
+
+ for key, val in self.test_env.items():
+ FakeAbrtFiles[key]['path'] = val
+
+ self.patch = monkeypatch.Patch([
+ (
+ abrt,
+ 'FILES',
+ FakeAbrtFiles
+ )
+ ])
+
+ self.patch.apply()
+
+ def tearDown(self):
+ self.patch.revert()
+ utils.rmTree(self._test_dir)
+
+ def testIsConfiguredNegative(self):
+ _setConfig(self,
+ ('ABRT_CONF', 'abrt'),
+ ('CCPP_CONF', 'CCPP'),
+ ('VMCORE_CONF', 'empty'),
+ ('PKG_CONF', 'abrt-action-save-package-data'),
+ )
+ self.assertEqual(
+ abrt.isconfigured(),
+ NO
+ )
+
+ def testAbrtConfigure(self):
+ _setConfig(self,
+ ('ABRT_CONF', 'empty'),
+ ('CCPP_CONF', 'empty'),
+ ('VMCORE_CONF', 'empty'),
+ ('PKG_CONF', 'empty'),
+ )
+
+ self.assertEqual(
+ abrt.isconfigured(),
+ NO
+ )
+
+ abrt.configure()
+
+ self.assertEqual(
+ abrt.isconfigured(),
+ MAYBE
+ )
+
+
class LibvirtModuleConfigureTests(TestCase):
test_env = {}
@@ -311,12 +387,12 @@
for key, val in self.test_env.items():
if not key == 'VDSM_CONF':
- FakeFiles[key]['path'] = val
+ FakeLibvirtFiles[key]['path'] = val
- self._setConfig(
- ('QLCONF', 'libvirtd'),
- ('LDCONF', 'qemu_sanlock'),
- )
+ _setConfig(self,
+ ('QLCONF', 'libvirtd'),
+ ('LDCONF', 'qemu_sanlock'),
+ )
self.vdsm_cfg = make_config(())
self.patch = monkeypatch.Patch([
@@ -333,7 +409,7 @@
(
libvirt,
'FILES',
- FakeFiles
+ FakeLibvirtFiles
)
])
@@ -343,51 +419,39 @@
self.patch.revert()
utils.rmTree(self._test_dir)
- # helpers
- def _setConfig(self, *configurations):
- for file_, type_ in configurations:
- with open(os.path.join(dirName,
- 'toolTests_%s.conf' % type_)) as template:
- data = template.read()
- data = data % {
- 'LATEST_CONF_VERSION': libvirt.CONF_VERSION}
- with open(self.test_env[file_], 'w') as testConf:
- testConf.write(data)
-
def testValidatePositive(self):
self.vdsm_cfg.set('vars', 'ssl', 'true')
- self._setConfig(
- ('LCONF', 'lconf_ssl'),
- ('QCONF', 'qemu_ssl'),
- )
+ _setConfig(self,
+ ('LCONF', 'lconf_ssl'),
+ ('QCONF', 'qemu_ssl'),
+ )
self.assertTrue(libvirt.validate())
def testValidateNegative(self):
self.vdsm_cfg.set('vars', 'ssl', 'false')
- self._setConfig(
- ('LCONF', 'lconf_ssl'),
- ('QCONF', 'qemu_ssl'),
- )
+ _setConfig(self,
+ ('LCONF', 'lconf_ssl'),
+ ('QCONF', 'qemu_ssl'),
+ )
self.assertFalse(libvirt.validate())
def testIsConfiguredPositive(self):
- self._setConfig(
- ('LCONF', 'lconf_ssl'),
- ('QCONF', 'qemu_ssl'),
-
- )
+ _setConfig(self,
+ ('LCONF', 'lconf_ssl'),
+ ('QCONF', 'qemu_ssl'),
+ )
self.assertEqual(
libvirt.isconfigured(),
MAYBE
)
def testIsConfiguredNegative(self):
- self._setConfig(
- ('LCONF', 'lconf_ssl'),
- ('QCONF', 'empty'),
- )
+ _setConfig(self,
+ ('LCONF', 'lconf_ssl'),
+ ('QCONF', 'empty'),
+ )
self.assertEqual(
libvirt.isconfigured(),
NO
@@ -395,10 +459,10 @@
def testLibvirtConfigureToSSLTrue(self):
self.vdsm_cfg.set('vars', 'ssl', 'true')
- self._setConfig(
- ('LCONF', 'empty'),
- ('QCONF', 'empty'),
- )
+ _setConfig(self,
+ ('LCONF', 'empty'),
+ ('QCONF', 'empty'),
+ )
self.assertEqual(
libvirt.isconfigured(),
diff --git a/tests/toolTests_CCPP.conf b/tests/toolTests_CCPP.conf
new file mode 100644
index 0000000..f0233e9
--- /dev/null
+++ b/tests/toolTests_CCPP.conf
@@ -0,0 +1,6 @@
+## beginning of configuration section by vdsm-%(LATEST_CONF_VERSION)s
+MakeCompatCore=no
+SaveBinaryImage=no
+CreateCoreBacktrace=yes
+SaveFullCore=no
+## end of configuration section by vdsm-%(LATEST_CONF_VERSION)s
diff --git a/tests/toolTests_abrt-action-save-package-data.conf
b/tests/toolTests_abrt-action-save-package-data.conf
new file mode 100644
index 0000000..a75d738
--- /dev/null
+++ b/tests/toolTests_abrt-action-save-package-data.conf
@@ -0,0 +1,3 @@
+## beginning of configuration section by vdsm-%(LATEST_CONF_VERSION)s
+OpenGPGCheck=no
+## end of configuration section by vdsm-%(LATEST_CONF_VERSION)s
diff --git a/tests/toolTests_abrt.conf b/tests/toolTests_abrt.conf
new file mode 100644
index 0000000..17e5c4b
--- /dev/null
+++ b/tests/toolTests_abrt.conf
@@ -0,0 +1,6 @@
+## beginning of configuration section by vdsm-%(LATEST_CONF_VERSION)s
+DumpLocation=/var/tmp/abrt
+AutoreportingEvent=report_uReport
+MaxCrashReportsSize=1000
+AutoreportingEnabled=yes
+## end of configuration section by vdsm-%(LATEST_CONF_VERSION)s
diff --git a/tests/toolTests_vmcore.conf b/tests/toolTests_vmcore.conf
new file mode 100644
index 0000000..1177d02
--- /dev/null
+++ b/tests/toolTests_vmcore.conf
@@ -0,0 +1,3 @@
+## beginning of configuration section by vdsm-%(LATEST_CONF_VERSION)s
+CopyVMcore=no
+## end of configuration section by vdsm-%(LATEST_CONF_VERSION)s
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 2cd7c92..e27945d 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -109,6 +109,9 @@
Requires: nfs-utils
Requires: m2crypto
Requires: libnl3
+Requires: abrt-addon-vmcore
+Requires: abrt-addon-ccpp
+Requires: abrt-addon-python
Requires: curl
Requires: %{name}-xmlrpc = %{version}-%{release}
Requires: %{name}-jsonrpc = %{version}-%{release}
@@ -804,13 +807,6 @@
/etc/sysctl.conf
fi
-# hack until we replace core dump with abrt
-if /usr/sbin/selinuxenabled; then
- /usr/sbin/semanage fcontext -a -t virt_cache_t '/var/log/core(/.*)?'
-fi
-/sbin/restorecon -R /var/log/core >/dev/null 2>&1
-# hack until we replace core dump with abrt
-
# VDSM installs vdsm-modules-load.d.conf file - the following command will
# refresh vdsm kernel modules requirements to start on boot
/bin/systemctl restart systemd-modules-load.service >/dev/null 2>&1 || :
@@ -1282,6 +1278,7 @@
%{python_sitelib}/%{vdsm_name}/tool/nwfilter.py*
%{python_sitelib}/%{vdsm_name}/tool/configurator.py*
%{python_sitelib}/%{vdsm_name}/tool/configurators/__init__*
+%{python_sitelib}/%{vdsm_name}/tool/configurators/abrt.py*
%{python_sitelib}/%{vdsm_name}/tool/configurators/certificates.py*
%{python_sitelib}/%{vdsm_name}/tool/configurators/libvirt.py*
%{python_sitelib}/%{vdsm_name}/tool/configurators/lvm.py*
@@ -1373,6 +1370,10 @@
%{_datadir}/%{vdsm_name}/tests/network/netmaskconversions
%{_datadir}/%{vdsm_name}/tests/network/tc_filter_show.out
%{_datadir}/%{vdsm_name}/tests/run_tests.sh
+%{_datadir}/%{vdsm_name}/tests/toolTests_abrt-action-save-package-data.conf
+%{_datadir}/%{vdsm_name}/tests/toolTests_abrt.conf
+%{_datadir}/%{vdsm_name}/tests/toolTests_CCPP.conf
+%{_datadir}/%{vdsm_name}/tests/toolTests_vmcore.conf
%{_datadir}/%{vdsm_name}/tests/toolTests_empty.conf
%{_datadir}/%{vdsm_name}/tests/toolTests_lconf_ssl.conf
%{_datadir}/%{vdsm_name}/tests/toolTests_libvirtd.conf
diff --git a/vdsm/vdsm-logrotate b/vdsm/vdsm-logrotate
index 120c18c..aa391cc 100755
--- a/vdsm/vdsm-logrotate
+++ b/vdsm/vdsm-logrotate
@@ -17,15 +17,6 @@
errors=$((errors+1))
fi
-if [ -d /var/log/core ] ; then
- /usr/bin/find /var/log/core -type f -name '*xz' -mtime +7 -exec /bin/rm -f
'{}' \;
- EXITVALUE=$?
- if [ $EXITVALUE != 0 ]; then
- /usr/bin/logger -t vdsm-logrotate "ALERT clean old core files exited
abnormally with [$EXITVALUE]"
- errors=$((errors+1))
- fi
-fi
-
if [ -d /var/log/vdsm/import ] ; then
/usr/bin/find /var/log/vdsm/import -type f -mtime +30 -exec /bin/rm -f '{}'
\;
EXITVALUE=$?
--
To view, visit
https://gerrit.ovirt.org/75660
To unsubscribe, visit
https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1ca5e66c9f029be75483b86414e328d074c7e454
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-4.1
Gerrit-Owner: Yaniv Bronhaim <ybronhei(a)redhat.com>