Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2plugin set forward mode when netmaster up #1058

Merged
merged 4 commits into from
Nov 14, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions install/v2plugin/config.template
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@
],
## Do not change the default value, this will be replaced with $CONTIV_V2PLUGIN_NAME
"Value": "__CONTIV_V2PLUGIN_NAME__"
},
{
"Description": "Forwarding mode for netplugin",
"Name": "fwd_mode",
Copy link
Contributor

@rchirakk rchirakk Nov 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check if you need to configure Fabric mode(ACI/default) also here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's fine for now about fabric mode

"Settable": [
"value"
],
"Value": "bridge"
}
],
"mounts": [
Expand Down
29 changes: 25 additions & 4 deletions install/v2plugin/startcontiv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,19 @@
### Pre-requisite on the host
# run a cluster store like etcd or consul

set -eu

if [ $log_dir == "" ]; then
log_dir="/var/log/contiv"
fi
BOOTUP_LOGFILE="$log_dir/plugin_bootup.log"

# Redirect stdout and stdin to BOOTUP_LOGFILE
exec 1<&- # Close stdout
exec 2<&- # Close stderr
exec 1<>$BOOTUP_LOGFILE # stdout read and write to logfile instead of console
exec 2>&1 # redirect stderr to where stdout is (logfile)

mkdir -p $log_dir
mkdir -p /var/run/openvswitch
mkdir -p /etc/openvswitch
Expand All @@ -33,8 +41,6 @@ if [ $vxlan_port != "4789" ]; then
vxlan_port_cfg="-vxlan-port=$vxlan_port"
fi

set -e

echo "Loading OVS" >> $BOOTUP_LOGFILE
(modprobe openvswitch) || (echo "Load ovs FAILED!!! " >> $BOOTUP_LOGFILE)

Expand All @@ -50,7 +56,7 @@ echo " Starting OVSBD server " >> $BOOTUP_LOGFILE
ovsdb-server --remote=punix:/var/run/openvswitch/db.sock --remote=db:Open_vSwitch,Open_vSwitch,manager_options --private-key=db:Open_vSwitch,SSL,private_key --certificate=db:Open_vSwitch,SSL,certificate --bootstrap-ca-cert=db:Open_vSwitch,SSL,ca_cert --log-file=$log_dir/ovs-db.log -vsyslog:dbg -vfile:dbg --pidfile --detach /etc/openvswitch/conf.db >> $BOOTUP_LOGFILE
echo " Starting ovs-vswitchd " >> $BOOTUP_LOGFILE
ovs-vswitchd -v --pidfile --detach --log-file=$log_dir/ovs-vswitchd.log -vconsole:err -vsyslog:info -vfile:info &
ovs-vsctl set-manager tcp:127.0.0.1:6640
ovs-vsctl set-manager tcp:127.0.0.1:6640
ovs-vsctl set-manager ptcp:6640

echo "Started OVS, logs in $log_dir" >> $BOOTUP_LOGFILE
Expand All @@ -77,9 +83,24 @@ if [ $plugin_role == "master" ]; then
sleep 5
echo "Restarting Netmaster " >> $BOOTUP_LOGFILE
done &

echo "Waiting for netmaster to be ready for connections"
# wait till netmaster starts to listen
for i in $(seq 1 10); do
[ "$(curl -s -o /dev/null -w '%{http_code}' $control_url)" != "000" ] \
&& break
sleep 1
done
if [ "$i" -ge "10" ]; then
echo "Failed to set forwarding mode, plugin will fail to enable"
exit 1
fi
sleep 1
echo "Netmaster ready for connections, setting forward mode to $fwd_mode"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a nit, could we exit 1 when $fwd_mode not set ?

/netctl --netmaster http://$control_url global set --fwd-mode "$fwd_mode"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we need to check if fwd mode has been set or if it's allowed to update, or we can check the return code, if it's 5xx then retry, if it's 2xx or 4xx, it might be good to move on

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i did testing, the request is idempotent , as long as it's not changing the mode when there's network, we should be good

echo "Forward mode is set"
else
echo "Not starting netmaster as plugin role is" $plugin_role >> $BOOTUP_LOGFILE
fi

while true; do sleep 1; done