From: Ondrej Lichtner olichtne@redhat.com
When creation and configuration of a device fails, calling the link_stats method would raise an Exception. Since this is always called during deconfiguration, a configuration error would result in an exception related crash of LNST and leave the Slave in an inconsistent state - unable to run any more recipes unless manually restarted.
This commit fixes the issue by catching the exception and returning an empty stats dictionary to indicate the failure. This is detected on the Controller and the logging of device stats is skipped.
Signed-off-by: Ondrej Lichtner olichtne@redhat.com --- lnst/Controller/Machine.py | 15 +++++++++------ lnst/Slave/InterfaceManager.py | 6 +++++- 2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/lnst/Controller/Machine.py b/lnst/Controller/Machine.py index 3725de6..b2cff15 100644 --- a/lnst/Controller/Machine.py +++ b/lnst/Controller/Machine.py @@ -309,12 +309,15 @@ class Machine(object): if isinstance(iface, UnusedInterface): continue stats = iface.link_stats() - logging.debug("%s:%s:%s: RX:\t bytes: %d\t packets: %d\t dropped: %d" % - (iface.get_netns(), iface.get_host(), iface.get_id(), - stats["rx_bytes"], stats["rx_packets"], stats["rx_dropped"])) - logging.debug("%s:%s:%s: TX:\t bytes: %d\t packets: %d\t dropped: %d" % - (iface.get_netns(), iface.get_host(), iface.get_id(), - stats["tx_bytes"], stats["tx_packets"], stats["tx_dropped"])) + if stats: + logging.debug("%s:%s:%s: RX:\t bytes: %d\t packets: %d\t dropped: %d" % + (iface.get_netns(), iface.get_host(), + iface.get_id(), stats["rx_bytes"], + stats["rx_packets"], stats["rx_dropped"])) + logging.debug("%s:%s:%s: TX:\t bytes: %d\t packets: %d\t dropped: %d" % + (iface.get_netns(), iface.get_host(), + iface.get_id(), stats["tx_bytes"], + stats["tx_packets"], stats["tx_dropped"]))
self._rpc_call("kill_cmds") for netns in self._namespaces: diff --git a/lnst/Slave/InterfaceManager.py b/lnst/Slave/InterfaceManager.py index 51aa6cc..05bd71e 100644 --- a/lnst/Slave/InterfaceManager.py +++ b/lnst/Slave/InterfaceManager.py @@ -647,7 +647,11 @@ class Device(object): def link_stats(self): stats = {"devname": self._name, "hwaddr": self._hwaddr} - out, _ = exec_cmd("ip -s link show %s" % self._name) + try: + out, _ = exec_cmd("ip -s link show %s" % self._name) + except: + return {} + lines = iter(out.split("\n")) for line in lines: if (len(line.split()) == 0):
From: Ondrej Lichtner olichtne@redhat.com
Recent removal of the --dump-pools argument in favor of the list_pools action broke the regression-tests run-tests.sh script.
In addition to that I moved the lnst-ctl function call from the lib.sh file into the main run-test.sh file and fixed it's handling of the -C vs -c argument which I previously only fixed in the get_pool_dirs function.
And a final minor change is the addition of the -L argument to rsync calls so that we also copy linked directories and files such as pools or slave machine description xmls.
Signed-off-by: Ondrej Lichtner olichtne@redhat.com --- regression-tests/run-test.sh | 20 ++++++++++++-------- regression-tests/tests/lib.sh | 9 --------- 2 files changed, 12 insertions(+), 17 deletions(-)
diff --git a/regression-tests/run-test.sh b/regression-tests/run-test.sh index 02fa126..2ffd505 100755 --- a/regression-tests/run-test.sh +++ b/regression-tests/run-test.sh @@ -56,22 +56,27 @@ function usage exit 0 }
-function get_pool_dirs +function lnst-ctl { - if [ "$use_user_conf" = "true" ]; then - command lnst-ctl --dump-pools 2>/dev/null | cut -d = -f2 + if [ "$use_user_conf" = "false" ]; then + command lnst-ctl -C $repo/lnst-ctl.conf $@ else - command lnst-ctl -C $repo/lnst-ctl.conf --dump-pools 2>/dev/null | - cut -d = -f2 + command lnst-ctl $@ fi }
+function get_pool_dirs +{ + lnst-ctl list_pools 2>/dev/null | sed -n 's/Pool: .*((.*))$/\1/p' +} + # ---
#default repository url url="../" use_git=true export use_user_conf="false" +export -f lnst-ctl
while getopts "chlr:t:g:ns" OPTION do @@ -110,7 +115,7 @@ export repo=`mktemp -d` if $use_git ; then git clone $url $repo else - rsync -r $url $repo + rsync -r -L $url $repo fi
if $use_git ; then @@ -146,8 +151,7 @@ for pool_dir in $pool_dirs; do remote_repo=`ssh "root@$hostname" "mktemp -d"`
# Transfer the repo to the machine - rsync -r --exclude "Logs" --exclude ".git" "$repo/" \ - "root@$hostname:$remote_repo" + rsync -r -L --exclude "Logs" "$repo/" "root@$hostname:$remote_repo"
if [ ! -z $nm_off ]; then ssh "root@$hostname" "cd $remote_repo && echo "use_nm = false" >> lnst-slave.conf" diff --git a/regression-tests/tests/lib.sh b/regression-tests/tests/lib.sh index 5286534..df83ab1 100644 --- a/regression-tests/tests/lib.sh +++ b/regression-tests/tests/lib.sh @@ -56,12 +56,3 @@ function print_separator { echo "--------------------------------------------------------------------------------" } - -function lnst-ctl -{ - if [ "$use_user_conf" = "true" ]; then - command lnst-ctl $@ - else - command lnst-ctl -c $repo/lnst-ctl.conf $@ - fi -}
lnst-developers@lists.fedorahosted.org