Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

helpers: adds repo_sync_helper #365

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 23 additions & 33 deletions helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,25 @@ function start_ssh_agent {
fi
}

function repo_sync_helper {
_repo_retries=4
_repo_extra_args=""
for i in $(seq $_repo_retries); do
if run timeout --preserve-status $@ $_repo_extra_args; then
break
else
status "repo [$i/$_repo_retries] failed with error $?"
if [ $i -eq $_repo_retries ]; then
exit 1
fi
_sleep=$(($i*2))
status "sleeping ${_sleep}s and trying again"
sleep $_sleep
_repo_extra_args="--verbose"
fi
done
}

function repo_sync {
status "Repo syncing sources..."

Expand All @@ -74,39 +93,10 @@ function repo_sync {
status "Adding git config extraheader for $domain/factories"
git config --global http.https://${domain}/factories.extraheader "$(cat /secrets/git.http.extraheader)"
fi
_repo_extra_args=""
for i in $(seq 4); do
if run repo init $_repo_extra_args --repo-rev=v2.35 --no-clone-bundle -u $* ${REPO_INIT_OVERRIDES}; then
break
fi
_repo_extra_args="--verbose"
status "repo init failed with error $?"
if [ $i -eq 4 ]; then
exit 1
fi
status "sleeping and trying again"
sleep $(($i*2))
done
_repo_extra_args=""
for i in $(seq 4); do
if run timeout 4m repo sync $_repo_extra_args; then
break
fi
_repo_extra_args="--verbose"
if [ $? -eq 124 ] ; then
msg="Command timed out"
if [ $i -ne 4 ] ; then
msg="${msg}, trying again"
else
status ${msg}
exit 1
fi
status ${msg}
sleep $(($i*2))
else
exit $?
fi
done

repo_sync_helper 1m repo init --repo-rev=v2.35 --no-clone-bundle -u $* ${REPO_INIT_OVERRIDES}
repo_sync_helper 4m repo sync

if [ -d "$archive" ] ; then
status "Generating pinned manifest"
repo manifest -r -o $archive/manifest.pinned.xml
Expand Down
Loading