From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 029A443262; Wed, 1 Nov 2023 17:57:58 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EE7F9402C7; Wed, 1 Nov 2023 17:57:57 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 42DE2400EF for ; Wed, 1 Nov 2023 17:57:56 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698857875; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kRC6k68B+oS87LvwqUYo2ji1OqECsXAc75ot2WLwe8I=; b=ZFuCRHP+DVo6P5tuizmAiwv7Vu98kXqBzho+6dmir9aUBUiyoTXxfdYQL/dMrERHMKzER5 aCqTVzpB+MT38OXthQaI80UAv1PjJ7tik/UZaqpLOvPWmJW9fqwzzzM2FgypCNtZZT3W0w KHUTwAvT1QsNlzugmNQcXiAGhUlXSAU= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-451-fhV_UwhRPdeix4FVV0O9vA-1; Wed, 01 Nov 2023 12:57:50 -0400 X-MC-Unique: fhV_UwhRPdeix4FVV0O9vA-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-9d31e27d0bfso1474666b.0 for ; Wed, 01 Nov 2023 09:57:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698857870; x=1699462670; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kRC6k68B+oS87LvwqUYo2ji1OqECsXAc75ot2WLwe8I=; b=Z8tgdWXeP4YBjcfWAiGwYDYtcEfju6nPiO6lX7QDSGo+roCi8cVjjN86Cz/P3Cgdq4 KCNXyv4tBy0vmtaTaGAsNoNgV9lQsGfF6eeja+j2t58dUBhPCCiVTa1lUlaubGFwYaua 948iFX8YIjwklH0Ocvr6HiUpHJUnzo243cSn8dNmUy6pIAlxhvegzhiHRI42gTi1V8M5 MSA7ruzr8FSY+BxpRTspbOj/zrX3LspT4CEEIzpjyh3TeRur8r5pJlMNyAjCCZHVcYwc xUQwojU86v1P7i0L4U2AFxpc6td6WWUpUk4YM8Vim2XsG2Nk7RVgLMnka23GLbyPjqjh yYsg== X-Gm-Message-State: AOJu0YxYLOMadRuwyKKT/nRZWdAFVx11AtjRdyJ4lhk5a806V9anIVaZ hPj2GNjZKCdMuLgr2BorMjEWMUWPf1EVvXlteu8m1Vjv8oQSgYYnx0U7T54h5+p+a4FqYFlCkvc EPI5ZPAyqnAU/cZXbnQ== X-Received: by 2002:a17:907:a44:b0:9be:b668:5700 with SMTP id be4-20020a1709070a4400b009beb6685700mr2306175ejc.58.1698857869798; Wed, 01 Nov 2023 09:57:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFAUUn5mDddHok0a8ysO7TQ6OTAulFkaqr89ZBI1q+DluISpeCuQAsdN1bBMr/aX+42lUfNTwxQwgfFHzZqdxU= X-Received: by 2002:a17:907:a44:b0:9be:b668:5700 with SMTP id be4-20020a1709070a4400b009beb6685700mr2306163ejc.58.1698857869383; Wed, 01 Nov 2023 09:57:49 -0700 (PDT) MIME-Version: 1.0 References: <20231027130609.3035396-1-aconole@redhat.com> <20231027130609.3035396-2-aconole@redhat.com> In-Reply-To: <20231027130609.3035396-2-aconole@redhat.com> From: Michael Santana Date: Wed, 1 Nov 2023 12:57:37 -0400 Message-ID: Subject: Re: [RFC 2/2] recheck: Add a recheck parser for patchwork comments To: Aaron Conole Cc: Dumitru Ceara , David Marchand , Ilya Maximets , ci@dpdk.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: ci@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK CI discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ci-bounces@dpdk.org On Fri, Oct 27, 2023 at 9:06=E2=80=AFAM Aaron Conole w= rote: > > Add a recheck parsing tool that will allow for labs to build a > recheck workflow based on specific recheck labels and projects, > with an associated state machine and querying interface. > > The output of the recheck parsing tool is json and can be fed to > jq or other json parsing utilities for better field support. > > Signed-off-by: Aaron Conole Thank you Aaron for the patch. It looks like you spent a lot of time on it Overall I like the patch and dont have major concerns other than the questions I have made in-line Thanks! > --- > pw_mon | 59 +++++++++++++++++++++++++++++- > recheck_tool | 93 ++++++++++++++++++++++++++++++++++++++++++++++++ > series_db_lib.sh | 62 +++++++++++++++++++++++++++++++- > 3 files changed, 212 insertions(+), 2 deletions(-) > create mode 100755 recheck_tool > > diff --git a/pw_mon b/pw_mon > index 01bdd25..d5ad8f5 100755 > --- a/pw_mon > +++ b/pw_mon > @@ -1,6 +1,6 @@ > #!/bin/sh > # SPDX-Identifier: gpl-2.0-or-later > -# Copyright (C) 2018, Red Hat, Inc. > +# Copyright (C) 2018-2023 Red Hat, Inc. > # > # Monitors a project on a patchwork instance for new series submissions > # Records the submissions in the series database (and emits them on the > @@ -44,6 +44,7 @@ if [ "$1" !=3D "" ]; then > fi > fi > > +recheck_filter=3D"" > > while [ "$1" !=3D "" ]; do > if echo "$1" | grep -E ^--pw-project=3D >/dev/null 2>&1; then > @@ -59,6 +60,13 @@ while [ "$1" !=3D "" ]; do > echo " --add-filter-recheck=3Dfilter Adds a filter to flag t= hat a recheck needs to be done" > echo "" > exit 0 > + elif echo "$1" | grep -E ^--add-filter-recheck=3D >/dev/null 2>&1; t= hen > + filter_str=3D$(echo "$1" | sed s/--add-filter-recheck=3D//) > + recheck_filter=3D"$filter_str $recheck_filter" > + shift > + else > + echo "Uknown option: $1" s/Uknown/Unknown/ > + exit 1 > fi > done > > @@ -179,7 +187,56 @@ function check_superseded_series() { > done > } > > +function run_recheck() { > + local recheck_list=3D$(echo "$7" | sed -e 's/^Recheck-request: // ' = -e 's/,/ /g') > + > + for filter in $recheck_filter; do > + for check in $recheck_list; do > + if [ "$filter" =3D=3D "$check" ]; then > + insert_recheck_request_if_needed "$1" "$3" "$8" "$check"= "$2" > + fi > + done > + done > +} > + > +function check_patch_for_retest_request() { > + local patch_url=3D"$1" > + > + local patch_comments_url=3D$(curl -s "$userpw" "$patch_url" | jq -rc= '.comments') > + if [ "Xnull" !=3D "X$patch_comments_url" ]; then > + local comments_json=3D$(curl -s "$userpw" "$patch_comments_url") > + > + local seq_end=3D$(echo "$comments_json" | jq -rc 'length') > + if [ "$seq_end" -a $seq_end -gt 0 ]; then Isnt this just a longer way of saying " if [ $seq_end -gt 0 ] " ? > + seq_end=3D$((seq_end-1)) > + for comment_id in $(seq 0 $seq_end); do > + local recheck_requested=3D$(echo "$comments_json" | jq -= rc ".[$comment_id].content" | grep "^Recheck-request: ") > + if [ "X$recheck_requested" !=3D "X" ]; then > + local msgid=3D$(echo "$comments_json" | jq -rc ".[$c= omment_id].msgid") > + run_recheck "$pw_instance" "$series_id" "$project" "= $url" "$repo" "$branchname" "$recheck_requested" "$msgid" > + fi > + done > + fi > + fi > +} > + > +function check_series_needs_retest() { > + local pw_instance=3D"$1" > + > + series_get_active_branches "$pw_instance" | while IFS=3D\| read -r s= eries_id project url repo branchname; do > + local patch_comments_url=3D$(curl -s "$userpw" "$url" | jq -rc '= .patches[] | .url') > + > + for patch in $patch_comments_url; do > + check_patch_for_retest_request $patch > + done > + done > +} > + > check_undownloaded_series "$pw_instance" "$pw_project" > check_completed_series "$pw_instance" "$pw_project" > check_new_series "$pw_instance" "$pw_project" > check_superseded_series "$pw_instance" > + > +# check for retest requests after a series is still passing all the > +# checks above > +check_series_needs_retest "$pw_instance" Okay, I am trying to understand what the workflow here is. I think I understand that this script will automatically go and check the series for comments that match "Recheck-request:". This string means that someone asked the bot to recheck the patch/series. This script will call into insert_recheck_request_if_needed(), which will do a check in the database to see if we have already done a recheck to avoid repeating checking the same patches over and over. This is done by checking the $recheck_msgid value in the database I like this workflow. The only thing that I do not like is that you have to check every comment on every patch. That seems like an expensive operation, but honestly I do not think there is a better way to accomplish this. So if there is no better way to do it then it's okay, let's move forward with it > diff --git a/recheck_tool b/recheck_tool > new file mode 100755 > index 0000000..f346e1c > --- /dev/null > +++ b/recheck_tool I guess it wasnt very obvious to me. But what is the purpose of this script? for us to manually add an entry in the database to run a recheck? > @@ -0,0 +1,93 @@ > +#!/bin/sh > +# SPDX-Identifier: gpl-2.0-or-later > +# Copyright (C) 2023 Red Hat, Inc. > +# > +# Licensed under the terms of the GNU General Public License as publishe= d > +# by the Free Software Foundation; either version 2 of the License, or > +# (at your option) any later version. You may obtain a copy of the > +# license at > +# > +# https://www.gnu.org/licenses/old-licenses/gpl-2.0.html > +# > +# Unless required by applicable law or agreed to in writing, software > +# distributed under the License is distributed on an "AS IS" BASIS, WITH= OUT > +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See t= he > +# License for the specific language governing permissions and limitation= s > +# under the License. > + > +mode=3D"select" > + > +while [ "$1" !=3D "" ]; do > + if echo "$1" | grep -E ^--help >/dev/null 2>&1; then > + echo "recheck / retest state machine script" > + echo "" > + echo "$0:" > + echo " --pw-project=3D: Patchwork project." > + echo " --pw-instance=3D: Patchwork instance." > + echo " --filter=3D: Job / request for recheck." > + echo " --state=3D<0..>: Resync state ID." > + echo " --msgid=3D: Message ID to select." > + echo " --update: Set tool in update mode" > + echo " --new-state=3D<0..>: New state ID to set" > + echo " --series-id=3D<..>: Series ID" > + echo "" > + echo "Will spit out a parsable json for each db line when select= ing" > + exit 0 > + elif echo "$1" | grep -E ^--pw-project=3D >/dev/null 2>&1; then > + pw_project=3D$(echo "$1" | sed s/--pw-project=3D//) > + elif echo "$1" | grep -E ^--pw-instance=3D >/dev/null 2>&1; then > + pw_instance=3D$(echo "$1" | sed s/--pw-instance=3D//) > + elif echo "$1" | grep -E ^--filter=3D >/dev/null 2>&1; then > + filter=3D$(echo "$1" | sed s/--filter=3D//) > + elif echo "$1" | grep -E ^--state=3D >/dev/null 2>&1; then > + recheck_state=3D$(echo "$1" | sed s/--state=3D//) > + elif echo "$1" | grep -E ^--msgid=3D >/dev/null 2>&1; then > + message_id=3D$(echo "$1" | sed s/--msgid=3D//) > + elif echo "$1" | grep -E ^--update >/dev/null 2>&1; then > + mode=3D"update" > + elif echo "$1" | grep -E ^--new-state=3D >/dev/null 2>&1; then > + new_recheck_state=3D$(echo "$1" | sed s/--new-state=3D//) > + elif echo "$1" | grep -E ^--series-id=3D >/dev/null 2>&1; then > + series_id=3D$(echo "$1" | sed s/--series-id=3D//) > + else > + echo "unknown option $1" > + exit 1 > + fi > + shift > +done > + > +source $(dirname $0)/series_db_lib.sh > + > +if [ "$mode" =3D=3D "select" ]; then > + echo "{\"rechecks\":[" > + for request in $(get_recheck_requests_by_project "$pw_instance" \ > + "$pw_project" \ > + "$recheck_state" \ > + "$filter"); do > + message_id=3D$(echo $request | cut -d\| -f1) > + series_id=3D$(echo $request | cut -d\| -f2) > + echo "{\"pw_instance\": \"$pw_instance\", \"series_id\":$series_= id, \"msg_id\":\"$message_id\", \"state\":\"$recheck_state\", \"requested\"= : \"$filter\"}" > + done > + echo "]}" > +elif [ "$mode" =3D=3D "update" ]; then > + if [ "X$new_recheck_state" =3D=3D "X" -o "X$series_id" =3D=3D "X" ];= then > + echo "Need to set a series-id and a new recheck state when updat= ing." > + exit 1 > + fi > + > + request=3D$(get_recheck_request "$pw_instance" "$pw_project" "$messa= ge_id" \ > + "$filter" "$series_id" "$recheck_state= ") > + if [ "X$request" =3D=3D "X" ]; then > + echo "{\"result\":\"notfound\"}" > + exit 0 > + fi > + > + set_recheck_request_state "$pw_instance" "$pw_project" "$message_id"= \ > + "$filter" "$series_id" "$new_recheck_state= " > + > + echo "{\"result\":\"executed\",\"recheck\":{\"pw_instance\": \"$pw_i= nstance\", \"series_id\":$series_id, \"msg_id\":\"$message_id\", \"state\":= \"$new_recheck_state\", \"requested\": \"$filter\"}}" > +else > + echo "Uknown state: $mode" s/Uknown/Unknown/ > + exit 1 > +fi > + > diff --git a/series_db_lib.sh b/series_db_lib.sh > index 6c2d98e..a729337 100644 > --- a/series_db_lib.sh > +++ b/series_db_lib.sh > @@ -1,6 +1,6 @@ > #!/bin/sh > # SPDX-Identifier: gpl-2.0-or-later > -# Copyright (C) 2018,2019 Red Hat, Inc. > +# Copyright (C) 2018-2023 Red Hat, Inc. > # > # Licensed under the terms of the GNU General Public License as publishe= d > # by the Free Software Foundation; either version 2 of the License, or > @@ -114,6 +114,21 @@ EOF > run_db_command "INSERT INTO series_schema_version(id) values (7)= ;" > fi > > + run_db_command "select * from series_schema_version;" | egrep '^8$' = > /dev/null 2>&1 > + if [ $? -eq 1 ]; then > + sqlite3 ${HOME}/.series-db < +CREATE TABLE recheck_requests ( > +recheck_id INTEGER, > +recheck_message_id STRING, > +recheck_requested_by STRING, > +recheck_series STRING, > +patchwork_instance STRING, > +patchwork_project STRING, > +recheck_sync INTEGER > +); > +EOF > + run_db_command "INSERT INTO series_schema_version(id) values (8)= ;" > + fi > } > > function series_db_exists() { > @@ -390,3 +405,48 @@ function get_patch_id_by_series_id_and_sha() { > > echo "select patch_id from git_builds where patchwork_instance=3D\"$= instance\" and series_id=3D$series_id and sha=3D\"$sha\";" | series_db_exec= ute > } > + > +function get_recheck_requests_by_project() { > + local recheck_instance=3D"$1" > + local recheck_project=3D"$2" > + local recheck_state=3D"$3" > + local recheck_requested_by=3D"$4" > + > + series_db_exists > + > + echo "select recheck_message_id,recheck_series from recheck_requests= where patchwork_instance=3D\"$recheck_instance\" and patchwork_project=3D\= "$recheck_project\" and recheck_sync=3D$recheck_state and recheck_requested= _by=3D\"$recheck_requested_by\";" | series_db_execute > +} > + > +function insert_recheck_request_if_needed() { > + local recheck_instance=3D"$1" > + local recheck_project=3D"$2" > + local recheck_msgid=3D"$3" > + local recheck_requested_by=3D"$4" > + local recheck_series=3D"$5" > + > + if ! echo "select * from recheck_requests where recheck_message_id= =3D\"$recheck_msgid\";" | series_db_execute | grep $recheck_msgid >/dev/nul= l 2>&1; then > + echo "INSERT INTO recheck_requests (recheck_message_id, recheck_= requested_by, recheck_series, patchwork_instance, patchwork_project, rechec= k_sync) values (\"$recheck_msgid\", \"$recheck_requested_by\", \"$recheck_s= eries\", \"$recheck_instance\", \"$recheck_project\", 0);" | series_db_exec= ute > + fi > +} > + > +function get_recheck_request() { > + local recheck_instance=3D"$1" > + local recheck_project=3D"$2" > + local recheck_msgid=3D"$3" > + local recheck_requested_by=3D"$4" > + local recheck_series=3D"$5" > + local recheck_state=3D"$6" > + > + echo "select * from recheck_requests where patchwork_instance=3D\"$r= echeck_instance\" and patchwork_project=3D\"$recheck_project\" and recheck_= requested_by=3D\"$recheck_requested_by\" and recheck_series=3D\"$recheck_se= ries\" and recheck_message_id=3D\"$recheck_msgid\" and recheck_sync=3D$rech= eck_state;" | series_db_execute > +} > + > +function set_recheck_request_state() { > + local recheck_instance=3D"$1" > + local recheck_project=3D"$2" > + local recheck_msgid=3D"$3" > + local recheck_requested_by=3D"$4" > + local recheck_series=3D"$5" > + local recheck_state=3D"$6" > + > + echo "UPDATE recheck_requests set recheck_sync=3D$recheck_state wher= e patchwork_instance=3D\"$recheck_instance\" and patchwork_project=3D\"$rec= heck_project\" and recheck_requested_by=3D\"$recheck_requested_by\" and rec= heck_series=3D\"$recheck_series\";" | series_db_execute > +} > -- > 2.41.0 >