gstanden / orabuntu-lxc

Developer and User Guide
https://gstanden.github.io/
GNU General Public License v3.0
46 stars 15 forks source link

Incorporate Networking Improvements for OpenvSwitch #57

Closed gstanden closed 3 years ago

gstanden commented 8 years ago

Testing on the Dell PowerEdge 2850's revealed some serious bootup hang problems with the current networking startup for OpenvSwitch. The new design needs the following incorporated into orabuntu-lxc:

CHANGE 1

  1. The patches and edits described at this link:
    https://github.com/jpfluger/examples/blob/master/ubuntu-14.04/openvswitch.md Those changes are:

Clear OVS on Reboot

Since we will be letting Ubuntu implement OVS via /etc/network/interfaces instead of using ovs-ctl commands, we need to instruct Ubuntu on restart to clear the OVS tables, so they may be refreshed with the parameters supplied in /etc/network/interfaces.

Open the OVS defaults file in a text editor.

$ sudo vim /etc/default/openvswitch-switch

Add --delete-bridges to the options line.

OVS_CTL_OPTS: Extra options to pass to ovs-ctl. This is, for example, a suitable place to specify --ovs-vswitchd-wrapper=valgrind. OVS_CTL_OPTS='--delete-bridges'

Per this guide, patch the OVS upstart script.

First open the script.

$ sudo vim /etc/init/openvswitch-switch.conf

The edits appear in two places defined by PATCH-START and PATCH-END.

set ovs_ctl start --system-id=random if test X"$FORCE_COREFILES" != X; then set "$@" --force-corefiles="$FORCE_COREFILES" fi set "$@" $OVS_CTL_OPTS

PATCH-START

"$@" || exit $? bridges=ifquery --allow ovs -l [ -n "${bridges}" ] && ifup --allow=ovs ${bridges} logger -t ovs-start pre-start end

PATCH-END

end script

post-stop script

PATCH-START

logger -t ovs-stop post-stop bridges=ifquery --allow ovs -l [ -n "${bridges}" ] && ifdown --allow=ovs ${bridges}

PATCH-END

. /usr/share/openvswitch/scripts/ovs-lib test -e /etc/default/openvswitch-switch && . /etc/default/openvswitch-switch

ovs_ctl stop end script +++ So basically, we just want to include the scripts:

/etc/init/openvswitch-switch.conf /etc/default/openvswitch-switch

Also, see below, we will need to add the following scripts to ubuntu-host.tar as well:

/etc/init.d/rc.local (new version) /etc/rc.local.shutdown /etc/rc.local.startup

Then the following commands will need to be run in ubuntu-services-1.sh after ubuntu-host.tar has been unpacked:

sudo chmod +x /etc/init/rc.local sudo chmod +x /etc/rc.local.startup sudo chmod +x /etc/rc.local.shutdown sudo /usr/sbin/update-rc.d -f rc.local remove sudo /usr/sbin/update-rc.d rc.local defaults sudo find /etc/rc?.d -iname '*local' sudo mv /etc/rcS.d/S02rc.local /etc/rcS.d/S15rc.local

in the ubuntu-host.tar bundle and overwrite the existing script so that the one used has the patches and the delete-bridges switch enabled, respectively.

CHANGE 2

  1. Setup the rc.local.startup and the rc.local.shutdown as described here:

http://crunchbang.org/forums/viewtopic.php?id=14453

And then put the following contents into the rc.local.shutdown (for each openvswitch bridge - here only sw1 and sx1 are shown). This scripting deletes the bridge and all associated ports completely for each OpenvSwitch.

gstanden@P2850A:/etc$ cat rc.local.shutdown

!/bin/sh -e

rc.local

This script is executed at shutdown (rc0) and reboot (rc6) with argument "stop".

Make sure that the script will "exit 0" on success or any other

value on error.

In order to enable or disable this script just change the execution

bits.

By default this script does nothing.

sudo ovs-vsctl del-br sw1 sudo tunctl -d s5 > /dev/null sudo tunctl -d s4 > /dev/null sudo tunctl -d s3 > /dev/null sudo tunctl -d s2 > /dev/null sudo tunctl -d s1 > /dev/null

sudo ovs-vsctl del-br sx1 sudo tunctl -d a5 > /dev/null sudo tunctl -d a4 > /dev/null sudo tunctl -d a3 > /dev/null sudo tunctl -d a2 > /dev/null sudo tunctl -d a1 > /dev/null

exit 0 gstanden@P2850A:/etc$ +++ This one will also be a file to be included in ubuntu-host.tar and restored at install time of orabuntu-lxc. Eventually, this will need to get dynamic updates when new interfaces are added, but for now we can just put in all the {sw1, sw2,...sw9, sx1} interfaces so that they are all included and then include this file in the ubuntu-host.tar.

The procedures to follow are as follows:

sudo cp -p /etc/init/rc.local /etc/init/rc.local.bak sudo vi rc.local (replace with the code shown below this list of files) sudo vi /etc/rc.local.startup sudo vi /etc/rc.local.shutdown sudo chmod +x /etc/rc.local.startup sudo chmod +x /etc/rc.local.shutdown sudo /usr/sbin/update-rc.d -f rc.local remove sudo /usr/sbin/update-rc.d rc.local defaults sudo find /etc/rc?.d -iname '*local' sudo mv /etc/rcS.d/S02rc.local /etc/rcS.d/S15rc.local

Here's the script for the new rc.local

! /bin/sh

BEGIN INIT INFO

Provides: rc.local

Required-Start: $local_fs $bootlog

Required-Stop:

Default-Start: S

Default-Stop: 0 6

Short-Description: Run /etc/rc.local if it exist

Description: This script executes commands in /etc/rc.local

at startup, if /etc/rc.local exists and

executes /etc/rc.local.shutdown when the

system goes down for shutdown or reboot.

END INIT INFO

PATH=/sbin:/usr/sbin:/bin:/usr/bin

. /lib/init/vars.sh . /lib/lsb/init-functions

do_start() { if [ -x /etc/rc.local.startup ]; then [ "$VERBOSE" != no ] && log_begin_msg "Running local boot scripts (/etc/rc.local)" /etc/rc.local.startup ES=$? [ "$VERBOSE" != no ] && log_end_msg $ES return $ES fi } do_stop() { if [ -x /etc/rc.local.shutdown ]; then [ "$VERBOSE" != no ] && log_begin_msg "Running local boot scripts (/etc/rc.local)" /etc/rc.local.shutdown ES=$? [ "$VERBOSE" != no ] && log_end_msg $ES return $ES fi }

case "$1" in start) do_start ;; restart|reload|force-reload) echo "Error: argument '$1' not supported" >&2 exit 3 ;; stop) do_stop ;; *) echo "Usage: $0 start|stop" >&2 exit 3 ;; esac