aboutsummaryrefslogtreecommitdiff
path: root/brep/handler/submit/submit-git.bash.in
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-08-28 17:34:24 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-08-28 23:32:13 +0300
commit05eeac08b63449925cc2e12d2fdaf937d5fa1bbc (patch)
treee448a5ac7f536f165a9b6a50833db7726ab980f5 /brep/handler/submit/submit-git.bash.in
parent9ffc9c2c72c57c381a0af44a52f2fe6dff73171c (diff)
Fix submit-git to respond with 422 (client) error if fail to git-clone control URL
Diffstat (limited to 'brep/handler/submit/submit-git.bash.in')
-rw-r--r--brep/handler/submit/submit-git.bash.in22
1 files changed, 15 insertions, 7 deletions
diff --git a/brep/handler/submit/submit-git.bash.in b/brep/handler/submit/submit-git.bash.in
index 2fd26b0..c77f18d 100644
--- a/brep/handler/submit/submit-git.bash.in
+++ b/brep/handler/submit/submit-git.bash.in
@@ -299,15 +299,20 @@ function url_scheme () # <url>
sed -n -e 's%^\(.*\)://.*$%\L\1%p' <<<"$1"
}
-# Checks that the repository properly responds to the probing request before
+# Check that the repository properly responds to the probing request before
# the timeout (in seconds). Noop for protocols other than HTTP(S).
#
-function check_connectivity () # <repo-url> <timeout>
+# If the repository is other than ours (e.g., control) then don't log a
+# failure and respond with the 422 (client) rather than 503 (server) HTTP
+# error.
+#
+function check_connectivity () # <repo-url> <timeout> <ours>
{
trace_func "$@"
local url="$1"
local tmo="$2"
+ local our="$3"
local s
s="$(url_scheme "$url")"
@@ -324,11 +329,14 @@ function check_connectivity () # <repo-url> <timeout>
u="$u/info/refs$q&service=git-upload-pack"
fi
- # This function is called on repositories other than ours (e.g., control)
- # so we don't want a failure to be logged.
- #
- if ! run_silent curl -S -s --max-time "$tmo" "$u" >/dev/null; then
- exit_with_manifest 503 "submission service temporarily unavailable"
+ local cmd=(curl -S -s --max-time "$tmo" "$u")
+
+ if [ "$our" ]; then
+ if ! run "${cmd[@]}" >/dev/null; then
+ exit_with_manifest 503 "submission service temporarily unavailable"
+ fi
+ elif ! run_silent "${cmd[@]}" >/dev/null; then
+ exit_with_manifest 422 "repository $url unavailable"
fi
fi
}