From patchwork Fri Jul 10 08:18:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Federico Paolinelli X-Patchwork-Id: 1326547 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=g4V6pllH; dkim-atps=neutral Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B35YJ4cFbz9sRK for ; Fri, 10 Jul 2020 18:19:16 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id F41EC88830; Fri, 10 Jul 2020 08:19:14 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sPCPTAbhvnho; Fri, 10 Jul 2020 08:19:12 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by fraxinus.osuosl.org (Postfix) with ESMTP id AA14C87269; Fri, 10 Jul 2020 08:19:12 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 99CA7C0865; Fri, 10 Jul 2020 08:19:12 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 8F8B8C016F for ; Fri, 10 Jul 2020 08:19:11 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 7B00F20475 for ; Fri, 10 Jul 2020 08:19:11 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Pzjmzv5WGwFA for ; Fri, 10 Jul 2020 08:19:09 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by silver.osuosl.org (Postfix) with ESMTPS id 44AB520BF9 for ; Fri, 10 Jul 2020 08:19:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594369148; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=7nKLV3arxJbxGL/ZwIiU0h1MYfy/qSCjUUoAc2DvaCM=; b=g4V6pllHDdYvbl7Jux/wSmrsSS7fDMLI6xq2zfy8aAJCA1k+XjCYU9zNMJII7KroFyN2s/ /F4NsKaZN3OUzwx0f+Gs6rmuuvM8PIesV+vfRe/Hv0h/gz/JXH4OZV6hhurRzZ+9mCIdb5 KAX4jqnebPmEZgY4wD/tFvdBqAs0nDI= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-115-q3ERmMRcOgm2okQSz13RcA-1; Fri, 10 Jul 2020 04:19:06 -0400 X-MC-Unique: q3ERmMRcOgm2okQSz13RcA-1 Received: by mail-ed1-f70.google.com with SMTP id g18so5800180edu.22 for ; Fri, 10 Jul 2020 01:19:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=7nKLV3arxJbxGL/ZwIiU0h1MYfy/qSCjUUoAc2DvaCM=; b=F/Dp85QOHq0LeWi+vMTCDYJCKszitfq4hHaMOqQR+OnZxcSUf2PhKzXfxhXw1YGays kj1GhXSn3Sgz6PYajGBDbJIjo42B4de5UnDeBeeyVReBI3+H9uxSHvzJdoEuN0zoxjKT ww35rpKqUJTL9kedYy42LPfExwB8285JUa+00oQOCmHOdxtudJqtvbDgLGYQEcHdYN88 hEvUTMHsURtBI4sl/285hOVrDRxRTV/amKR8ncOljkj6PoiPDHVS1aWV2j1FQcq02Mqg RFbvc1xbP/D6fXQ+pbQBG7UKwJ5CUitHL5py/Wg4nlqEyzrqmZzrc59KpGiHUM5r1K7k f/SA== X-Gm-Message-State: AOAM532UhGAFgVYocn6zBdIzHmsHwjzXzi+0c6ZUt6YdGEcZcYmvZDqW VAbDKqfhOvBWOs8GnU7MAKRIzg+zX8O2WtXKcA9pwExu5gOJ4m87jl88n8ybodKXOPtCosspC4d bra2lg9XcPtCU0c4on01b6QQwjYZR X-Received: by 2002:aa7:c655:: with SMTP id z21mr76481978edr.330.1594369144760; Fri, 10 Jul 2020 01:19:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNNlODnUSxKOdmLpB6PBVYJhnWqv15wcP0BDr3s0ILsR3NR5j/+ynrym3rcP//FZUqPcuedQVhKsWVhO1ttks= X-Received: by 2002:aa7:c655:: with SMTP id z21mr76481957edr.330.1594369144453; Fri, 10 Jul 2020 01:19:04 -0700 (PDT) MIME-Version: 1.0 From: Federico Paolinelli Date: Fri, 10 Jul 2020 10:18:53 +0200 Message-ID: To: dev@openvswitch.org Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=fpaoline@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: [ovs-dev] [PATCH v3] ovsdb-tool: Add a db consistency check to the ovsdb-tool check-cluster command X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" There are some occurrences where the database ends up in an inconsistent state. This happened in ovn-k8s and is described in [0]. Here we are adding a supported way to check that a given db is consistent, which is less error prone than checking the logs. Tested against both a valid db and a corrupted db attached to the above bug [1]. [0]: https://bugzilla.redhat.com/show_bug.cgi?id=1837953#c23 [1]: https://bugzilla.redhat.com/attachment.cgi?id=1697595 Signed-off-by: Federico Paolinelli Suggested-by: Dumitru Ceara Acked-by: Dumitru Ceara --- ovsdb/ovsdb-tool.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/ovsdb/ovsdb-tool.c b/ovsdb/ovsdb-tool.c index 91662cab8..016a3ba28 100644 --- a/ovsdb/ovsdb-tool.c +++ b/ovsdb/ovsdb-tool.c @@ -1497,6 +1497,28 @@ do_check_cluster(struct ovs_cmdl_context *ctx) } } + /* Check for db consistency: + * The serverid must be in the servers list. + */ + + for (struct server *s = c.servers; s < &c.servers[c.n_servers]; s++) { + struct shash *servers_obj = json_object(s->snap->servers); + char *server_id = xasprintf(SID_FMT, SID_ARGS(&s->header.sid)); + bool found = false; + const struct shash_node *node; + + SHASH_FOR_EACH (node, servers_obj) { + if (!strncmp(server_id, node->name, SID_LEN)) { + found = true; + } + } + if (!found) { + ovs_fatal(0, "%s: server %s not found in server list", + s->filename, server_id); + } + free(server_id); + } + /* Clean up. */ for (size_t i = 0; i < c.n_servers; i++) {