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/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') \
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)
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)
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
$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
%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
--- /dev/null
+[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
[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]
--- /dev/null
+### 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=""