All of lore.kernel.org
 help / color / mirror / Atom feed
* [oe-layersetup][master][PATCH] Add git_retry.sh wrapper around git
@ 2022-01-27 21:11 Ryan Eatmon
  0 siblings, 0 replies; only message in thread
From: Ryan Eatmon @ 2022-01-27 21:11 UTC (permalink / raw)
  To: Yogesh Siraswar, Praneeth Bajjuri, Denys Dmytriyenko, meta-arago

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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-01-27 21:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-27 21:11 [oe-layersetup][master][PATCH] Add git_retry.sh wrapper around git Ryan Eatmon

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.