From patchwork Wed Aug 8 10:50:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Po-Hsu Lin X-Patchwork-Id: 954896 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41lp7b0n3Nz9ryt; Wed, 8 Aug 2018 20:50:18 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1fnM2d-0006d3-6W; Wed, 08 Aug 2018 10:50:11 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1fnM2b-0006cv-IA for kernel-team@lists.ubuntu.com; Wed, 08 Aug 2018 10:50:09 +0000 Received: from mail-pf1-f200.google.com ([209.85.210.200]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1fnM2b-0005HW-6g for kernel-team@lists.ubuntu.com; Wed, 08 Aug 2018 10:50:09 +0000 Received: by mail-pf1-f200.google.com with SMTP id l15-v6so1207528pff.1 for ; Wed, 08 Aug 2018 03:50:09 -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:cc:subject:date:message-id; bh=ZJfX+rXUjT0tTrBWBjPTwnwj0UtREFFE7GDhoYFoG/A=; b=LJ4VEL4M/JL7ga/xQ9U841/JJkuC4vyCo+v8vQSbNVPHwHg0DaTntHOy/NLzDcBdoJ ND8lkWluSnDdBkADKP6+AzHP5Iq5kRmOeRW3jSFN5xoejwm4Nhpoz2C0xxkQJ0MjacHk lhWI7mhdWSGySuZGdMmH8dPlnYqeuT/WkS7xo4zmEK+aDujXj1lVpdeXmIlD8WEd2zt7 hkRdWZPWLogbSUA8egjKSyzB/1l4fs2f8sCMisfjnh2Lpgy2gDPP164XSYqR2qm+DX1e p7RHJNIUuayvCUswTbgtWZ+NQ5PgplfbJ5RXj7fQjq+fgztN5UH1v8pa03NanPtP2gVK TlFA== X-Gm-Message-State: AOUpUlGhP6xUQUW8mroTYz+YMmd+z6IznxfEgWpkBmR77k2KOke6w0x1 U0SLkxuAKvLiZQpSjNbqx95Z2W8heRRc10jUghoJecTQe70T5+GV0K+5XaOgSBLrCfC8gmfe8le RjD899FpiCVpe/8ZH4lBigPOlo1KY7ILutUP7VzBy X-Received: by 2002:a62:5047:: with SMTP id e68-v6mr2412867pfb.157.1533725407573; Wed, 08 Aug 2018 03:50:07 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzIGWb4kqH3GDhY5X75FV2xvGylj9CFg2MqCZgNxukmL/bE+Pmsu1gQ/rMoawfIZ3FltGkWGA== X-Received: by 2002:a62:5047:: with SMTP id e68-v6mr2412846pfb.157.1533725407353; Wed, 08 Aug 2018 03:50:07 -0700 (PDT) Received: from Leggiero.taipei.internal (61-220-137-37.HINET-IP.hinet.net. [61.220.137.37]) by smtp.gmail.com with ESMTPSA id t12-v6sm5496629pgg.72.2018.08.08.03.50.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Aug 2018 03:50:06 -0700 (PDT) From: Po-Hsu Lin To: kernel-team@lists.ubuntu.com Subject: [kteam-tools][PATCH] stable: add jenkins-git-update.sh Date: Wed, 8 Aug 2018 18:50:01 +0800 Message-Id: <20180808105001.14164-1-po-hsu.lin@canonical.com> X-Mailer: git-send-email 2.17.1 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" Add a script that can help us to update all SRU related git repositories on all of our jenkins server, and will capability to kill the test request handler to allow it respawn with cron jobs. Signed-off-by: Po-Hsu Lin --- stable/README | 8 ++++ stable/jenkins-git-update.sh | 93 ++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100755 stable/jenkins-git-update.sh diff --git a/stable/README b/stable/README index 2a2b5431..c909d99c 100644 --- a/stable/README +++ b/stable/README @@ -82,3 +82,11 @@ create-sru-cards.py: Example: create-sru-cards.py 2017.10.09 + +jenkins-git-update.sh: + Update all the SRU related git repo on all of our jenkins servers and their + slaves. It can also kill the test request handler (kmsg-jenking) to make new + configs take effect if requested. + + Example: + jenkins-git-update.sh -r diff --git a/stable/jenkins-git-update.sh b/stable/jenkins-git-update.sh new file mode 100755 index 00000000..50636aae --- /dev/null +++ b/stable/jenkins-git-update.sh @@ -0,0 +1,93 @@ +#!/bin/bash +# +# A small tool for updating SRU git repos on jenkins servers. +# Note that this script works only with bash 4 and later and +# you will need to have access to these servers as well. +# +# Po-Hsu Lin +# + +declare -A jenkins=( ["bare-metal"]="jenkins@10.246.72.4" + ["live-patching"]="jenkins@10.246.72.5" + ["aws"]="jenkins@10.246.72.47" + ["azure"]="jenkins@10.246.72.46" + ["google"]="jenkins@10.246.72.7" ) +declare -A slaves=( ["bare-metal"]="" + ["live-patching"]="" + ["aws"]="aws@obruchev" + ["azure"]="azure@obruchev" + ["google"]="google@obruchev" ) +repos=("autotest-client-tests" "autotest" "ckct" "kernel-testing") +respawn=false + + +function help_msg { + echo "Usage: $0 [-r]" + echo -e "\t-h : Print this help message and exit." + echo -e "\t-r : Kill the kmsgq-jenkins and request-handler to make it respawn with cron job." +} + + +function interrupted { + echo "SIGINT, terminating ssh-agent" + exit +} + + +function cleanup { + ssh-agent -k +} + + +while getopts :rh opt; do + case $opt in + r) + echo "Requested to restart kmsgq-jenkins and request-handler" + respawn=true + ;; + h) + help_msg + exit + ;; + \?) + echo "Invalid option: -$OPTARG" + help_msg + exit + ;; + esac +done + + +trap interrupted SIGINT +trap cleanup EXIT +eval `ssh-agent -s` > /dev/null +ssh-add +echo "ssh-agent with PID: $SSH_AGENT_PID will be terminated on exit / SIGINT" +echo "" + +for target in "${!jenkins[@]}" +do + echo -e "\033[1;32m == Running on $target jenkins == \033[m" + for dir in "${repos[@]}" + do + echo -e "\033[1;33m Updating $dir: \033[m" + ssh "${jenkins[$target]}" "cd $dir; git pull --ff-only" + done + echo "" + # Update slaves + if [ "${slaves[$target]}" != "" ]; then + echo -e "\033[1;36m -- Running on $target slave node: ${slaves[$target]} -- \033[m" + for dir in "${repos[@]}" + do + echo -e "\033[1;33m Updating $dir: \033[m" + ssh "${jenkins[$target]}" "ssh ${slaves[$target]} \"cd $dir; git pull --ff-only\"" + done + echo "" + fi + if [ $respawn == true ]; then + echo "Killing kmsgq-jenkins / requests-handler on $target jenkins" + ssh "${jenkins[$target]}" "pkill -f kmsgq-jenkins" + ssh "${jenkins[$target]}" "pkill -f requests-handler" + echo "" + fi +done