From patchwork Mon Apr 12 15:10:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 1465323 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.136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) 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=exLX1PVS; dkim-atps=neutral Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FJsc84TNSz9rx6 for ; Tue, 13 Apr 2021 01:10:16 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 1D99160A98; Mon, 12 Apr 2021 15:10:15 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id H7UXoggoNiNB; Mon, 12 Apr 2021 15:10:14 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTP id 593BB60658; Mon, 12 Apr 2021 15:10:13 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 172D9C000B; Mon, 12 Apr 2021 15:10:13 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists.linuxfoundation.org (Postfix) with ESMTP id DF494C000A for ; Mon, 12 Apr 2021 15:10:11 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id B25E882B84 for ; Mon, 12 Apr 2021 15:10:11 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp1.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TTeda2aRMgwI for ; Mon, 12 Apr 2021 15:10:11 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp1.osuosl.org (Postfix) with ESMTPS id EE6EC82B1E for ; Mon, 12 Apr 2021 15:10:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618240209; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5lIGHH/Vc26MkbECHzoqPo8Ap489933PpR2mVe/8G9A=; b=exLX1PVSKEPL+FA4oiNYeKQHWGHjKBkFD4D9JVqRuFJgbIDys/SN1vCFfRzKJi42l2kTVP mkiX3EomIvh1wfZ2XP5AzHnLQebifc9JWs6DugbldyhIm0YZJmyFX/j3j2KPG7QzfpTSvY X3joCQGdbvctKdz5d6DioRXpC73VJqA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-262-49Xp1ZTNOrOfI1g0Toz46A-1; Mon, 12 Apr 2021 11:10:04 -0400 X-MC-Unique: 49Xp1ZTNOrOfI1g0Toz46A-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 355BA801814 for ; Mon, 12 Apr 2021 15:10:04 +0000 (UTC) Received: from [10.10.110.44] (unknown [10.10.110.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id B3768101E663 for ; Mon, 12 Apr 2021 15:10:03 +0000 (UTC) Message-ID: <76637a18fa98c21d00454f09957bb8b93a8f1bfb.camel@redhat.com> From: Dan Williams To: dev@openvswitch.org Date: Mon, 12 Apr 2021 10:10:02 -0500 In-Reply-To: References: User-Agent: Evolution 3.38.4 (3.38.4-1.fc33) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dcbw@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn v2 1/2] ovn-lib: harmonize stop_ovn_daemon() with ovs-lib 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" OVN should probably be doing the same things OVS is doing here. Signed-off-by: Dan Williams --- utilities/ovn-lib.in | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/utilities/ovn-lib.in b/utilities/ovn-lib.in index 016815626fc7f..bd04d0e86322f 100644 --- a/utilities/ovn-lib.in +++ b/utilities/ovn-lib.in @@ -159,20 +159,36 @@ stop_ovn_daemon () { if version_geq "$version" "2.5.90"; then actions="$graceful $actions" fi + actiontype="" for action in $actions; do if pid_exists "$pid" >/dev/null 2>&1; then :; else - return 0 + # pid does not exist. + if [ -n "$actiontype" ]; then + return 0 + fi + # But, does the file exist? We may have had a daemon + # segfault with `ovs-appctl exit`. Check one more time + # before deciding that the daemon is dead. + [ -e "$ovn_rundir/$1.pid" ] && sleep 2 && pid=`cat "$ovn_rundir/$1.pid"` 2>/dev/null + if pid_exists "$pid" >/dev/null 2>&1; then :; else + return 0 + fi fi case $action in EXIT) action "Exiting $1 ($pid)" \ ${bindir}/ovs-appctl -T 1 -t $ovn_rundir/$1.$pid.ctl exit $2 + # The above command could have resulted in delayed + # daemon segfault. And if a monitor is running, it + # would restart the daemon giving it a new pid. ;; TERM) action "Killing $1 ($pid)" kill $pid + actiontype="force" ;; KILL) action "Killing $1 ($pid) with SIGKILL" kill -9 $pid + actiontype="force" ;; FAIL) log_failure_msg "Killing $1 ($pid) failed" From patchwork Mon Apr 12 15:10:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 1465324 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=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) 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=ZN561jNA; dkim-atps=neutral Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FJsct6CwYz9rx6 for ; Tue, 13 Apr 2021 01:10:54 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id C93998356E; Mon, 12 Apr 2021 15:10:52 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xbMg6k41alMI; Mon, 12 Apr 2021 15:10:51 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTP id 1207282C33; Mon, 12 Apr 2021 15:10:51 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id DE68EC000B; Mon, 12 Apr 2021 15:10:50 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 76799C000A for ; Mon, 12 Apr 2021 15:10:49 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 591184040E for ; Mon, 12 Apr 2021 15:10:49 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp2.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id smS03jsIGjQR for ; Mon, 12 Apr 2021 15:10:48 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp2.osuosl.org (Postfix) with ESMTPS id 5059C40001 for ; Mon, 12 Apr 2021 15:10:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618240247; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8fzKc35xXUhU18aOeWS51BEuI6VtDh59R7I/Y+m03Xk=; b=ZN561jNAnKbw3XENqbDXehhweZ4Sdiix06p7GHcr9LC7FFWpmFRW7Rn+yEMRIn+oPjoppr pNJCcjQo1sUP7mu/APdNbDiu/Y5mXkvANTRDHpz1MdVggkr2clFcBe8Lt9yIMO42Y6bVdU UUPDFHvSbCWMuuLtx6SrfmGv5vkNgrQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-322-TGTBOgE5NuyYC6iJxbH2RA-1; Mon, 12 Apr 2021 11:10:45 -0400 X-MC-Unique: TGTBOgE5NuyYC6iJxbH2RA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0EC4E83DD21 for ; Mon, 12 Apr 2021 15:10:45 +0000 (UTC) Received: from [10.10.110.44] (unknown [10.10.110.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7F8AA60240 for ; Mon, 12 Apr 2021 15:10:44 +0000 (UTC) Message-ID: <3d42545114d22c11f5ea4f8270dc243533cae0b1.camel@redhat.com> From: Dan Williams To: dev@openvswitch.org Date: Mon, 12 Apr 2021 10:10:43 -0500 In-Reply-To: References: User-Agent: Evolution 3.38.4 (3.38.4-1.fc33) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dcbw@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn v2 2/2] ovn-ctl: stop databases with stop_ovn_daemon() 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" Wait for the databases to actually exit before returning to the caller of ovn-ctl. In containerized use-cases the container runtime often kills the container when the process calling ovn-ctl exits, which may not give the DBs time to clean up after themselves. Reported-at: https://bugzilla.redhat.com/1944239 Signed-off-by: Dan Williams --- utilities/ovn-ctl | 16 +++++----------- utilities/ovn-lib.in | 24 ++++++++++++++++++------ 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/utilities/ovn-ctl b/utilities/ovn-ctl index 359c9c78afda2..ff61f21d0614a 100755 --- a/utilities/ovn-ctl +++ b/utilities/ovn-ctl @@ -45,18 +45,12 @@ pidfile_is_running () { test -e "$pidfile" && [ -s "$pidfile" ] && pid=`cat "$pidfile"` && pid_exists "$pid" } >/dev/null 2>&1 -stop_xx_ovsdb() { - if pidfile_is_running $1; then - ovn-appctl -t $OVN_RUNDIR/$2 exit - fi -} - stop_nb_ovsdb() { - stop_xx_ovsdb $DB_NB_PID ovnnb_db.ctl + OVS_RUNDIR=${OVS_RUNDIR} stop_ovn_daemon ovnnb_db $DB_NB_PID $OVN_RUNDIR/ovnnb_db.ctl } stop_sb_ovsdb() { - stop_xx_ovsdb $DB_SB_PID ovnsb_db.ctl + OVS_RUNDIR=${OVS_RUNDIR} stop_ovn_daemon ovnsb_db $DB_SB_PID $OVN_RUNDIR/ovnsb_db.ctl } stop_ovsdb () { @@ -65,11 +59,11 @@ stop_ovsdb () { } stop_ic_nb_ovsdb() { - stop_xx_ovsdb $DB_IC_NB_PID ovn_ic_nb_db.ctl + OVS_RUNDIR=${OVS_RUNDIR} stop_ovn_daemon ovn_ic_nb_db $DB_IC_NB_PID $OVN_RUNDIR/ovn_ic_nb_db.ctl } stop_ic_sb_ovsdb() { - stop_xx_ovsdb $DB_IC_SB_PID ovn_ic_sb_db.ctl + OVS_RUNDIR=${OVS_RUNDIR} stop_ovn_daemon ovn_ic_sb_db $DB_IC_SB_PID $OVN_RUNDIR/ovn_ic_sb_db.ctl } stop_ic_ovsdb () { @@ -590,7 +584,7 @@ stop_ic () { } stop_controller () { - OVS_RUNDIR=${OVS_RUNDIR} stop_ovn_daemon ovn-controller "$@" + OVS_RUNDIR=${OVS_RUNDIR} stop_ovn_daemon ovn-controller "" "" "$@" } stop_controller_vtep () { diff --git a/utilities/ovn-lib.in b/utilities/ovn-lib.in index bd04d0e86322f..301cc57125f62 100644 --- a/utilities/ovn-lib.in +++ b/utilities/ovn-lib.in @@ -137,10 +137,22 @@ start_ovn_daemon () { } stop_ovn_daemon () { - if test -e "$ovn_rundir/$1.pid"; then - if pid=`cat "$ovn_rundir/$1.pid"`; then + local pid_file=$2 + local ctl_file=$3 + local other_args=$4 + + if [ -z "$pid_file" ]; then + pid_file="$ovn_rundir/$1.pid" + fi + + if test -e "$pid_file"; then + if pid=`cat "$pid_file"`; then + if [ -z "$ctl_file" ]; then + ctl_file="$ovn_rundir/$1.$pid.ctl" + fi + if pid_exists "$pid" >/dev/null 2>&1; then :; else - rm -f $ovn_rundir/$1.$pid.ctl $ovn_rundir/$1.$pid + rm -f $ctl_file $pid_file return 0 fi @@ -148,7 +160,7 @@ stop_ovn_daemon () { actions="TERM .1 .25 .65 1 1 1 1 \ KILL 1 1 1 2 10 15 30 \ FAIL" - version=`ovs-appctl -T 1 -t $ovn_rundir/$1.$pid.ctl version \ + version=`ovs-appctl -T 1 -t $ctl_file version \ | awk 'NR==1{print $NF}'` # Use `ovs-appctl exit` only if the running daemon version @@ -169,7 +181,7 @@ stop_ovn_daemon () { # But, does the file exist? We may have had a daemon # segfault with `ovs-appctl exit`. Check one more time # before deciding that the daemon is dead. - [ -e "$ovn_rundir/$1.pid" ] && sleep 2 && pid=`cat "$ovn_rundir/$1.pid"` 2>/dev/null + [ -e "$pid_file" ] && sleep 2 && pid=`cat "$pid_file"` 2>/dev/null if pid_exists "$pid" >/dev/null 2>&1; then :; else return 0 fi @@ -177,7 +189,7 @@ stop_ovn_daemon () { case $action in EXIT) action "Exiting $1 ($pid)" \ - ${bindir}/ovs-appctl -T 1 -t $ovn_rundir/$1.$pid.ctl exit $2 + ${bindir}/ovs-appctl -T 1 -t $ctl_file exit $other_args # The above command could have resulted in delayed # daemon segfault. And if a monitor is running, it # would restart the daemon giving it a new pid.