Skip to content

Commit

Permalink
Merge pull request #57 from quaresmajose/garagesign
Browse files Browse the repository at this point in the history
[kirkstone] Improve the garage-sign targets push resilience
  • Loading branch information
pattivacek authored Oct 28, 2022
2 parents 7935897 + a5277d1 commit f42fa04
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions classes/image_types_ostree.bbclass
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ OSTREE_UPDATE_SUMMARY ??= "0"

BUILD_OSTREE_TARBALL ??= "1"

GARAGE_PUSH_RETRIES ??= "3"
GARAGE_PUSH_RETRIES_SLEEP ??= "0"

SYSTEMD_USED = "${@oe.utils.ifelse(d.getVar('VIRTUAL-RUNTIME_init_manager') == 'systemd', 'true', '')}"

IMAGE_CMD_TAR = "tar --xattrs --xattrs-include=*"
Expand Down Expand Up @@ -229,7 +232,7 @@ IMAGE_CMD:garagesign () {
target_expiry="--expire-after 1M"
fi

for push_retries in $( seq 3 ); do
for push_retries in $( seq ${GARAGE_PUSH_RETRIES} ); do
garage-sign targets pull --repo tufrepo \
--home-dir ${GARAGE_SIGN_REPO}
garage-sign targets add --repo tufrepo \
Expand Down Expand Up @@ -258,7 +261,13 @@ IMAGE_CMD:garagesign () {
push_success=1
break
else
bbwarn "Push to garage repository has failed with errcode ${errcode}, retrying"
bbwarn "Push to garage repository has failed with errcode ${errcode}, retrying ${push_retries}/${GARAGE_PUSH_RETRIES}"
if [ "${GARAGE_PUSH_RETRIES_SLEEP}" -ne "0" ]; then
ramdom="$(date +%s%N | cut -b10-19)"
sleep="$(expr ${ramdom} % ${GARAGE_PUSH_RETRIES_SLEEP} + 1)"
bbdebug 1 "Push to garage repository in ${sleep} seconds"
sleep ${sleep}
fi
fi
done
rm -rf ${GARAGE_SIGN_REPO}
Expand Down

0 comments on commit f42fa04

Please sign in to comment.