[ovs-dev] [patch v1] ovn: ovn-ctl support to start ovn db servers in backup mode
Numan Siddique
nusiddiq at redhat.com
Thu Sep 1 11:31:31 UTC 2016
On Thu, Sep 1, 2016 at 3:29 PM, Numan Siddique <nusiddiq at redhat.com> wrote:
>
>
> On Thu, Sep 1, 2016 at 10:51 AM, <bschanmu at redhat.com> wrote:
>
>> From: Babu Shanmugam <bschanmu at redhat.com>
>>
>> This patch adds support to start_ovsdb() function in ovn-ctl to start the
>> ovn db servers in backup mode. This can be done in the following ways
>> 1. Use parameters --ovn-nb-sync-from-addr and --ovn-sb-sync-from-addr to
>> set the addresses of the active server.
>> 2. Create files $etcdir/ovnnb-active.conf and $etcdir/ovnsb-active.conf
>> with the tcp url of the active servers.
>>
>> If --ovn-nb-sync-from-addr and --ovn-sb-sync-from-addr is used, it will
>> overwrite the contents in the $etcdir/*.conf and use that server as the
>> active server.
>>
>> Additional functions to promote a backup server to active and demote
>> active server to backup mode are also added in this patch
>>
>> Signed-off-by: Babu Shanmugam <bschanmu at redhat.com>
>> ---
>> ovn/utilities/ovn-ctl | 75 ++++++++++++++++++++++++++++++
>> +++++++++++++++++++++
>> 1 file changed, 75 insertions(+)
>>
>> diff --git a/ovn/utilities/ovn-ctl b/ovn/utilities/ovn-ctl
>> index a4a9817..54c2a72 100755
>> --- a/ovn/utilities/ovn-ctl
>> +++ b/ovn/utilities/ovn-ctl
>> @@ -26,6 +26,8 @@ for dir in "$sbindir" "$bindir" /sbin /bin /usr/sbin
>> /usr/bin; do
>> done
>>
>>
>> +ovnnb_active_conf_file="$etcdir/ovnnb-active.conf"
>> +ovnsb_active_conf_file="$etcdir/ovnsb-active.conf"
>> ## ----- ##
>> ## start ##
>> ## ----- ##
>> @@ -45,6 +47,42 @@ stop_ovsdb () {
>> fi
>> }
>>
>> +promote_ovnnb() {
>>
>
> I think this function is setting the ovsdb-server to backup which is not
> a promotion, rather its demotion.
> I think better name would be to use "set_active" or something similar.
> Calling the unixctl command "
>
> ovsdb-server/
>
>
> disconnect-active-ovsdb-server
> " would make the ovsdb-server to active (if it was in the backup state
> earlier).
>
>
>
> + if test ! -z "$DB_NB_SYNC_FROM_ADDR"; then
>> + echo "tcp:$DB_NB_SYNC_FROM_ADDR:$DB_NB_SYNC_FROM_PORT" >
>> $ovnnb_active_conf_file
>> + fi
>> +
>> + if test -e $ovnnb_active_conf_file; then
>> + ovs-appctl -t $rundir/ovnnb_db.ctl
>>
>> ovsdb-server/set-active-ovsdb-server `cat $ovnnb_active_conf_file`
>> + else
>> + echo >&2 "$0: active server details not set"
>> + exit 1
>> + fi
>> +}
>> +
>> +promote_ovnsb() {
>> + if test ! -z "$DB_SB_SYNC_FROM_ADDR"; then
>> + echo "tcp:$DB_SB_SYNC_FROM_ADDR:$DB_SB_SYNC_FROM_PORT" >
>> $ovnsb_active_conf_file
>> + fi
>> +
>> + if test -e $ovnsb_active_conf_file; then
>> + ovs-appctl -t $rundir/ovnsb_db.ctl
>>
>> ovsdb-server/set-active-ovsdb-server `cat $ovnsb_active_conf_file`
>> + else
>> + echo >&2 "$0: active server details not set"
>> + exit 1
>> + fi
>> +}
>> +
>> +demote_ovnnb() {
>>
>
> Similar comment as above. Its better to rename this function to
> "set_backup" or something similar.
> Calling the unixctl commands
>
> "
>
>
> ovsdb-server/set-active-ovsdb-server
> " followed by "
>
> ovsdb-server/
>
>
> connect-active-ovsdb-server" should make the ovsdb-server to act as a
> backup server. Calling only "
>
> ovsdb-server/set-active-ovsdb-server
> " will not connect to the active server.
>
>
>
> + rm -f $ovnnb_active_conf_file
>> + ovs-appctl -t $rundir/ovnnb_db.ctl ovsdb-server/
>>
>> disconnect-active-ovsdb-server
>> +}
>> +
>> +demote_ovnsb() {
>> + rm -f $ovnsb_active_conf_file
>> + ovs-appctl -t $rundir/ovnsb_db.ctl ovsdb-server/
>>
>> disconnect-active-ovsdb-server
>> +}
>> +
>> start_ovsdb () {
>> # Check and eventually start ovsdb-server for Northbound DB
>> if ! pidfile_is_running $DB_NB_PID; then
>> @@ -54,6 +92,14 @@ start_ovsdb () {
>>
>> set "$@" --detach $OVN_NB_LOG --log-file=$OVN_NB_LOGFILE
>> --remote=punix:$DB_NB_SOCK --remote=ptcp:$DB_NB_PORT:$DB_NB_ADDR
>> --pidfile=$DB_NB_PID --unixctl=ovnnb_db.ctl
>>
>> + if test ! -z "$
>>
>> DB_NB_SYNC_FROM_ADDR"; then
>> + echo "tcp:$DB_NB_SYNC_FROM_ADDR:$DB_NB_SYNC_FROM_PORT" >
>> $ovnnb_active_conf_file
>>
>
>
> It is also possible that we can start ovsdb-server as active and then
> transition to backup. So it would be better to honor the variables
>
> "
>
> DB_NB
> /SB
> _SYNC_FROM_ADDR
> "
>
> and "
>
> DB_NB
> /SB
> _SYNC_
> FROM_PORT"
>
> in the promote and demote functions. In the case of pacemaker resources,
> if proper preference constraints are not set, pacemaker/or any other HA
> manager can choose any one node as master after starting the resources. And
> when a new master is chosen, the other slaves should reconnect to the new
> master. so the client of this script can call demote (or set_backup)
> function setting these variables properly.
>
>
Sorry for this comment. I see that these variables are indeed used in the
demote function
>
>> + fi
>> +
>> + if test -e $ovnnb_active_conf_file; then
>> + set "$@" --sync-from=`cat $ovnnb_active_conf_file`
>> + fi
>> +
>> $@ $DB_NB_FILE
>> fi
>>
>> @@ -64,6 +110,15 @@ start_ovsdb () {
>> set ovsdb-server
>>
>> set "$@" --detach $OVN_SB_LOG --log-file=$OVN_SB_LOGFILE
>> --remote=punix:$DB_SB_SOCK --remote=ptcp:$DB_SB_PORT:$DB_SB_ADDR
>> --pidfile=$DB_SB_PID --unixctl=ovnsb_db.ctl
>> +
>> + if test ! -z "$DB_SB_SYNC_FROM_ADDR"; then
>> + echo "tcp:$DB_SB_SYNC_FROM_ADDR:$DB_SB_SYNC_FROM_PORT" >
>> $ovnsb_active_conf_file
>> + fi
>> +
>> + if test -e $ovnsb_active_conf_file; then
>> + set "$@" --sync-from=`cat $ovnsb_active_conf_file`
>> + fi
>> +
>> $@ $DB_SB_FILE
>> fi
>> }
>> @@ -176,12 +231,16 @@ set_defaults () {
>> DB_NB_FILE=$dbdir/ovnnb_db.db
>> DB_NB_ADDR=0.0.0.0
>> DB_NB_PORT=6641
>> + DB_NB_SYNC_FROM_ADDR=
>> + DB_NB_SYNC_FROM_PORT=6641
>>
>> DB_SB_SOCK=$rundir/ovnsb_db.sock
>> DB_SB_PID=$rundir/ovnsb_db.pid
>> DB_SB_FILE=$dbdir/ovnsb_db.db
>> DB_SB_ADDR=0.0.0.0
>> DB_SB_PORT=6642
>> + DB_SB_SYNC_FROM_ADDR=
>> + DB_SB_SYNC_FROM_PORT=6642
>>
>> DB_NB_SCHEMA=$datadir/ovn-nb.ovsschema
>> DB_SB_SCHEMA=$datadir/ovn-sb.ovsschema
>> @@ -272,6 +331,10 @@ File location options:
>> --db-sb-port=PORT OVN Southbound db ptcp port (default: $DB_SB_PORT)
>> --ovn-nb-logfile=FILE OVN Northbound log file (default:
>> $OVN_NB_LOGFILE)
>> --ovn-sb-logfile=FILE OVN Southbound log file (default:
>> $OVN_SB_LOGFILE)
>> + --db-nb-sync-from-addr=ADDR OVN Northbound active db tcp address
>> (default: $DB_NB_SYNC_FROM_ADDR)
>> + --db-nb-sync-from-port=PORT OVN Northdbound active db tcp port
>> (default: $DB_NB_SYNC_FROM_PORT)
>> + --db-sb-sync-from-addr=ADDR OVN Southbound active db tcp address
>> (default: $DB_SB_SYNC_FROM_ADDR)
>> + --db-sb-sync-from-port=ADDR OVN Southbound active db tcp port
>> (default: $DB_SB_SYNC_FROM_PORT)
>>
>> Default directories with "configure" option and environment variable
>> override:
>> logs: /usr/local/var/log/openvswitch (--with-logdir, OVS_LOGDIR)
>> @@ -377,6 +440,18 @@ case $command in
>> status_controller_vtep)
>> daemon_status ovn-controller-vtep || exit 1
>> ;;
>> + promote_ovnnb)
>> + promote_ovnnb
>> + ;;
>> + promote_ovnsb)
>> + promote_ovnsb
>> + ;;
>> + demote_ovnnb)
>> + demote_ovnnb
>> + ;;
>> + demote_ovnsb)
>> + demote_ovnsb
>> + ;;
>> help)
>> usage
>> ;;
>> --
>> 1.9.1
>>
>> _______________________________________________
>> dev mailing list
>> dev at openvswitch.org
>> http://openvswitch.org/mailman/listinfo/dev
>>
>
>
More information about the dev
mailing list