Commit graph

1981 commits

Author SHA1 Message Date
Pēteris Caune
a2c7259d1b
Fix redirects after login when using a path in SITE_ROOT
Fixes: #382

cc: #1091
2024-12-09 12:35:02 +02:00
Pēteris Caune
0ee3f03baf
Fix redirect to login when SITE_ROOT contains a path
cc: #382, #1091
2024-12-09 12:20:09 +02:00
Pēteris Caune
b685e66b71
Add a workaround for reverse() omitting script prefix when on thread
https://code.djangoproject.com/ticket/35985

cc: #1091
2024-12-09 11:53:53 +02:00
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
5e848f4976
Add index on api_flip (owner_id, created)
This helps queries in hc.front.views._get_events,
especially for checks that are flipping between up and down
states a lot.
2024-12-03 10:37:01 +02:00
Pēteris Caune
4a618cd7e9
Fix elf -> self 2024-12-02 11:32:53 +02:00
Jacek Kowalski
8485c758eb
Fix Trello integration (token regexp too specific) (#1094)
* Fix Trello configuration failing with HTTP 400

* Add additional tests regarding Trello token
2024-12-02 11:31:02 +02:00
Pēteris Caune
cb7e53677d
Increase ntfy.sh topic max length to 64 2024-11-25 11:16:15 +02:00
Pēteris Caune
62b10be5fe
Implement "no matching checks" message when searching/filtering
(instead of showing a table with a header row and no data rows)
2024-11-15 12:11:18 +02:00
Pēteris Caune
5ecea08e48
Fix type annotation 2024-11-14 14:28:47 +02:00
Pēteris Caune
b328c8739f
Reduce the number of Check.get_status() calls 2024-11-14 13:33:21 +02:00
Pēteris Caune
7c8d43414f
Implement filtering by status on the server side 2024-11-14 12:27:31 +02:00
Pēteris Caune
5c67c94654
Add a missing article 2024-11-08 11:31:09 +02:00
Pēteris Caune
5912758a8a
Update email alerts to mention failure reason
cc: #1069
2024-11-08 11:20:44 +02:00
Pēteris Caune
9edae634c7
Add Flip.reason field
cc: #1069
2024-11-08 10:24:50 +02:00
Pēteris Caune
79da9e9f4f
Fix auto-fixable ruff warnings
(`ruff check --fix`)
2024-11-07 15:15:58 +02:00
Pēteris Caune
4907073c55
Remove unneeded quotes 2024-11-06 19:32:44 +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
a6ca589b34
Fix pyright warning 2024-10-29 11:54:48 +02:00
Pēteris Caune
c372e3232f
Update MS Teams legacy webhook retirement date to Jan 2025
Microsoft pushed it forward again:
https://devblogs.microsoft.com/microsoft365dev/retirement-of-office-365-connectors-within-microsoft-teams/
2024-10-25 09:51:58 +03:00
Pēteris Caune
e3cbe79f57
Update CustomHeaderMiddleware to normalize email addresses to lower case
Also add a data migration to normalize any already existing user
accounts with non-lower-case email addresses too.

Fixes: #1074
2024-10-24 13:22:37 +03:00
Pēteris Caune
374f034bf9
Update check's status text to show how long it has been running
In check's details page, we have a "Current Status" section.
It shows an icon, a status text, and a table with downtime
statistics. When the check has received a start signal, the icon
also has an animated progress indicator under it.

With this change, the status text will also indicate the running
state and the elapsed time. Example:

"Currently running, started 3 minutes ago".
2024-10-23 14:14:44 +03:00
Pēteris Caune
9e69b5b5f5
Fix smtp listener to reject email addresses with unexpected domain
cc: #1077
2024-10-21 17:48:57 +03:00
Pēteris Caune
84f22c8978
Fix type warnings 2024-10-21 17:34:02 +03:00
Pēteris Caune
a5d4dc2db5
Fix smtp listener to reject email addresses with non-UUID local parts
cc: #1077)
2024-10-21 15:56:24 +03:00
Pēteris Caune
c91213179f
Fix API to gracefully handle too long slugs 2024-10-16 12:35:30 +03:00
Pēteris Caune
8c210e151f
Update the Signal integration to retry on network errors 2024-10-14 11:19:37 +03:00
Pēteris Caune
d574fa65fc
Update _refresh_last_active_date to also refresh user session
Fixes: #1063
2024-10-10 15:41:00 +03:00
Pēteris Caune
4f9b0b11b9
Update Signal transport to log unexpected signal-cli replies
When signal-cli returns an error that we are not handling yet,
log the precise JSON message that signal-cli returns. This
is for debug & development: We can look at the logged messages
and see what additional special error handling may be needed.
2024-10-10 10:21:08 +03:00
Pēteris Caune
e49b5f8fbd
Remove LINE Notify onboarding form
LINE Notify is shutting down on Apr 1, 2025:
https://notify-bot.line.me/closing-announce

I'm removing the onboarding form so people don't set up new
integrations that will stop working in 5 months.

The code for sending LINE Notify notifications still exists,
and the existing integrations will continue to work (until LINE
Notify stops working).
2024-10-08 09:13:03 +03:00
Pēteris Caune
fd96cc794b
Remove unused bits 2024-10-04 17:34:30 +03:00
Pēteris Caune
a51420744c
Add RiskCheck: disable in SMS transport
This is to reduce the chance of hitting Twilio error 30453,
"Message couldn't be delivered".

https://www.twilio.com/docs/api/errors/30453
2024-10-02 17:01:23 +03:00
Pēteris Caune
de4c4897e3
Remove prunenotifications management command
Notifications are now cleaned up automatically during pinging.
2024-10-02 09:24:01 +03:00
Pēteris Caune
13f92b90ef
Update settings.py to read SECURE_PROXY_SSL_HEADER from env vars
And add it to docs.

And add a system check to make sure it, if set, is a tuple
with 2 elements.

cc: #851
2024-10-01 19:13:26 +03:00
Pēteris Caune
e73d7a1ece
Remove pruneflips management command
Flips are now cleaned up automatically during pinging.
2024-10-01 15:33:56 +03:00
Pēteris Caune
12cccaf7d1
Fix Project.num_checks naming collision
The Project model has (well, had) a num_checks() method.
In the project admin we are also annotating project queryset
with a "num_checks" property. Using the same name for two different
things causes type confusion for mypy and can also lead to
coding accidents.

This commit removes the Project.num_checks() method. This was easier
to do than changing admin, as the method is very simple and was used
in only two places.
2024-09-24 10:18:22 +03:00
Pēteris Caune
2cb47d3742
Make the sorting of null values in Flip.select_channels() explicit 2024-09-12 10:52:06 +03:00
Pēteris Caune
f241d070e1
Update Flip.select_channels() to sort channels by last_notify_duration
If a check has multiple associated channels, some are slow and
some are quick, handle the quick ones first.
2024-09-12 10:44:56 +03:00
Pēteris Caune
f60af9a156
Update ntfy integration to give up db connection before network IO 2024-09-12 10:30:58 +03:00
Pēteris Caune
28af3720f4
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.
2024-09-11 12:37:40 +03:00
Pēteris Caune
13217af304
Add --pool parameter in manage.py sendalerts
If sendalerts receives this parameter, it reconfigures
settings.DATABASES to enable db connection pooling
(using psycopg_pool with default parameters).

This lets us use many concurrent worker threads but not
run out of database connections. For example, with
`--num-workers 100 --pool`, up to 100 worker threads can run
concurrently, but only 3 threads can get a database connection
from the pool, the rest have to wait. When a worker thread
gives up a connection (by calling `close_old_connections`),
another thread can continue.

A worker thread can give up a db connection before it is fully
finished if it anticipates a long network IO operation ahead.
The Webhook transport does this before making a curl call.

psycopg_pool's default pool size is 4 connections. One
connection is used up by the main thread, so 3 connections
are available for the worker threads.
2024-09-10 14:58:24 +03:00
Pēteris Caune
8eecece0bb
Add db migration for the updated msteams name 2024-09-10 14:45:48 +03:00
Pēteris Caune
fd0c428e29
Update sqlite settings to avoid "Database is locked" errors
Fixes: #1057

"PRAGMA busy_timeout" configures the database to wait when a
database is locked instead of giving up immediately.

"transaction_mode IMMEDIATE" starts transactions in read/write
mode, required to make busy_timeout work.

Reference: https://gcollazo.com/optimal-sqlite-settings-for-django/
2024-09-09 10:11:22 +03:00
Pēteris Caune
6bf588d984
Remove unused import 2024-09-04 10:49:09 +03:00
Pēteris Caune
9d4fc031aa
Fix sendalerts to check the self.shutdown flag more often 2024-09-03 10:30:18 +03:00
Pēteris Caune
3275e0ffaa
Update notify() to return logs instead of printing them 2024-09-03 10:23:15 +03:00
Pēteris Caune
8c56ca6dde
Update sendalerts to mark flip as processed on thread
Previously this was done in process_one_flip (so on the main thread).
The advantage of doing this way is the flip gets marked as processed
only when the thread has started and has acquired a db connection.
There is now a smaller pause between a sendalerts process claiming a
flip, and actually starting work on it.
2024-09-01 15:28:48 +03:00
Pēteris Caune
fd75049e0c
Fix type warnings 2024-08-31 19:23:10 +03:00
Pēteris Caune
a463daa775
Update Webhook transport to close db connection before network IO
Webhook requests can take 20+ seconds. During that time we hold
on to a database connection. With this commit, the Webhook transport
closes its DB connection before making a curl call.

With psycopg2 this does not have much effect. But with
psycopg 3 & connection pooling we will be able to use more
sendalerts workers than we have database connections. While one
worker is busy making a slow curl call, another worker can
grab its freed up connection and do some work.

Django's test runner is not happy with connections closed
mid-test, so I patched out close_old_connections() in affected tests.
2024-08-31 19:18:17 +03:00