fedora package: fix systemd ordering and deps.
authorFlavio Leitner <fbl@redhat.com>
Thu, 9 Jan 2014 03:04:33 +0000 (01:04 -0200)
committerGurucharan Shetty <gshetty@nicira.com>
Thu, 9 Jan 2014 18:57:08 +0000 (10:57 -0800)
There is a chicken and egg issue where common OVS
configuration uses a controller which is only accessible
via the network. So starting OVS before network.target
would break those configurations.

However, the network doesn't come up after boot because
OVS isn't started until after the network scripts tries
to configure the ovs.

This is partially fixed by commits:
   commit: 602453000e28ec1076c0482ce13c284765a84409
   rhel: Automatically start openvswitch service before bringing an ovs interfa

   commit: 3214851c31538e8690e31f95702f8927a8c0838b
   rhel: Add OVSREQUIRES to automatically bring up OpenFlow interface dependencies

But still there is the dependency issue between network.target
and openvswitch which this patch fixes it.  It provides two systemd
service units. One to run at any time (openvswitch-nonetwork.service)
which runs 'ovs-ctl start' and the other one (openvswith.service) to
run after network.target which works as a frontend to the admin.

The openvswitch-nonetwork.service is used internally by the
'ifup-ovs/ifdown-ovs' scripts when adding or removing ports to
the bridge or when the openvswitch.service is enabled by the admin.

Signed-off-by: Flavio Leitner <fbl@redhat.com>
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
rhel/automake.mk
rhel/etc_sysconfig_network-scripts_ifdown-ovs
rhel/etc_sysconfig_network-scripts_ifup-ovs
rhel/openvswitch-fedora.spec.in
rhel/usr_lib_systemd_system_openvswitch-nonetwork.service [new file with mode: 0644]
rhel/usr_lib_systemd_system_openvswitch.service
rhel/usr_share_openvswitch_scripts_systemd_sysconfig.template [new file with mode: 0644]

index 2911e71..9cd9a41 100644 (file)
@@ -22,7 +22,9 @@ EXTRA_DIST += \
        rhel/openvswitch-fedora.spec \
        rhel/openvswitch-fedora.spec.in \
        rhel/usr_share_openvswitch_scripts_sysconfig.template \
-       rhel/usr_lib_systemd_system_openvswitch.service
+       rhel/usr_share_openvswitch_scripts_systemd_sysconfig.template \
+       rhel/usr_lib_systemd_system_openvswitch.service \
+       rhel/usr_lib_systemd_system_openvswitch-nonetwork.service
 
 update_rhel_spec = \
   ($(ro_shell) && sed -e 's,[@]VERSION[@],$(VERSION),g') \
index 8e768c8..daa5786 100755 (executable)
@@ -34,7 +34,16 @@ if [ ! -x ${OTHERSCRIPT} ]; then
     OTHERSCRIPT="/etc/sysconfig/network-scripts/ifdown-eth"
 fi
 
-[ -f /var/lock/subsys/openvswitch ] || /sbin/service openvswitch start
+SERVICE_UNIT=/usr/lib/systemd/system/openvswitch-nonetwork.service
+if [ -f $SERVICE_UNIT ] && [ -x /usr/bin/systemctl ]; then
+       if ! systemctl --quiet is-active openvswitch-nonetwork.service; then
+               systemctl start openvswitch-nonetwork.service
+       fi
+else
+       if [ ! -f /var/lock/subsys/openvswitch ]; then
+               /sbin/service openvswitch start
+       fi
+fi
 
 case "$TYPE" in
        OVSBridge)
index 017346d..3f31c30 100755 (executable)
@@ -60,7 +60,16 @@ fi
        fi
 done
 
-[ -f /var/lock/subsys/openvswitch ] || /sbin/service openvswitch start
+SERVICE_UNIT=/usr/lib/systemd/system/openvswitch-nonetwork.service
+if [ -f $SERVICE_UNIT ] && [ -x /usr/bin/systemctl ]; then
+       if ! systemctl --quiet is-active openvswitch-nonetwork.service; then
+               systemctl start openvswitch-nonetwork.service
+       fi
+else
+       if [ ! -f /var/lock/subsys/openvswitch ]; then
+               /sbin/service openvswitch start
+       fi
+fi
 
 case "$TYPE" in
        OVSBridge)
