feat: add monitoring to cronjobs#1835
Conversation
|
Awesome to see healthchecks.io being used. Have you setup an account? We need to make sure one global KCI account is used with me/denys (@nuclearcat) (and you guys on it). Lets talk about this in tomorrows meeting |
Yeah, I have setup a personal account so I can test this later. Since this change won't stop the cronjobs that don't have monitoring we can go checking the accounts without blocking the PR. |
backend/kernelCI_app/management/commands/helpers/healthcheck.py
Outdated
Show resolved
Hide resolved
backend/kernelCI_app/management/commands/helpers/healthcheck.py
Outdated
Show resolved
Hide resolved
| if monitoring_path.startswith("http://") or monitoring_path.startswith("https://"): | ||
| return monitoring_path | ||
|
|
||
| return f"{HEALTHCHECK_BASE_URL.rstrip('/')}/{monitoring_path.lstrip('/')}" |
There was a problem hiding this comment.
nit: we can use urllib.parse.urljoin
There was a problem hiding this comment.
urljoin actually was a bit worse because if you join url/middle with end, it will result in url/end instead of url/middle/end. Formatting the strings seems to be safe for this operation
backend/kernelCI_app/management/commands/helpers/healthcheck.py
Outdated
Show resolved
Hide resolved
backend/kernelCI_app/management/commands/helpers/healthcheck.py
Outdated
Show resolved
Hide resolved
| if monitoring_path.startswith("http://") or monitoring_path.startswith("https://"): | ||
| return monitoring_path | ||
|
|
||
| return f"{HEALTHCHECK_BASE_URL.rstrip('/')}/{monitoring_path.lstrip('/')}" |
This comment was marked as duplicate.
This comment was marked as duplicate.
Sorry, something went wrong.
ed28904 to
d912983
Compare
d912983 to
dcbc86a
Compare
|
@bhcopeland all set up and tested, this is now ready for review. If you want to move forward with the healthcheck.io integration, I left some instructions on what to do. cc @nuclearcat |
Changes
How to test
For this PR, the ideal way to test would be with a healthcheck account and uuid so you can monitor the pings. Follow the instructions there to create an account and a check.
notifications --action=fake-reportand set a small interval, such as*/2 * * * *(run every 2 minutes)docker compose up backend --buildor locally withpoetry run ./manage.py crontab add(docker is the recommended way)The cronjobs should even if the ping fails or the monitoring_id is empty
Required production changes
Also set the request headers to
Content-Type: application/jsonCloses #1792