Browse code

Merge "install ebtables locking workaround"

Jenkins authored on 2015/11/19 08:20:36
Showing 4 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,23 @@
0
+#!/bin/bash
1
+#
2
+# Copyright 2015 Hewlett-Packard Development Company, L.P.
3
+#
4
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
5
+# not use this file except in compliance with the License. You may obtain
6
+# a copy of the License at
7
+#
8
+#    http://www.apache.org/licenses/LICENSE-2.0
9
+#
10
+# Unless required by applicable law or agreed to in writing, software
11
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+# License for the specific language governing permissions and limitations
14
+# under the License.
15
+#
16
+#
17
+# This is a terrible, terrible, truly terrible work around for
18
+# environments that have libvirt < 1.2.11. ebtables requires that you
19
+# specifically tell it you would like to not race and get punched in
20
+# the face when 2 run at the same time with a --concurrent flag.
21
+
22
+flock -w 300 /var/lock/ebtables.nova /sbin/ebtables.real $@
... ...
@@ -31,6 +31,11 @@ function install_libvirt {
31 31
         fi
32 32
         install_package libvirt-bin libvirt-dev
33 33
         pip_install_gr libvirt-python
34
+        if [[ "$EBTABLES_RACE_FIX" == "True" ]]; then
35
+            # Work around for bug #1501558. We can remove this once we
36
+            # get to a version of Ubuntu that has new enough libvirt.
37
+            TOP_DIR=$TOP_DIR $TOP_DIR/tools/install_ebtables_workaround.sh
38
+        fi
34 39
         #pip_install_gr <there-si-no-guestfs-in-pypi>
35 40
     elif is_fedora || is_suse; then
36 41
         install_package kvm
... ...
@@ -766,6 +766,16 @@ GIT_DEPTH=${GIT_DEPTH:-0}
766 766
 # Use native SSL for servers in ``SSL_ENABLED_SERVICES``
767 767
 USE_SSL=$(trueorfalse False USE_SSL)
768 768
 
769
+# ebtables is inherently racey. If you run it by two or more processes
770
+# simultaneously it will collide, badly, in the kernel and produce
771
+# failures or corruption of ebtables. The only way around it is for
772
+# all tools running ebtables to only ever do so with the --concurrent
773
+# flag. This requires libvirt >= 1.2.11.
774
+#
775
+# If you don't have this then the following work around will replace
776
+# ebtables with a wrapper script so that it is safe to run without
777
+# that flag.
778
+EBTABLES_RACE_FIX=$(trueorfalse False EBTABLES_RACE_FIX)
769 779
 
770 780
 # Following entries need to be last items in file
771 781
 
772 782
new file mode 100755
... ...
@@ -0,0 +1,31 @@
0
+#!/bin/bash -eu
1
+#
2
+# Copyright 2015 Hewlett-Packard Development Company, L.P.
3
+#
4
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
5
+# not use this file except in compliance with the License. You may obtain
6
+# a copy of the License at
7
+#
8
+#    http://www.apache.org/licenses/LICENSE-2.0
9
+#
10
+# Unless required by applicable law or agreed to in writing, software
11
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+# License for the specific language governing permissions and limitations
14
+# under the License.
15
+#
16
+#
17
+# This replaces the ebtables on your system with a wrapper script that
18
+# does implicit locking. This is needed if libvirt < 1.2.11 on your platform.
19
+
20
+EBTABLES=/sbin/ebtables
21
+EBTABLESREAL=/sbin/ebtables.real
22
+FILES=$TOP_DIR/files
23
+
24
+if [[ -f "$EBTABLES" ]]; then
25
+    if file $EBTABLES | grep ELF; then
26
+        sudo mv $EBTABLES $EBTABLESREAL
27
+        sudo install -m 0755 $FILES/ebtables.workaround $EBTABLES
28
+        echo "Replaced ebtables with locking workaround"
29
+    fi
30
+fi