From fa57e21738b6f4df246a4a61fbdea934dc8256fc Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Sat, 15 Aug 2020 18:11:53 -0700 Subject: [PATCH] taskd/clone.sh: record info for clones exceeding limits When a clone exceeds an allowed size limit, all objects are immediately purged to avoid using disk space. Remember that it was a clone that failed due to an exceeded limit by using ".clone_failed_exceeds_limit" instead of ".clone_failed" and emit copies of the exceeds reason(s) to both ".clone_failed_exceeds_limit" and ".clonelog" to make it easy to recover the information without needing the failure message that's emailed. At the same time, remove the ".clone_failed" file to prevent having a "Restart Mirroring" button show up on the project edit page. Restarting the mirror will not cure the fact that the source respository exceeds allowed limits. Signed-off-by: Kyle J. McKay --- taskd/clone.sh | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/taskd/clone.sh b/taskd/clone.sh index 2989a64..dc6c74a 100755 --- a/taskd/clone.sh +++ b/taskd/clone.sh @@ -89,7 +89,6 @@ send_clone_failed() { trap "" EXIT # We must now close the .clonelog file that is open on stdout and stderr exec >/dev/null 2>&1 - ! [ -d htmlcache ] || { >htmlcache/changed; } 2>/dev/null || : failaddrs="$(config_get owner)" || : ccadm="${cfg_admincc:-0}" xfsz_err="" @@ -122,6 +121,24 @@ The source repository${reposize:+ ($reposize)} exceeds our maximum allowed repos The source repository${exit_objs:+ ($exit_objs objects)} exceeds our maximum allowed object limit." clear_all_objects_and_packs fi + if [ -n "$xfsz_err" ] || [ -n "$xobjs_err" ]; then + # Mark as an exceeds limit clone failure and remember the exceeds + # message(s) in both .clone_failed_exceeds_limit and .clonelog + >.clone_failed_exceeds_limit + if [ -n "$xfsz_err" ]; then + printf '%s\n' "${xfsz_err#??}" >>.clone_failed_exceeds_limit + printf '%s\n' "${xfsz_err#?}" >>.clonelog + fi + if [ -n "$xobjs_err" ]; then + printf '%s\n' "${xobjs_err#??}" >>.clone_failed_exceeds_limit + printf '%s\n' "${xobjs_err#?}" >>.clonelog + fi + # Remove the .clone_failed file to prevent "restarting" the clone since + # restarting it will not cure the fact that it exceeds allowed limits + # And the .clone_in_progress file has to go at the same time + rm -f .clone_in_progress .clone_failed + fi + ! [ -d htmlcache ] || { >htmlcache/changed; } 2>/dev/null || : [ "$ccadm" = "0" ] || [ -z "$cfg_admin" ] || if [ -z "$failaddrs" ]; then failaddrs="$cfg_admin"; else failaddrs="$failaddrs,$cfg_admin"; fi [ -z "$failaddrs" ] || -- 2.11.4.GIT