Skip to content

Commit

Permalink
fedora package: fix systemd ordering and deps.
Browse files Browse the repository at this point in the history
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: 6024530
   rhel: Automatically start openvswitch service before bringing an ovs interfa

   commit: 3214851
   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 <[email protected]>
Signed-off-by: Gurucharan Shetty <[email protected]>
  • Loading branch information
fleitner authored and shettyg committed Jan 9, 2014
1 parent 615309c commit b49c106
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 7 deletions.
4 changes: 3 additions & 1 deletion rhel/automake.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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') \
Expand Down
11 changes: 10 additions & 1 deletion rhel/etc_sysconfig_network-scripts_ifdown-ovs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 10 additions & 1 deletion rhel/etc_sysconfig_network-scripts_ifup-ovs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion rhel/openvswitch-fedora.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions rhel/usr_lib_systemd_system_openvswitch-nonetwork.service
Original file line number Diff line number Diff line change
@@ -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
7 changes: 4 additions & 3 deletions rhel/usr_lib_systemd_system_openvswitch.service
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
23 changes: 23 additions & 0 deletions rhel/usr_share_openvswitch_scripts_systemd_sysconfig.template
Original file line number Diff line number Diff line change
@@ -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=""

0 comments on commit b49c106

Please sign in to comment.