优化 Gitea 并行构建、重试与 Windows 更新发布 #5
No files matched your search
@@ -56,6 +56,8 @@ the build job must still be rerun; it has no saved app to restore.
|
||||
|
||||
Release attachment uploads retry temporary network errors, HTTP 408/429 and
|
||||
500/502/503/504 up to three POST attempts per file, also with 5/15-second delays.
|
||||
The specific FRP HTML "Not Found" page observed during tunnel reconnection is
|
||||
also treated as temporary; ordinary Gitea API or HTML 404 responses still fail.
|
||||
Before retrying a POST, the uploader checks whether Gitea already saved the named
|
||||
attachment, including after the final response is lost. This avoids duplicate
|
||||
uploads after a timeout. Authorization, invalid-input and other permanent errors
|
||||
|
||||
@@ -17,6 +17,11 @@ RETRY_DELAYS = (5, 15)
|
||||
|
||||
def transient(error):
|
||||
if isinstance(error, urllib.error.HTTPError):
|
||||
if error.code == 404 and error.headers.get('Content-Type', '').split(';')[0].lower() == 'text/html':
|
||||
body = error.read(64 * 1024).lower()
|
||||
# FRP returns this page while the vhost tunnel is unavailable.
|
||||
# A normal Gitea API 404 remains a permanent error.
|
||||
return b'github.com/fatedier/frp' in body and b'not found' in body
|
||||
return error.code in {408, 429, 500, 502, 503, 504}
|
||||
return isinstance(error, (urllib.error.URLError, TimeoutError, ConnectionError,
|
||||
http.client.IncompleteRead))
|
||||
|
||||
@@ -9,6 +9,33 @@ import release_transport as transfers
|
||||
|
||||
|
||||
class TransferToolsTests(unittest.TestCase):
|
||||
def test_frp_tunnel_not_found_page_is_retried_as_a_temporary_failure(self):
|
||||
calls = 0
|
||||
|
||||
def transport(url, data=None, method=None, content_type=None):
|
||||
nonlocal calls
|
||||
if method is None:
|
||||
return []
|
||||
calls += 1
|
||||
if calls == 1:
|
||||
body = b'<h1>Not Found</h1><a href="https://github.com/fatedier/frp">frp</a>'
|
||||
raise urllib.error.HTTPError(url, 404, 'Not Found',
|
||||
{'Content-Type': 'text/html; charset=utf-8'}, io.BytesIO(body))
|
||||
return {}
|
||||
|
||||
with patch.object(transfers.time, 'sleep') as sleep:
|
||||
transfers.upload_contents('base', 3, {'app.zip': b'app'}, transport=transport)
|
||||
self.assertEqual(calls, 2)
|
||||
sleep.assert_called_once_with(5)
|
||||
|
||||
def test_ordinary_html_not_found_and_json_api_errors_are_not_retried(self):
|
||||
for content_type, body in [('text/html', b'<h1>Not Found</h1>'),
|
||||
('application/json', b'Not Found github.com/fatedier/frp')]:
|
||||
with self.subTest(content_type=content_type):
|
||||
error = urllib.error.HTTPError('url', 404, 'Not Found',
|
||||
{'Content-Type': content_type}, io.BytesIO(body))
|
||||
self.assertFalse(transfers.transient(error))
|
||||
|
||||
def test_transient_upload_failure_retries_without_restarting_other_files(self):
|
||||
calls = []
|
||||
|
||||
|
||||
Reference in new issue
Block a user