Add explicit timeouts to subprocess and HTTP calls in git-gate paths #271
Reference in New Issue
Block a user
Delete Branch "add-subprocess-http-timeouts"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #255.
Summary
git_http_backend.py: addsGIT_HTTP_BACKEND_TIMEOUT_SECS = 30and passes it to bothsubprocess.runcalls (access-hook invocation andgit http-backendCGI), mirroring the existingGIT_GATE_DAEMON_TIMEOUT_SECSon the daemon path.contrib/gitea/deploy_key_provisioner.py: adds_API_TIMEOUT_SECS = 30and_KEYGEN_TIMEOUT_SECS = 10; passes them to the twourllib.request.urlopencalls (create and delete deploy key) and thessh-keygensubprocess.@@ -25,0 +25,4 @@# Timeout for the access-hook subprocess and git http-backend CGI subprocess.# Mirrors GIT_GATE_DAEMON_TIMEOUT_SECS so both HTTP and daemon paths share the# same bound: a hung upstream fetch in the access-hook or a stalled CGI child# cannot wedge the sidecar indefinitely.@didericis-claude Should probably just import
GIT_GATE_DAEMON_TIMEOUT_SECSand set this to that value if they should be equal.Good call. Dropped
GIT_HTTP_BACKEND_TIMEOUT_SECSentirely and now importGIT_GATE_DAEMON_TIMEOUT_SECSdirectly fromgit_gate. The test was updated to assert against the imported constant too, so the value is enforced at a single source. Pushed indb9857c.@@ -16,6 +16,8 @@ from http.server import BaseHTTPRequestHandler, ThreadingHTTPServerfrom pathlib import Pathfrom urllib.parse import urlsplitfrom .git_gate import GIT_GATE_DAEMON_TIMEOUT_SECSGiven we're using this for two different purposes now, probably makes sense to rename it to
GIT_GATE_TIMEOUT_SECS. Can add a comment about where it's currently used/fact that it's used in a multiple places.Done in
1077621. Renamed toGIT_GATE_TIMEOUT_SECSand updated the comment to enumerate all three current users (git daemon--timeout/--init-timeout, access-hook subprocess, git http-backend CGI).1077621beato8e81b3b4258e81b3b425to0bace7615a