index 5cec1ff..19fa154 100644 (file)
@@ -45,6 +45,8 @@ install -d -m 755 $RPM_BUILD_ROOT/etc
 install -d -m 755 $RPM_BUILD_ROOT/etc/openvswitch
 install -p -D -m 0644 rhel/usr_lib_systemd_system_openvswitch.service \
         $RPM_BUILD_ROOT%{_unitdir}/openvswitch.service
+install -p -D -m 0644 rhel/usr_lib_systemd_system_openvswitch-nonetwork.service \
+        $RPM_BUILD_ROOT%{_unitdir}/openvswitch-nonetwork.service
 install -m 755 rhel/etc_init.d_openvswitch \
         $RPM_BUILD_ROOT%{_datadir}/openvswitch/scripts/openvswitch.init
 install -d -m 755 $RPM_BUILD_ROOT/etc/sysconfig
@@ -60,7 +62,7 @@ install -p -m 0755 rhel/etc_sysconfig_network-scripts_ifdown-ovs \
         $RPM_BUILD_ROOT/etc/sysconfig/network-scripts/ifdown-ovs
 install -p -m 0755 rhel/etc_sysconfig_network-scripts_ifup-ovs \
         $RPM_BUILD_ROOT/etc/sysconfig/network-scripts/ifup-ovs
-install -p -D -m 0644 rhel/usr_share_openvswitch_scripts_sysconfig.template \
+install -p -D -m 0644 rhel/usr_share_openvswitch_scripts_systemd_sysconfig.template \
         $RPM_BUILD_ROOT/etc/sysconfig/openvswitch
 install -d -m 755 $RPM_BUILD_ROOT/usr/share/openvswitch/scripts
 
@@ -104,6 +106,7 @@ systemctl start openvswitch.service
 %config /etc/sysconfig/openvswitch
 %config /etc/logrotate.d/openvswitch
 %{_unitdir}/openvswitch.service
+%{_unitdir}/openvswitch-nonetwork.service
 %{_datadir}/openvswitch/scripts/openvswitch.init
 %{_sysconfdir}/sysconfig/network-scripts/ifup-ovs
 %{_sysconfdir}/sysconfig/network-scripts/ifdown-ovs
diff --git a/rhel/usr_lib_systemd_system_openvswitch-nonetwork.service b/rhel/usr_lib_systemd_system_openvswitch-nonetwork.service
new file mode 100644 (file)
index 0000000..870b25e
--- /dev/null
@@ -0,0 +1,13 @@
+[Unit]
+Description=Open vSwitch Internal Unit
+After=syslog.target
+PartOf=openvswitch.service
+Wants=openvswitch.service
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+EnvironmentFile=-/etc/sysconfig/openvswitch
+ExecStart=/usr/share/openvswitch/scripts/ovs-ctl start \
+          --system-id=random $OPTIONS
+ExecStop=/usr/share/openvswitch/scripts/ovs-ctl stop
index f39d7e6..f0bc16f 100644 (file)
@@ -1,11 +1,12 @@
 [Unit]
 Description=Open vSwitch
-After=syslog.target network.target
+After=syslog.target network.target openvswitch-nonetwork.service
+Requires=openvswitch-nonetwork.service
 
 [Service]
 Type=oneshot
-ExecStart=/usr/share/openvswitch/scripts/openvswitch.init start
-ExecStop=/usr/share/openvswitch/scripts/openvswitch.init stop
+ExecStart=/bin/true
+ExecStop=/bin/true
 RemainAfterExit=yes
 
 [Install]
diff --git a/rhel/usr_share_openvswitch_scripts_systemd_sysconfig.template b/rhel/usr_share_openvswitch_scripts_systemd_sysconfig.template
new file mode 100644 (file)
index 0000000..3050a07
--- /dev/null
@@ -0,0 +1,23 @@
+### Configuration options for openvswitch
+#
+# Enable core files:
+# --force-corefiles=yes
+#
+# Set "nice" priority at which to run ovsdb-server:
+# --ovsdb-server-priority=-10
+#
+# Set "nice" priority at which to run ovsdb-vswitchd:
+# --ovs-vswitchd-priority=-10
+#
+# Pass or not --mlockall option to ovs-vswitchd.
+# This option should be set to "yes" or "no".  The default is "yes".
+# Enabling this option can avoid networking interruptions due to
+# system memory pressure in extraordinary situations, such as multiple
+# concurrent VM import operations.
+# --mlockall=yes
+#
+# Use valgrind:
+#   --ovs-vswitchd-wrapper=valgrind
+#   --ovsdb-server-wrapper=valgrind
+#
+OPTIONS=""