* Bound HTTP request timeouts and retry budget With no request timeout, Retry(total=30, backoff_factor=2, backoff_max=60) let a single unreachable server hang the client for around 26 minutes: backoff sleeps alone sum to that, and each of the 30 connection attempts could itself stall indefinitely without a timeout. Measured a black-holed connect attempt taking 75s on this machine with no timeout set, confirming the mechanism. - Add HTTP_TIMEOUT (connect, read) and a tighter retry budget (HTTP_RETRY_TOTAL/BACKOFF_FACTOR/BACKOFF_MAX) in dsc/const.py, bounding the worst case to a few minutes. - Pass timeout=HTTP_TIMEOUT on both SeafileClient HTTP calls (token fetch, remote library listing). - Add NetworkError(DscError) so a network failure is caught by start.py's existing top-level DscError handling instead of producing a bare traceback. - Add tests/test_http.py covering the retry policy values, timeout propagation, and error wrapping. - Check off the corresponding IMPROVEMENTS.md items. * Include URL and status code in NetworkError messages Copilot review on PR #28 flagged that the non-200 path for remote library listing raised NetworkError with only the raw response body, losing which request failed and its status code. The token-fetch error had the same gap. Both now include the URL and HTTP status. --------- Co-authored-by: Maxim Shulga <maxim.shulga@alludo.com>
30 lines
1.0 KiB
Python
30 lines
1.0 KiB
Python
DEFAULT_APP_DIR = "/dsc"
|
|
DEFAULT_LIBS_DIR = "/dsc/seafile"
|
|
DEPRECATED_LIBS_DIR = "/data"
|
|
DEFAULT_USERNAME = "seafile"
|
|
STATUS_POLL_PERIOD = 1
|
|
|
|
# Bounds for daemon startup and shutdown, in seconds. The stop timeout has to
|
|
# fit inside the grace period of "docker stop", which sends SIGKILL 10 seconds
|
|
# after SIGTERM by default, otherwise shutdown is never graceful.
|
|
DAEMON_POLL_PERIOD = 1
|
|
DAEMON_START_TIMEOUT = 120
|
|
DAEMON_STOP_TIMEOUT = 8
|
|
|
|
# Bounds for HTTP requests to the Seafile server. Without a request timeout,
|
|
# a total=30/backoff_factor=2/backoff_max=60 retry policy was measured to
|
|
# take about 26 minutes against an unreachable host before giving up, which
|
|
# is indistinguishable from a hang. HTTP_TIMEOUT is (connect, read); the
|
|
# retry budget below now bounds the worst case to a few minutes instead.
|
|
HTTP_TIMEOUT = (10, 30)
|
|
HTTP_RETRY_TOTAL = 5
|
|
HTTP_RETRY_BACKOFF_FACTOR = 1
|
|
HTTP_RETRY_BACKOFF_MAX = 30
|
|
|
|
AVAILABLE_SEAFCLI_OPTIONS = {
|
|
"delete_confirm_threshold",
|
|
"disable_verify_certificate",
|
|
"upload_limit",
|
|
"download_limit",
|
|
}
|