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

helper: repo_sync: improve timeout diagnostics #354

Merged
merged 1 commit into from
Oct 10, 2024
Merged
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
12 changes: 10 additions & 2 deletions helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,29 @@ 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
run repo init --repo-rev=v2.35 --no-clone-bundle -u $* ${REPO_INIT_OVERRIDES} && break
run repo init $_repo_extra_args --repo-rev=v2.35 --no-clone-bundle -u $* ${REPO_INIT_OVERRIDES} && break
_repo_extra_args = "--verbose"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the downside of always running with verbose?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

basically it just generates less noise, as the first time it almost always works

status "repo init failed with error $?"
[ $i -eq 4 ] && exit 1
status "sleeping and trying again"
sleep $(($i*2))
done
_repo_extra_args = ""
for i in $(seq 4); do
run timeout 4m repo sync && break
run timeout 4m repo sync $_repo_extra_args && break
_repo_extra_args = "--verbose"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clever

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
Expand Down