[ovs-dev] ovs-lib: dont't purge corrupted DB

Message ID 20170927134613.7967-1-mcroce@redhat.com
State New
Headers show
Series
  • [ovs-dev] ovs-lib: dont't purge corrupted DB
Related show

Commit Message

Matteo Croce Sept. 27, 2017, 1:46 p.m.
In ovs-lib there is a function named upgrade_db which tries to convert a
database after OVS {up,down}grades. This function uses ovsdb-tool to
check if the DB needs to be upgraded. If the upgrade fails,
it purges the DB and create an empty one.
ovsdb-tool returns "yes" or "no" to indicate if the DB needs upgrading,
but if the DB is corrupted it returns a list of errors.
Change a condition from "!= no" to "= yes" because in case of DB
corruption upgrade_db would purge the existing DB without writing
anything in the logs.

Signed-off-by: Matteo Croce <mcroce@redhat.com>
---
 utilities/ovs-lib.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Mark Michelson Sept. 27, 2017, 9:32 p.m. | #1
LGTM

On Wed, Sep 27, 2017 at 8:46 AM Matteo Croce <mcroce@redhat.com> wrote:

> In ovs-lib there is a function named upgrade_db which tries to convert a
> database after OVS {up,down}grades. This function uses ovsdb-tool to
> check if the DB needs to be upgraded. If the upgrade fails,
> it purges the DB and create an empty one.
> ovsdb-tool returns "yes" or "no" to indicate if the DB needs upgrading,
> but if the DB is corrupted it returns a list of errors.
> Change a condition from "!= no" to "= yes" because in case of DB
> corruption upgrade_db would purge the existing DB without writing
> anything in the logs.
>
> Signed-off-by: Matteo Croce <mcroce@redhat.com>
>
Acked-by: Mark Michelson <mmichels@redhat.com>

> ---
>  utilities/ovs-lib.in | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/utilities/ovs-lib.in b/utilities/ovs-lib.in
> index 8665698bb..ea5a12375 100644
> --- a/utilities/ovs-lib.in
> +++ b/utilities/ovs-lib.in
> @@ -400,7 +400,7 @@ upgrade_db () {
>          log_warning_msg "$DB_FILE does not exist"
>          install_dir `dirname $DB_FILE`
>          create_db "$DB_FILE" "$DB_SCHEMA"
> -    elif test X"`ovsdb_tool needs-conversion "$DB_FILE" "$DB_SCHEMA"`" !=
> Xno; then
> +    elif test X"`ovsdb_tool needs-conversion "$DB_FILE" "$DB_SCHEMA"`" =
> Xyes; then
>          # Back up the old version.
>          version=`ovsdb_tool db-version "$DB_FILE"`
>          cksum=`ovsdb_tool db-cksum "$DB_FILE" | awk '{print $1}'`
> --
> 2.13.5
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>

Patch

diff --git a/utilities/ovs-lib.in b/utilities/ovs-lib.in
index 8665698bb..ea5a12375 100644
--- a/utilities/ovs-lib.in
+++ b/utilities/ovs-lib.in
@@ -400,7 +400,7 @@  upgrade_db () {
         log_warning_msg "$DB_FILE does not exist"
         install_dir `dirname $DB_FILE`
         create_db "$DB_FILE" "$DB_SCHEMA"
-    elif test X"`ovsdb_tool needs-conversion "$DB_FILE" "$DB_SCHEMA"`" != Xno; then
+    elif test X"`ovsdb_tool needs-conversion "$DB_FILE" "$DB_SCHEMA"`" = Xyes; then
         # Back up the old version.
         version=`ovsdb_tool db-version "$DB_FILE"`
         cksum=`ovsdb_tool db-cksum "$DB_FILE" | awk '{print $1}'`