Commit graph

193 commits

Author SHA1 Message Date
Pēteris Caune
7836da6448
Update settings.py to allow subpath in SITE_ROOT
If SITE_ROOT contains a subpath
(e.g., "http://example.org/healthchecks"), settings.py now adjusts
FORCE_SCRIPT_NAME and STATIC_URL.

Also, hc.lib.urls.absolute_reverse() now recognizes subpath in
SITE_ROOT, and makes sure it does not show up twice in the
generated URLs.

cc: #1091
2024-12-04 10:37:52 +02:00
Pēteris Caune
22268c1484
Move absolute URL construction to hc.lib.urls.absolute_reverse()
absolute_reverse() works the same as django.urls.reverse()
except it generates absolute URLs (starting with http[s]://)
2024-12-03 17:24:27 +02:00
Pēteris Caune
e048ec4c48
Fix "class Foo(object):" -> "class Foo:"
In Python 3 these are equivalent, and shorter is better.
2024-10-29 17:57:50 +02:00
Pēteris Caune
9660bc293c
Update hc.lib.s3 to retry failed requests *one time* 2024-07-17 17:26:49 +03:00
Pēteris Caune
ce5d9bcf56
Re-enable S3 retries 2024-07-17 17:04:33 +03:00
Pēteris Caune
1877a8324f
Disable S3 API request retries
urrlib3's default number of retries is 3.
If requests to the S3 API are timing out, the retries usually
don't help, but a 10-second timeout turns into 10*3=30 seconds
of python code being blocked.
2024-07-12 03:09:21 +03:00
Pēteris Caune
8d0930c4b9
Fix unclosed sockets in statsd tests 2024-06-27 11:03:29 +03:00
Pēteris Caune
1a5ca45d09
Fix InvalidResponseError() initialization parameters 2024-06-20 15:15:14 +03:00
Pēteris Caune
9dbd961beb
Add test case for InvalidResponseError handling 2024-06-20 15:11:42 +03:00
Pēteris Caune
475bdff87d
Add handling for minio.InvalidResponseError exceptions 2024-06-18 23:50:11 +03:00
Pēteris Caune
b2c5e91c70
Implement legacy -> canonical timezone conversion
There are three related changes:

* Removed legacy timezones from hc.lib.tz.all_timezones
* Added data migration to update existing Check.tz values
* For backwards compatibility, added code to automatically
  replace a legacy timezone with a canonical timezone when a
  legacy timezone is passed to an API call

I used the timezone mapping on
https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
2024-06-14 12:55:57 +03:00
Pēteris Caune
c5bd666faf
Add data migration to update timezone "Europe/Kiev" to "Europe/Kyiv" 2024-06-13 15:03:51 +03:00
Pēteris Caune
66d482c4af
Disable a type warning related to statsd having no type hints yet
python-statsd does have a PR for adding type hints, so
hopefully this is temporary.
2024-05-01 11:39:20 +03:00
Pēteris Caune
5b905c1cbc
Bump django-stubs-ext to 5.0.0 2024-05-01 11:11:54 +03:00
Pēteris Caune
22325565b5
Remove unused import 2024-03-18 13:02:46 +02:00
Pēteris Caune
3615d26aea
Remove debug statement 2024-03-18 12:56:18 +02:00
Pēteris Caune
274a59956a
Make statsd metrics collection optional
To enable, set STATSD_HOST env var (or set STATSD_HOST in
local_settings.py):

STATSD_HOST=localhost:1234

cc: #974
2024-03-18 12:55:36 +02:00
Pēteris Caune
4959856e58
Redesign the "Status Badges" page 2024-02-26 12:34:26 +02:00
Pēteris Caune
4d0cf7fb80
Remove @nolog decorator
The purpose of @nolog was to disable logging in certain
test cases to avoid console spam during tests. But with the
current logging configuration console is clean even without it.
2024-02-06 17:30:24 +02:00
Pēteris Caune
7cb47188b9
Remove redundant cast 2024-01-22 16:09:20 +02:00
Pēteris Caune
42f88f4fb0
Add S3_SECURE setting
It controls whether to use secure (TLS) connection to S3 or not.
2024-01-10 12:19:45 +02:00
Pēteris Caune
ae94648efd
Fix minio-related mypy warnings
A few warnings remain, I think these should be fixed in minio-py:

https://github.com/minio/minio-py/pull/1389
2024-01-04 16:01:34 +02:00
Pēteris Caune
767c3ae702
Add a management command for pruning all checks 2023-12-21 14:55:05 +02:00
Pēteris Caune
b9df18728a
Improve error logging in hc.lib.s3._remove_objects 2023-11-24 10:11:31 +02:00
Pēteris Caune
96823a7f90
Add logging for failed webauthn key registrations 2023-11-17 16:06:39 +02:00
Pēteris Caune
2a2c7d66ec
Fix mypy warning 2023-11-15 10:22:22 +02:00
Pēteris Caune
cff4138774
Fix webauthn registration failure on Firefox with Bitwarden extension 2023-11-15 10:13:40 +02:00
Pēteris Caune
ec9649a6a6
Fix logging calls to avoid string formatting in client code 2023-10-27 10:33:55 +03:00
Pēteris Caune
ab7449a279
Improve type hints in hc.lib.s3 2023-10-26 10:19:28 +03:00
Pēteris Caune
d059431b08
Improve type hints in hc.lib.webauthn 2023-10-26 10:14:30 +03:00
Pēteris Caune
343e55bd4f
Improve type hints 2023-10-25 18:12:12 +03:00
Pēteris Caune
232f534bc0
Improve type hints in hc.lib.curl 2023-10-25 14:47:52 +03:00
Pēteris Caune
8b006e0d58
Move nolog decorator to hc.test so it can be reused 2023-10-25 13:48:55 +03:00
Pēteris Caune
7e503d9c33
Move the "join Matrix room" code to hc.lib.matrix 2023-10-23 09:32:03 +03:00
Pēteris Caune
5911075282
Fix HTTP verb in hc.lib.curl.post 2023-10-22 12:38:44 +03:00
Pēteris Caune
30a3a784c3
Move AuthenticatedHttpRequest to hc.accounts.http module
If AuthenticatedHttpRequest lives in the hc.lib.typealias
module then hc.lib.typealias imports User and Profile,
and so needs configured Django settings. Most of the stuff
in hc.lib is intended to work standalone, and not rely on Django.
2023-10-21 18:16:48 +03:00
Pēteris Caune
470f70b164
Update curl.get and curl.post to closer match requests fn signatures
In requests, "params" is a positional argument for the get function:

    requests.get(url, params=None, **kwargs)

So I made params positional here too.

In requests, "data" is a positional argument for the post function:

    requests.post(url, data=None, json=None, **kwargs)

So I data positional here too.
2023-10-21 11:45:45 +03:00
Pēteris Caune
7c7774d18c
Replace **kwargs with explicit keyword arguments in hc.lib.curl
This makes the code more verbose, but at the same time
makes type hinting cleaner, and allows mock autospeccing
to catch more problems.
2023-10-21 11:21:42 +03:00
Pēteris Caune
52ab8c4703
Improve type hints in hc.lib.curl and hc.api.transports
This results in changes in other places too:

* curl.post() does not accept `data` as positional arg,
  it must now be a keyword argument
* we need asserts and if clauses in a few places to make sure
  we are not passing `None` in the arguments to hc.lib.curl.request
2023-10-20 19:11:08 +03:00
Pēteris Caune
42a137e128
Switch to pydantic for validating Telegram incoming webhooks 2023-10-17 16:10:35 +03:00
Pēteris Caune
5d99c544ee
Increase the precision in hc.lib.date.format_approx_duration
Format durations in one of the following forms:

* "{x} days {y} h"
* "{y} h {z} min"
* "{z} min {w} sec"
2023-10-02 12:50:59 +03:00
Pēteris Caune
58d7c8cc55
Simplify DowntimeSummary 2023-09-27 17:16:16 +03:00
Pēteris Caune
f7af738c76
Add monthly uptime percentage display in Check Details page
Fixes: #773
2023-09-27 13:44:35 +03:00
Pēteris Caune
e48d361331
Fix time interval formatting in check details - downtime summary
In hc.lib.date.format_approx_duration, we were calling
timedeltaobj.total_seconds() and basing all calculations off that.
This method returns float, so the final result was "2.0 hours" or
"3.0 days" and similar. We now convert it to int, to get "2 hours",
"3 days" etc.
2023-09-26 10:30:34 +03:00
Pēteris Caune
ee40cd8dab
Fix type warnings 2023-09-08 16:47:27 +03:00
Pēteris Caune
5746bbb015
Improve type hints in hc.api.models 2023-09-08 15:58:39 +03:00
Pēteris Caune
92bf9773dc
Improve type hints in hc.lib 2023-09-08 13:05:19 +03:00
Pēteris Caune
9173475194
Improve type hints in hc.api.views 2023-09-07 14:38:55 +03:00
Pēteris Caune
05d2d0065e
Remove usage of backports.zoneinfo 2023-09-06 12:54:27 +03:00
Pēteris Caune
c9bf3132fe
Replace usage of typing.List, typing.Optional etc. with modern syntax 2023-09-06 11:27:43 +03:00