Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=05eb87ca2defb6e7…
Commit: 05eb87ca2defb6e7e7bd9759bab566de7cb6e3f0
Parent: ecc040688601ec0f4b35f4250e057db13fd847a0
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Mon Feb 22 16:05:43 2016 -0600
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Mon Feb 22 16:07:54 2016 -0600
lvmdbusd: Initial unit test driver script
It's disabled until we can fix it up.
Signed-off-by: Tony Asleson <tasleson(a)redhat.com>
---
test/api/dbustest.sh | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 60 insertions(+), 0 deletions(-)
diff --git a/test/api/dbustest.sh b/test/api/dbustest.sh
new file mode 100644
index 0000000..f33add0
--- /dev/null
+++ b/test/api/dbustest.sh
@@ -0,0 +1,60 @@
+#!/bin/sh
+# Copyright (C) 2016 Red Hat, Inc. All rights reserved.
+#
+# This file is part of LVM2.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# 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
+
+SKIP_WITH_CLVMD=1
+
+. lib/inittest
+
+# Will default to skip until we can get this reviewed
+skip
+
+aux prepare_pvs 6
+
+# This allows us to run without installing
+# com.redhat.lvmdbus1.conf to /etc/dbus-1/system.d/
+# but in normal operation it needs to be on system bus
+export LVMDBUSD_USE_SESSION="True"
+
+# Setup the python path so we can run
+export PYTHONPATH=$abs_top_builddir/daemons
+
+# Where should we be logging the output of the daemon when not running as
+# a systemd service
+# Start the dbus service
+$abs_top_builddir/daemons/lvmdbusd/lvmdbusd --debug --udev > /tmp/lvmdbusd.log 2>&1 &
+
+# Give the service some time to start before we try to run the
+# unit test
+sleep 1
+
+LVM_DBUS_PID=$(ps aux | grep lvmdbus[d] | awk '{print $2}')
+if [ "CHK${LVM_DBUS_PID}" == "CHK" ];then
+ echo "Failed to start lsmdbusd daemon"
+ exit 1
+fi
+
+# Run all the unit tests
+# Are we already logging stdout & stderror?
+$abs_top_builddir/test/dbus/lvmdbustest.py -v > /tmp/lvmdbustest.log 2>&1
+
+# We can run individual unit tests by doing this
+# $abs_top_builddir/test/dbus/lvmdbustest.py -v TestDbusService.test_snapshot_merge
+
+# I'm guessing there is a better way to handle this with the built in test env.
+if [ $? -eq 0 ]; then
+ rm -f /tmp/lvmdbusd.log
+ rm -f /tmp/lvmdbustest.log
+fi
+
+echo "Stopping service"
+kill $LVM_DBUS_PID
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=70d0b210e17884ab…
Commit: 70d0b210e17884ab8cfc5f2a9be90461afb993c7
Parent: d7dd8bf9d6ef146d48e5a2d39cf7ae17ca93545b
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Mon Feb 22 14:00:30 2016 -0600
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Mon Feb 22 16:07:54 2016 -0600
lvmdbusd: background.py, fix stdout parse error
It appears that the output of lvconvert --merge can vary some. The code
was blowing up as it was trying to parse a line of stdout to retrieve the
% complete, but the line did not have the needed format and an execption
was thrown. The uncaught exception caused the background thread to exit
without updating the job object, which caused the client to hang forever
waiting. Added a default exception handler to prevent unhandled execptions
causing hangs and removed the parameter skip_first_line as it's no longer
needed. The code checks to see if the line can be parsed before doing so.
Signed-off-by: Tony Asleson <tasleson(a)redhat.com>
---
daemons/lvmdbusd/background.py | 85 ++++++++++++++++++++++++----------------
1 files changed, 51 insertions(+), 34 deletions(-)
diff --git a/daemons/lvmdbusd/background.py b/daemons/lvmdbusd/background.py
index 16ee7a6..4265154 100644
--- a/daemons/lvmdbusd/background.py
+++ b/daemons/lvmdbusd/background.py
@@ -14,8 +14,9 @@ import time
from .cmdhandler import options_to_cli_args
import dbus
from .job import Job, JobState
-from .utils import pv_range_append, pv_dest_ranges
+from .utils import pv_range_append, pv_dest_ranges, log_debug, log_error
from .request import RequestEntry
+import traceback
_rlock = threading.RLock()
_thread_list = list()
@@ -48,11 +49,11 @@ def _create_background_dbus_job(job_state):
return job_obj.dbus_object_path()
-def _move_merge(interface_name, cmd, time_out, skip_first_line=False):
+def _move_merge(interface_name, cmd, time_out):
# Create job object to be used while running the command
rc = '/'
job_state = JobState(None)
- add(cmd, job_state, skip_first_line)
+ add(cmd, job_state)
if time_out == -1:
# Waiting forever
@@ -122,7 +123,7 @@ def merge(interface_name, lv_uuid, lv_name, merge_options, time_out):
dbo = cfg.om.get_object_by_uuid_lvm_id(lv_uuid, lv_name)
if dbo:
cmd = lv_merge_cmd(merge_options, dbo.lvm_id)
- return _move_merge(interface_name, cmd, time_out, True)
+ return _move_merge(interface_name, cmd, time_out)
else:
raise dbus.exceptions.DBusException(
interface_name,
@@ -154,41 +155,57 @@ def empty_cb(disregard):
def background_execute(command, background_job, skip_first_line=False):
- process = subprocess.Popen(command, stdout=subprocess.PIPE,
- stderr=subprocess.PIPE, close_fds=True)
- lines_iterator = iter(process.stdout.readline, b"")
- for line in lines_iterator:
- # Merge ouputs a line before updates, move does not
- if skip_first_line:
- skip_first_line = False
- continue
-
- if len(line) > 10:
- (device, ignore, percentage) = line.decode("utf-8").split(':')
- background_job.Percent = round(float(percentage.strip()[:-1]), 1)
-
- out = process.communicate()
-
- # print "DEBUG: EC %d, STDOUT %s, STDERR %s" % \
- # (process.returncode, out[0], out[1])
-
- if process.returncode == 0:
- background_job.Percent = 100
-
- # Queue up the result so that it gets executed in same thread as others.
- r = RequestEntry(
- -1, process_background_result,
- (background_job, process.returncode, out[1]),
- empty_cb, empty_cb, False)
- cfg.worker_q.put(r)
-
-def add(command, reporting_job, skip_first_line=False):
+ # Wrap this whole operation in an exception handler, otherwise if we
+ # hit a code bug we will silently exit this thread without anyone being
+ # the wiser.
+ try:
+ process = subprocess.Popen(command, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE, close_fds=True)
+ lines_iterator = iter(process.stdout.readline, b"")
+ for line in lines_iterator:
+ line_str = line.decode("utf-8")
+
+ # Check to see if the line has the correct number of separators
+ try:
+ if line_str.count(':') == 2:
+ (device, ignore, percentage) = line_str.split(':')
+ background_job.Percent = \
+ round(float(percentage.strip()[:-1]), 1)
+ except ValueError:
+ log_error("Trying to parse percentage which failed for %s" %
+ line_str)
+
+ out = process.communicate()
+
+ if process.returncode == 0:
+ background_job.Percent = 100
+
+ # Queue up the result so that it gets executed in same thread as others.
+ r = RequestEntry(
+ -1, process_background_result,
+ (background_job, process.returncode, out[1]),
+ empty_cb, empty_cb, False)
+ cfg.worker_q.put(r)
+ except Exception:
+ # In the unlikely event that we blew up, lets notify fill out the
+ # job object so that the client doesn't hang potentially forever!
+ st = traceback.format_exc()
+ error = "Exception in background thread: \n%s" % st
+ log_error(error)
+ r = RequestEntry(
+ -1, process_background_result,
+ (background_job, 1, error),
+ empty_cb, empty_cb, False)
+ cfg.worker_q.put(r)
+
+
+def add(command, reporting_job):
# Create the thread, get it running and then add it to the list
t = threading.Thread(
target=background_execute,
name="thread: " + ' '.join(command),
- args=(command, reporting_job, skip_first_line))
+ args=(command, reporting_job))
t.start()
with _rlock:
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=367fb85e44e0718a…
Commit: 367fb85e44e0718a335c328ca75cb646539d3148
Parent: c716813651c2691c44bc709040cd16fbf363a74e
Author: Marian Csontos <mcsontos(a)redhat.com>
AuthorDate: Mon Feb 22 17:40:12 2016 +0100
Committer: Marian Csontos <mcsontos(a)redhat.com>
CommitterDate: Mon Feb 22 17:50:35 2016 +0100
spec: Fix 04ab1fa572bb: Remove left-overs
---
spec/build.inc | 5 -----
test/api/pytest.sh | 16 ++++++++++++----
2 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/spec/build.inc b/spec/build.inc
index 3ba7840..cd58f3b 100644
--- a/spec/build.inc
+++ b/spec/build.inc
@@ -55,11 +55,6 @@ make install_initscripts DESTDIR=$RPM_BUILD_ROOT
%if %{enable_testsuite}
make -C test install DESTDIR=$RPM_BUILD_ROOT
%endif
-%if %{enable_python3}
-pushd %{py3dir}
-make -C python install DESTDIR=$RPM_BUILD_ROOT
-popd
-%endif
# when building an src.rpm from freestanding specfiles
test -e %{_sourcedir}/source.inc || cp source.inc build.inc packages.inc macros.inc %{_sourcedir}
diff --git a/test/api/pytest.sh b/test/api/pytest.sh
index 33c1095..28a1cd0 100644
--- a/test/api/pytest.sh
+++ b/test/api/pytest.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
# Copyright (C) 2012-2015 Red Hat, Inc. All rights reserved.
#
# This file is part of LVM2.
@@ -31,9 +31,17 @@ aux prepare_dmeventd
#Locate the python binding library to use.
if [[ -n $abs_top_builddir ]]; then
- python_lib=$(find $abs_top_builddir -name lvm.so)
- # Unable to test python bindings if library not available
- test -n "$python_lib" || skip "lvm2-python-libs not built"
+ python_lib=($(find $abs_top_builddir -name lvm.so))
+ if [[ ${#python_lib[*]} -ne 1 ]]; then
+ if [[ ${#python_lib[*]} -gt 1 ]]; then
+ # Unable to test python bindings if multiple libraries found:
+ echo "Found left over lvm.so: ${python_lib[*]}"
+ false
+ else
+ # Unable to test python bindings if library not available
+ skip "lvm2-python-libs not built"
+ fi
+ fi
export PYTHONPATH=$(dirname $python_lib):$PYTHONPATH
elif rpm -q lvm2-python-libs &>/dev/null; then
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c716813651c2691c…
Commit: c716813651c2691c44bc709040cd16fbf363a74e
Parent: 161ae36363f5fa1b1469fd3a42c096c878002b31
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Feb 22 09:32:39 2016 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Feb 22 09:36:35 2016 -0600
lvmlockd: invalidate name in lockspace struct after remove
After the lockspace has been successfully removed,
invalidate the name field in the lockspace struct.
The struct remains on the list of lockspaces until
the struct can be freed later. Until the struct is
freed, its name will prevent another new lockspace
from being created with the same name.
---
daemons/lvmlockd/lvmlockd-core.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/daemons/lvmlockd/lvmlockd-core.c b/daemons/lvmlockd/lvmlockd-core.c
index 76a7650..c273d25 100644
--- a/daemons/lvmlockd/lvmlockd-core.c
+++ b/daemons/lvmlockd/lvmlockd-core.c
@@ -2269,6 +2269,7 @@ static void *lockspace_thread_main(void *arg_in)
struct action *act_op_free = NULL;
struct list_head tmp_act;
struct list_head act_close;
+ char tmp_name[MAX_NAME+1];
int free_vg = 0;
int drop_vg = 0;
int error = 0;
@@ -2634,6 +2635,10 @@ out_act:
ls->drop_vg = drop_vg;
if (ls->lm_type == LD_LM_DLM && !strcmp(ls->name, gl_lsname_dlm))
global_dlm_lockspace_exists = 0;
+ /* Avoid a name collision of the same lockspace is added again before this thread is cleaned up. */
+ memset(tmp_name, 0, sizeof(tmp_name));
+ snprintf(tmp_name, MAX_NAME, "REM:%s", ls->name);
+ memcpy(ls->name, tmp_name, MAX_NAME);
pthread_mutex_unlock(&lockspaces_mutex);
/* worker_thread will join this thread, and free the ls */
@@ -3113,6 +3118,8 @@ static int for_each_lockspace(int do_stop, int do_free, int do_force)
/* FIXME: will free_vg ever not be set? */
+ log_debug("free ls %s", ls->name);
+
if (ls->free_vg) {
/* In future we may need to free ls->actions here */
free_ls_resources(ls);