refactor: rename GIT_GATE_DAEMON_TIMEOUT_SECS to GIT_GATE_TIMEOUT_SECS
The constant now covers the daemon path, the HTTP backend access-hook, and the git http-backend CGI subprocess, so 'daemon' in the name was too narrow. Updated the comment to list all three current uses.
This commit is contained in:
@@ -43,10 +43,10 @@ from .manifest import ManifestBottle, ManifestGitEntry
|
|||||||
# Short network alias for git-gate inside the sidecar bundle. The
|
# Short network alias for git-gate inside the sidecar bundle. The
|
||||||
# agent's `.gitconfig` insteadOf rewrites resolve through this name.
|
# agent's `.gitconfig` insteadOf rewrites resolve through this name.
|
||||||
GIT_GATE_HOSTNAME = "git-gate"
|
GIT_GATE_HOSTNAME = "git-gate"
|
||||||
# Bound half-open git client sessions. If an agent/tool runner is
|
# Shared timeout (seconds) for all git-gate subprocess and CGI calls:
|
||||||
# interrupted during push, git daemon should reap the receive-pack
|
# git daemon (--timeout/--init-timeout), the access-hook subprocess in
|
||||||
# child instead of keeping the gate wedged indefinitely.
|
# git_http_backend, and the git http-backend CGI subprocess.
|
||||||
GIT_GATE_DAEMON_TIMEOUT_SECS = 15
|
GIT_GATE_TIMEOUT_SECS = 15
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
@@ -217,8 +217,8 @@ def git_gate_render_entrypoint(upstreams: tuple[GitGateUpstream, ...]) -> str:
|
|||||||
"",
|
"",
|
||||||
"exec git daemon \\",
|
"exec git daemon \\",
|
||||||
" --reuseaddr \\",
|
" --reuseaddr \\",
|
||||||
f" --timeout={GIT_GATE_DAEMON_TIMEOUT_SECS} \\",
|
f" --timeout={GIT_GATE_TIMEOUT_SECS} \\",
|
||||||
f" --init-timeout={GIT_GATE_DAEMON_TIMEOUT_SECS} \\",
|
f" --init-timeout={GIT_GATE_TIMEOUT_SECS} \\",
|
||||||
" --base-path=/git \\",
|
" --base-path=/git \\",
|
||||||
" --export-all \\",
|
" --export-all \\",
|
||||||
" --enable=receive-pack \\",
|
" --enable=receive-pack \\",
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from urllib.parse import urlsplit
|
from urllib.parse import urlsplit
|
||||||
|
|
||||||
from .git_gate import GIT_GATE_DAEMON_TIMEOUT_SECS
|
from .git_gate import GIT_GATE_TIMEOUT_SECS
|
||||||
|
|
||||||
|
|
||||||
DEFAULT_PORT = 9420
|
DEFAULT_PORT = 9420
|
||||||
@@ -49,7 +49,7 @@ class GitHttpHandler(BaseHTTPRequestHandler):
|
|||||||
[hook_path, "upload-pack", str(repo_dir), peer, peer],
|
[hook_path, "upload-pack", str(repo_dir), peer, peer],
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
check=False,
|
check=False,
|
||||||
timeout=GIT_GATE_DAEMON_TIMEOUT_SECS,
|
timeout=GIT_GATE_TIMEOUT_SECS,
|
||||||
)
|
)
|
||||||
if hook.returncode != 0:
|
if hook.returncode != 0:
|
||||||
detail = (hook.stderr or hook.stdout).decode(
|
detail = (hook.stderr or hook.stdout).decode(
|
||||||
@@ -113,7 +113,7 @@ class GitHttpHandler(BaseHTTPRequestHandler):
|
|||||||
env=env,
|
env=env,
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
check=False,
|
check=False,
|
||||||
timeout=GIT_GATE_DAEMON_TIMEOUT_SECS,
|
timeout=GIT_GATE_TIMEOUT_SECS,
|
||||||
)
|
)
|
||||||
self._write_cgi_response(proc.stdout)
|
self._write_cgi_response(proc.stdout)
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import urllib.request
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
from bot_bottle.git_gate import GIT_GATE_DAEMON_TIMEOUT_SECS
|
from bot_bottle.git_gate import GIT_GATE_TIMEOUT_SECS
|
||||||
from bot_bottle.git_http_backend import GitHttpHandler, MAX_BODY_BYTES
|
from bot_bottle.git_http_backend import GitHttpHandler, MAX_BODY_BYTES
|
||||||
|
|
||||||
|
|
||||||
@@ -201,7 +201,7 @@ class TestGitHttpBackend(unittest.TestCase):
|
|||||||
|
|
||||||
for call in run.call_args_list:
|
for call in run.call_args_list:
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
GIT_GATE_DAEMON_TIMEOUT_SECS,
|
GIT_GATE_TIMEOUT_SECS,
|
||||||
call.kwargs.get("timeout"),
|
call.kwargs.get("timeout"),
|
||||||
f"subprocess.run call missing timeout: {call}",
|
f"subprocess.run call missing timeout: {call}",
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user