All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ryan Eatmon" <reatmon@ti.com>
To: Yogesh Siraswar <yogeshs@ti.com>,
	Praneeth Bajjuri <praneeth@ti.com>,
	Denys Dmytriyenko <denys@konsulko.com>,
	<meta-arago@lists.yoctoproject.org>
Subject: [oe-layersetup][master][PATCH] Add git_retry.sh wrapper around git
Date: Thu, 27 Jan 2022 15:11:20 -0600	[thread overview]
Message-ID: <20220127211120.23772-1-reatmon@ti.com> (raw)

We are seeing a sporadic failure in our nightly builds
due to the git clone/fetch calls timing out and erroring.
These events are usually resolved by just trying the git
call again, but in a scripted flow it causes a failure
in that run.  The git_retry.sh script solves that by
allowing the git command to be retried a few times while
sleeping in between.

Signed-off-by: Ryan Eatmon <reatmon@ti.com>
---
 git_retry.sh          | 29 +++++++++++++++++++++++++++++
 oe-layertool-setup.sh |  4 ++--
 2 files changed, 31 insertions(+), 2 deletions(-)
 create mode 100755 git_retry.sh

diff --git a/git_retry.sh b/git_retry.sh
new file mode 100755
index 0000000..e5ed5bb
--- /dev/null
+++ b/git_retry.sh
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+let glRetries=5
+let glDelay=15
+let glExitCode=0
+
+while [ $glRetries -gt 0 ]; do
+
+    git "$@"
+
+    glExitCode=$?
+
+    if [ $glExitCode -eq 0 ]; then
+        exit
+    fi
+
+    let glRetries=$glRetries-1
+
+    if [ $glRetries -gt 0 ]; then
+        echo "git failed... remaining attempts: $glRetries"
+        sleep $glDelay
+    fi
+
+done
+
+echo "git failed... giving up..."
+
+exit $glExitCode
+
diff --git a/oe-layertool-setup.sh b/oe-layertool-setup.sh
index df1523f..932ec49 100755
--- a/oe-layertool-setup.sh
+++ b/oe-layertool-setup.sh
@@ -336,9 +336,9 @@ clone_repo() {
     if [ -d $sourcedir/$name ]
     then
         cd $sourcedir/$name
-        git fetch --all
+        $oebase/git_retry.sh fetch --all
     else
-        git clone $uri $sourcedir/$name
+        $oebase/git_retry.sh clone $uri $sourcedir/$name
         if [ "$?" != "0" ]
         then
             echo "ERROR: Could not clone repository at $uri"
-- 
2.17.1


                 reply	other threads:[~2022-01-27 21:11 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220127211120.23772-1-reatmon@ti.com \
    --to=reatmon@ti.com \
    --cc=denys@konsulko.com \
    --cc=meta-arago@lists.yoctoproject.org \
    --cc=praneeth@ti.com \
    --cc=yogeshs@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.