mirror of
https://github.com/healthchecks/healthchecks.git
synced 2025-04-04 21:05:26 +00:00
Increase outgoing webhook timeout from 10 to 30 seconds
Also simplify the retry logic: each retry attempt is now allowed to use the full 30 seconds. This means, a single webhook delivery can take up to 3*30=90 seconds.
This commit is contained in:
parent
13217af304
commit
28af3720f4
4 changed files with 8 additions and 8 deletions
|
@ -3,6 +3,9 @@ All notable changes to this project will be documented in this file.
|
|||
|
||||
## v3.7-dev - Unreleased
|
||||
|
||||
### Improvements
|
||||
- Increase outgoing webhook timeout from 10 to 30 seconds
|
||||
|
||||
### Bug Fixes
|
||||
- Update sqlite settings to avoid "Database is locked" errors (#1057)
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@ class NotifyWebhookTestCase(BaseTestCase):
|
|||
self.channel.notify(self.flip)
|
||||
args, kwargs = mock_get.call_args
|
||||
self.assertEqual(args, ("get", "http://example"))
|
||||
self.assertEqual(kwargs["timeout"], 30)
|
||||
|
||||
@patch(
|
||||
"hc.api.transports.curl.request",
|
||||
|
@ -153,7 +154,6 @@ class NotifyWebhookTestCase(BaseTestCase):
|
|||
self.assertEqual(args[0], "get")
|
||||
self.assertEqual(args[1], url)
|
||||
self.assertEqual(kwargs["headers"], {})
|
||||
self.assertEqual(kwargs["timeout"], 10)
|
||||
|
||||
@patch("hc.api.transports.curl.request", autospec=True)
|
||||
def test_webhooks_handle_variable_variables(self, mock_get: Mock) -> None:
|
||||
|
|
|
@ -258,7 +258,7 @@ class HttpTransport(Transport):
|
|||
json=json,
|
||||
headers=headers,
|
||||
auth=auth,
|
||||
timeout=10,
|
||||
timeout=30,
|
||||
)
|
||||
if r.status_code not in (200, 201, 202, 204):
|
||||
cls.raise_for_response(r)
|
||||
|
@ -278,7 +278,6 @@ class HttpTransport(Transport):
|
|||
headers: curl.Headers = None,
|
||||
auth: curl.Auth = None,
|
||||
) -> None:
|
||||
start = time.time()
|
||||
tries_left = 3 if retry else 1
|
||||
while True:
|
||||
try:
|
||||
|
@ -293,11 +292,9 @@ class HttpTransport(Transport):
|
|||
)
|
||||
except TransportError as e:
|
||||
tries_left = 0 if e.permanent else tries_left - 1
|
||||
|
||||
# If we have no tries left *or* have already used more than
|
||||
# 15 seconds of time then abort the retry loop by re-raising
|
||||
# If we have no tries left then abort the retry loop by re-raising
|
||||
# the exception:
|
||||
if tries_left == 0 or time.time() - start > 15:
|
||||
if tries_left == 0:
|
||||
raise e
|
||||
|
||||
# Convenience wrapper around self.request for making "POST" requests
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
{% site_name %} considers a HTTP request failed if:
|
||||
</p>
|
||||
<ul>
|
||||
<li>The destination server does not return a complete response within 10 seconds.</li>
|
||||
<li>The destination server does not return a complete response within 30 seconds.</li>
|
||||
<li>The HTTP response status code is not one of: 200, 201, 202 or 204.</li>
|
||||
</ul>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue