28fc1e
From f32488ec28a05e26e0298b3e10b3a7fe422fbf88 Mon Sep 17 00:00:00 2001
28fc1e
From: Flavio Leitner <fbl@redhat.com>
28fc1e
Date: Thu, 9 Jan 2014 01:04:33 -0200
28fc1e
Subject: [PATCH] fedora package: fix systemd ordering and deps.
28fc1e
28fc1e
There is a chicken and egg issue where common OVS
28fc1e
configuration uses a controller which is only accessible
28fc1e
via the network. So starting OVS before network.target
28fc1e
would break those configurations.
28fc1e
28fc1e
However, the network doesn't come up after boot because
28fc1e
OVS isn't started until after the network scripts tries
28fc1e
to configure the ovs.
28fc1e
28fc1e
This is partially fixed by commits:
28fc1e
   commit: 602453000e28ec1076c0482ce13c284765a84409
28fc1e
   rhel: Automatically start openvswitch service before bringing an ovs interfa
28fc1e
28fc1e
   commit: 3214851c31538e8690e31f95702f8927a8c0838b
28fc1e
   rhel: Add OVSREQUIRES to automatically bring up OpenFlow interface dependencies
28fc1e
28fc1e
But still there is the dependency issue between network.target
28fc1e
and openvswitch which this patch fixes it.  It provides two systemd
28fc1e
service units. One to run at any time (openvswitch-nonetwork.service)
28fc1e
which runs 'ovs-ctl start' and the other one (openvswith.service) to
28fc1e
run after network.target which works as a frontend to the admin.
28fc1e
28fc1e
The openvswitch-nonetwork.service is used internally by the
28fc1e
'ifup-ovs/ifdown-ovs' scripts when adding or removing ports to
28fc1e
the bridge or when the openvswitch.service is enabled by the admin.
28fc1e
28fc1e
Signed-off-by: Flavio Leitner <fbl@redhat.com>
28fc1e
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
28fc1e
---
28fc1e
 rhel/automake.mk                                   |  4 +++-
28fc1e
 rhel/etc_sysconfig_network-scripts_ifdown-ovs      | 11 ++++++++++-
28fc1e
 rhel/etc_sysconfig_network-scripts_ifup-ovs        | 11 ++++++++++-
28fc1e
 rhel/openvswitch-fedora.spec.in                    |  5 ++++-
28fc1e
 ...ib_systemd_system_openvswitch-nonetwork.service | 13 ++++++++++++
28fc1e
 rhel/usr_lib_systemd_system_openvswitch.service    |  7 ++++---
28fc1e
 ..._openvswitch_scripts_systemd_sysconfig.template | 23 ++++++++++++++++++++++
28fc1e
 7 files changed, 67 insertions(+), 7 deletions(-)
28fc1e
 create mode 100644 rhel/usr_lib_systemd_system_openvswitch-nonetwork.service
28fc1e
 create mode 100644 rhel/usr_share_openvswitch_scripts_systemd_sysconfig.template
28fc1e
28fc1e
diff --git a/rhel/automake.mk b/rhel/automake.mk
28fc1e
index 2911e71..9cd9a41 100644
28fc1e
--- a/rhel/automake.mk
28fc1e
+++ b/rhel/automake.mk
28fc1e
@@ -22,7 +22,9 @@ EXTRA_DIST += \
28fc1e
 	rhel/openvswitch-fedora.spec \
28fc1e
 	rhel/openvswitch-fedora.spec.in \
28fc1e
 	rhel/usr_share_openvswitch_scripts_sysconfig.template \
28fc1e
-	rhel/usr_lib_systemd_system_openvswitch.service
28fc1e
+	rhel/usr_share_openvswitch_scripts_systemd_sysconfig.template \
28fc1e
+	rhel/usr_lib_systemd_system_openvswitch.service \
28fc1e
+	rhel/usr_lib_systemd_system_openvswitch-nonetwork.service
28fc1e
 
28fc1e
 update_rhel_spec = \
28fc1e
   ($(ro_shell) && sed -e 's,[@]VERSION[@],$(VERSION),g') \
28fc1e
diff --git a/rhel/etc_sysconfig_network-scripts_ifdown-ovs b/rhel/etc_sysconfig_network-scripts_ifdown-ovs
28fc1e
index d2a2f4b..32fddb5 100755
28fc1e
--- a/rhel/etc_sysconfig_network-scripts_ifdown-ovs
28fc1e
+++ b/rhel/etc_sysconfig_network-scripts_ifdown-ovs
28fc1e
@@ -34,7 +34,16 @@ if [ ! -x ${OTHERSCRIPT} ]; then
28fc1e
     OTHERSCRIPT="/etc/sysconfig/network-scripts/ifdown-eth"
