diff mbox series

[ovs-dev,v3] ovs-lib: pass optional --election-timer arg to ovsdb-tool

Message ID bf26bd313a12f155436bbaba06e90566bc018c31.camel@redhat.com
State New
Headers show
Series [ovs-dev,v3] ovs-lib: pass optional --election-timer arg to ovsdb-tool | expand

Commit Message

Dan Williams June 9, 2021, 7:11 p.m. UTC
Signed-off-by: Dan Williams <dcbw@redhat.com>
---
v3: fix line wrapping
v2: put --election-timer arg before create-cluster per Ilya

 utilities/ovs-lib.in | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Dan Williams June 24, 2021, 12:51 a.m. UTC | #1
On Wed, 2021-06-09 at 14:11 -0500, Dan Williams wrote:
> Signed-off-by: Dan Williams <dcbw@redhat.com>
> ---
> v3: fix line wrapping
> v2: put --election-timer arg before create-cluster per Ilya

Ping on this patch?

Thanks!
Dan

> 
>  utilities/ovs-lib.in | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/utilities/ovs-lib.in b/utilities/ovs-lib.in
> index ab38ece458b7b..61a062fa992da 100644
> --- a/utilities/ovs-lib.in
> +++ b/utilities/ovs-lib.in
> @@ -495,15 +495,21 @@ create_cluster () {
>      DB_FILE="$1"
>      DB_SCHEMA="$2"
>      LOCAL_ADDR="$3"
> +    ELECTION_TIMER_MS="$4"
> +
> +    election_timer_arg=
> +    if [ -n "$ELECTION_TIMER_MS" ]; then
> +      election_timer_arg="--election-timer=$ELECTION_TIMER_MS"
> +    fi
>  
>      if test ! -e "$DB_FILE"; then
> -        action "Creating cluster database $DB_FILE" ovsdb_tool
> create-cluster "$DB_FILE" "$DB_SCHEMA" "$LOCAL_ADDR"
> +        action "Creating cluster database $DB_FILE" ovsdb_tool
> "$election_timer_arg" create-cluster "$DB_FILE" "$DB_SCHEMA"
> "$LOCAL_ADDR"
>      elif ovsdb_tool db-is-standalone "$DB_FILE"; then
>          # Convert standalone database to clustered.
>          backup_db || return 1
>          rm -f "$DB_FILE"
>          action "Creating cluster database $DB_FILE from existing
> one" \
> -               ovsdb_tool create-cluster "$DB_FILE" "$backup"
> "$LOCAL_ADDR"
> +               ovsdb_tool "$election_timer_arg" create-cluster
> "$DB_FILE" "$backup" "$LOCAL_ADDR"
>      fi
>  }
>
Ben Pfaff June 24, 2021, 9:58 p.m. UTC | #2
On Wed, Jun 09, 2021 at 02:11:42PM -0500, Dan Williams wrote:
> Signed-off-by: Dan Williams <dcbw@redhat.com>
> ---
> v3: fix line wrapping
> v2: put --election-timer arg before create-cluster per Ilya
> 
>  utilities/ovs-lib.in | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/utilities/ovs-lib.in b/utilities/ovs-lib.in
> index ab38ece458b7b..61a062fa992da 100644
> --- a/utilities/ovs-lib.in
> +++ b/utilities/ovs-lib.in
> @@ -495,15 +495,21 @@ create_cluster () {
>      DB_FILE="$1"
>      DB_SCHEMA="$2"
>      LOCAL_ADDR="$3"
> +    ELECTION_TIMER_MS="$4"
> +
> +    election_timer_arg=
> +    if [ -n "$ELECTION_TIMER_MS" ]; then
> +      election_timer_arg="--election-timer=$ELECTION_TIMER_MS"
> +    fi
>  
>      if test ! -e "$DB_FILE"; then
> -        action "Creating cluster database $DB_FILE" ovsdb_tool create-cluster "$DB_FILE" "$DB_SCHEMA" "$LOCAL_ADDR"
> +        action "Creating cluster database $DB_FILE" ovsdb_tool "$election_timer_arg" create-cluster "$DB_FILE" "$DB_SCHEMA" "$LOCAL_ADDR"

Won't this give ovsdb-tool indigestion by passing a "" argument if
there's no election timer?  I think that $election_timer_arg needs to be
unquoted.

Similar issue below.
diff mbox series

Patch

diff --git a/utilities/ovs-lib.in b/utilities/ovs-lib.in
index ab38ece458b7b..61a062fa992da 100644
--- a/utilities/ovs-lib.in
+++ b/utilities/ovs-lib.in
@@ -495,15 +495,21 @@  create_cluster () {
     DB_FILE="$1"
     DB_SCHEMA="$2"
     LOCAL_ADDR="$3"
+    ELECTION_TIMER_MS="$4"
+
+    election_timer_arg=
+    if [ -n "$ELECTION_TIMER_MS" ]; then
+      election_timer_arg="--election-timer=$ELECTION_TIMER_MS"
+    fi
 
     if test ! -e "$DB_FILE"; then
-        action "Creating cluster database $DB_FILE" ovsdb_tool create-cluster "$DB_FILE" "$DB_SCHEMA" "$LOCAL_ADDR"
+        action "Creating cluster database $DB_FILE" ovsdb_tool "$election_timer_arg" create-cluster "$DB_FILE" "$DB_SCHEMA" "$LOCAL_ADDR"
     elif ovsdb_tool db-is-standalone "$DB_FILE"; then
         # Convert standalone database to clustered.
         backup_db || return 1
         rm -f "$DB_FILE"
         action "Creating cluster database $DB_FILE from existing one" \
-               ovsdb_tool create-cluster "$DB_FILE" "$backup" "$LOCAL_ADDR"
+               ovsdb_tool "$election_timer_arg" create-cluster "$DB_FILE" "$backup" "$LOCAL_ADDR"
     fi
 }