]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
script/ptl-tool: add automatic HTTP retry adapter to requests session 70190/head
authorPatrick Donnelly <pdonnell@ibm.com>
Tue, 14 Jul 2026 13:37:48 +0000 (09:37 -0400)
committerPatrick Donnelly <pdonnell@ibm.com>
Tue, 14 Jul 2026 13:38:38 +0000 (09:38 -0400)
Long-running local git operations and Redmine API calls can cause the idle
keep-alive connection to api.github.com to be closed by the remote server.
When the script later attempts to post automated PR comments, it fails with
http.client.RemoteDisconnected.

Fix this by mounting an urllib3 Retry adapter to the requests.Session,
automatically re-establishing dropped connections up to 3 times on
transient network or server errors (500, 502, 503, 504).

Assisted-by: Gemini
Signed-off-by: Patrick Donnelly <pdonnell@ibm.com>
src/script/ptl-tool.py

index a602c025997d5f0695522bfceccddb480a7a7ef0..70602d3c370f2ef6c162148f0f257ad243b2da1d 100755 (executable)
@@ -69,6 +69,8 @@ except ImportError:
 
 try:
     import requests
+    from requests.adapters import HTTPAdapter
+    from urllib3.util.retry import Retry
 except ImportError:
     MISSING_DEPS.append("requests")
 
@@ -1927,6 +1929,14 @@ def build_branch(args):
     merge_branch_name = args.merge_branch_name
 
     session = requests.Session()
+    retries = Retry(
+        total=3,
+        backoff_factor=1,
+        status_forcelist=[500, 502, 503, 504],
+        raise_on_status=False
+    )
+    session.mount("https://", HTTPAdapter(max_retries=retries))
+    session.mount("http://", HTTPAdapter(max_retries=retries))
 
     if label:
         # Check the label format