28fc1e
 fi
28fc1e
 
28fc1e
-[ -f /var/lock/subsys/openvswitch ] || /sbin/service openvswitch start
28fc1e
+SERVICE_UNIT=/usr/lib/systemd/system/openvswitch-nonetwork.service
28fc1e
+if [ -f $SERVICE_UNIT ] && [ -x /usr/bin/systemctl ]; then
28fc1e
+	if ! systemctl --quiet is-active openvswitch-nonetwork.service; then
28fc1e
+		systemctl start openvswitch-nonetwork.service
28fc1e
+	fi
28fc1e
+else
28fc1e
+	if [ ! -f /var/lock/subsys/openvswitch ]; then
28fc1e
+		/sbin/service openvswitch start
28fc1e
+	fi
28fc1e
+fi
28fc1e
 
28fc1e
 case "$TYPE" in
28fc1e
 	OVSBridge)
28fc1e
diff --git a/rhel/etc_sysconfig_network-scripts_ifup-ovs b/rhel/etc_sysconfig_network-scripts_ifup-ovs
28fc1e
index 8904c59..3c6b557 100755
28fc1e
--- a/rhel/etc_sysconfig_network-scripts_ifup-ovs
28fc1e
+++ b/rhel/etc_sysconfig_network-scripts_ifup-ovs
28fc1e
@@ -60,7 +60,16 @@ fi
28fc1e
 	fi
28fc1e
 done
28fc1e
 
28fc1e
-[ -f /var/lock/subsys/openvswitch ] || /sbin/service openvswitch start
28fc1e
+SERVICE_UNIT=/usr/lib/systemd/system/openvswitch-nonetwork.service
28fc1e
+if [ -f $SERVICE_UNIT ] && [ -x /usr/bin/systemctl ]; then
28fc1e
+	if ! systemctl --quiet is-active openvswitch-nonetwork.service; then
28fc1e
+		systemctl start openvswitch-nonetwork.service
28fc1e
+	fi
28fc1e
+else
28fc1e
+	if [ ! -f /var/lock/subsys/openvswitch ]; then
28fc1e
+		/sbin/service openvswitch start
28fc1e
+	fi
28fc1e
+fi
28fc1e
 
28fc1e
 case "$TYPE" in
28fc1e
 	OVSBridge)
28fc1e
diff --git a/rhel/openvswitch-fedora.spec.in b/rhel/openvswitch-fedora.spec.in
28fc1e
index 27a3b03..8a5505d 100644
28fc1e
--- a/rhel/openvswitch-fedora.spec.in
28fc1e
+++ b/rhel/openvswitch-fedora.spec.in
28fc1e
@@ -45,6 +45,8 @@ install -d -m 755 $RPM_BUILD_ROOT/etc
28fc1e
 install -d -m 755 $RPM_BUILD_ROOT/etc/openvswitch
28fc1e
 install -p -D -m 0644 rhel/usr_lib_systemd_system_openvswitch.service \
28fc1e
         $RPM_BUILD_ROOT%{_unitdir}/openvswitch.service
28fc1e
+install -p -D -m 0644 rhel/usr_lib_systemd_system_openvswitch-nonetwork.service \
28fc1e
+        $RPM_BUILD_ROOT%{_unitdir}/openvswitch-nonetwork.service
28fc1e
 install -m 755 rhel/etc_init.d_openvswitch \
28fc1e
         $RPM_BUILD_ROOT%{_datadir}/openvswitch/scripts/openvswitch.init
28fc1e
 install -d -m 755 $RPM_BUILD_ROOT/etc/sysconfig
28fc1e
@@ -60,7 +62,7 @@ install -p -m 0755 rhel/etc_sysconfig_network-scripts_ifdown-ovs \
28fc1e
         $RPM_BUILD_ROOT/etc/sysconfig/network-scripts/ifdown-ovs
28fc1e
 install -p -m 0755 rhel/etc_sysconfig_network-scripts_ifup-ovs \
28fc1e
         $RPM_BUILD_ROOT/etc/sysconfig/network-scripts/ifup-ovs
28fc1e
-install -p -D -m 0644 rhel/usr_share_openvswitch_scripts_sysconfig.template \
28fc1e
+install -p -D -m 0644 rhel/usr_share_openvswitch_scripts_systemd_sysconfig.template \
28fc1e
         $RPM_BUILD_ROOT/etc/sysconfig/openvswitch
28fc1e
 install -d -m 755 $RPM_BUILD_ROOT/usr/share/openvswitch/scripts
28fc1e
 
