From patchwork Wed Sep 27 13:46:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matteo Croce X-Patchwork-Id: 819165 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y2Jy93pc8z9sRm for ; Wed, 27 Sep 2017 23:46:23 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 1E586A7B; Wed, 27 Sep 2017 13:46:19 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 8E979A48 for ; Wed, 27 Sep 2017 13:46:17 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr0-f175.google.com (mail-wr0-f175.google.com [209.85.128.175]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id F05651A6 for ; Wed, 27 Sep 2017 13:46:16 +0000 (UTC) Received: by mail-wr0-f175.google.com with SMTP id m18so16566073wrm.2 for ; Wed, 27 Sep 2017 06:46:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=WKGgsbagItDm8KR+1UA8sjfkE6rctBMdIgmHQNW+evY=; b=Qs9fNFqk9RsKy7EbokutixDYWGepiD1NPmv4XSrUQHXoN8/U8mwMMKDvXZs7+x/O3T yWMMWvxjwpbXIYfHpbD6f2243MQBrdc6ivGfKY9SYaffQ4LpYq4N7r7DVN9bbnYXIRLw oTNVtM6RXOzBTIsrrL2KWdkSQ5SfhEV8y7O5Ei9i9lQM9SHGItUc85SJQ8tVwTQk+rY9 hGaqhb1AnQ21PNpti5252h1EKpH3DbBblggB3egI5sAkomd7BEnhjWvySzcsmZAA5nvj YmN6aGacRG8+5rw/hIlZdCvshJV4ucDBnyuwy9yjhYHan18xLL+NBJF/PUfyObElPt3N /Tww== X-Gm-Message-State: AHPjjUj9SqWR6iJQPzogPVBv9juLE8gsZhEYwSWx/IqIpBVtiNberhNz MnMSGMhMYtgPpmytDbFxz8+cUvM8zUI= X-Google-Smtp-Source: AOwi7QAqFTerNdwJQgvsLb0uQEsmNeCUiY3lC4yV56Q/ahS3fpCyFsmxermk0vOLAH3yi9Y4s6L6RQ== X-Received: by 10.223.133.65 with SMTP id 59mr1620387wrh.233.1506519975214; Wed, 27 Sep 2017 06:46:15 -0700 (PDT) Received: from mcroce.mxp.redhat.com (nat-pool-mxp-t.redhat.com. [149.6.153.186]) by smtp.gmail.com with ESMTPSA id 64sm4402928wma.21.2017.09.27.06.46.14 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 27 Sep 2017 06:46:14 -0700 (PDT) From: Matteo Croce To: dev@openvswitch.org Date: Wed, 27 Sep 2017 15:46:13 +0200 Message-Id: <20170927134613.7967-1-mcroce@redhat.com> X-Mailer: git-send-email 2.13.5 X-Spam-Status: No, score=0.5 required=5.0 tests=RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM autolearn=disabled version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH] ovs-lib: dont't purge corrupted DB X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org 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 Acked-by: Mark Michelson --- 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}'`