28fc1e
@@ -101,6 +103,7 @@ systemctl start openvswitch.service
28fc1e
 %config /etc/sysconfig/openvswitch
28fc1e
 %config /etc/logrotate.d/openvswitch
28fc1e
 %{_unitdir}/openvswitch.service
28fc1e
+%{_unitdir}/openvswitch-nonetwork.service
28fc1e
 %{_datadir}/openvswitch/scripts/openvswitch.init
28fc1e
 %{_sysconfdir}/sysconfig/network-scripts/ifup-ovs
28fc1e
 %{_sysconfdir}/sysconfig/network-scripts/ifdown-ovs
28fc1e
diff --git a/rhel/usr_lib_systemd_system_openvswitch-nonetwork.service b/rhel/usr_lib_systemd_system_openvswitch-nonetwork.service
28fc1e
new file mode 100644
28fc1e
index 0000000..870b25e
28fc1e
--- /dev/null
28fc1e
+++ b/rhel/usr_lib_systemd_system_openvswitch-nonetwork.service
28fc1e
@@ -0,0 +1,13 @@
28fc1e
+[Unit]
28fc1e
+Description=Open vSwitch Internal Unit
28fc1e
+After=syslog.target
28fc1e
+PartOf=openvswitch.service
28fc1e
+Wants=openvswitch.service
28fc1e
+
28fc1e
+[Service]
28fc1e
+Type=oneshot
28fc1e
+RemainAfterExit=yes
28fc1e
+EnvironmentFile=-/etc/sysconfig/openvswitch
28fc1e
+ExecStart=/usr/share/openvswitch/scripts/ovs-ctl start \
28fc1e
+          --system-id=random $OPTIONS
28fc1e
+ExecStop=/usr/share/openvswitch/scripts/ovs-ctl stop
28fc1e
diff --git a/rhel/usr_lib_systemd_system_openvswitch.service b/rhel/usr_lib_systemd_system_openvswitch.service
28fc1e
index f39d7e6..f0bc16f 100644
28fc1e
--- a/rhel/usr_lib_systemd_system_openvswitch.service
28fc1e
+++ b/rhel/usr_lib_systemd_system_openvswitch.service
28fc1e
@@ -1,11 +1,12 @@
28fc1e
 [Unit]
28fc1e
 Description=Open vSwitch
28fc1e
-After=syslog.target network.target
28fc1e
+After=syslog.target network.target openvswitch-nonetwork.service
28fc1e
+Requires=openvswitch-nonetwork.service
28fc1e
 
28fc1e
 [Service]
28fc1e
 Type=oneshot
28fc1e
-ExecStart=/usr/share/openvswitch/scripts/openvswitch.init start
28fc1e
-ExecStop=/usr/share/openvswitch/scripts/openvswitch.init stop
28fc1e
+ExecStart=/bin/true
28fc1e
+ExecStop=/bin/true
28fc1e
 RemainAfterExit=yes
28fc1e
 
28fc1e
 [Install]
28fc1e
diff --git a/rhel/usr_share_openvswitch_scripts_systemd_sysconfig.template b/rhel/usr_share_openvswitch_scripts_systemd_sysconfig.template
28fc1e
new file mode 100644
28fc1e
index 0000000..3050a07
28fc1e
--- /dev/null
28fc1e
+++ b/rhel/usr_share_openvswitch_scripts_systemd_sysconfig.template
28fc1e
@@ -0,0 +1,23 @@
28fc1e
+### Configuration options for openvswitch
28fc1e
+#
28fc1e
+# Enable core files:
28fc1e
+# --force-corefiles=yes
28fc1e
+#
28fc1e
+# Set "nice" priority at which to run ovsdb-server:
28fc1e
+# --ovsdb-server-priority=-10
28fc1e
+#
28fc1e
+# Set "nice" priority at which to run ovsdb-vswitchd:
28fc1e
+# --ovs-vswitchd-priority=-10
28fc1e
+#
28fc1e
+# Pass or not --mlockall option to ovs-vswitchd.
28fc1e
+# This option should be set to "yes" or "no".  The default is "yes".
28fc1e
+# Enabling this option can avoid networking interruptions due to
28fc1e
+# system memory pressure in extraordinary situations, such as multiple
28fc1e
+# concurrent VM import operations.
28fc1e
+# --mlockall=yes
28fc1e
+#
28fc1e
+# Use valgrind:
28fc1e
+#   --ovs-vswitchd-wrapper=valgrind
28fc1e
+#   --ovsdb-server-wrapper=valgrind
28fc1e
+#
28fc1e
+OPTIONS=""
28fc1e
-- 
28fc1e
1.8.4.2
28fc1e