-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Sentry monitoring for cron jobs #2275
Conversation
c1e8c97
to
045a62e
Compare
This is in draft and you asked in Slack for an in-flight review. What's left to do? The simplified approach you point to in #2279 looks like it would have worked okay but I agree that DRY is preferable for the actual HTTP API interactions as there's a bit of processing and logic to do, which is more manageable and extensible when centralized. I really like automating the deployment steps and getting the schedule from config. How have you tested what you've done so far? I guess for bash scripts automated testing will be a bit tricky? I like the cron jobs docs added to How does this compare to our approach in Job Server? I think we use the SDK/CLI approach there but to be honest I haven't understood how it works there from looking for a few minutes. |
We do use the Python SDK since Job Server has its own job scheduling system (why yes, that is another overload for job) which is all Python and so we can use the (far nicer) Python SDK. In this case it's all bash scripts so making HTTP requests with CURL is the most universally compatible approach. If we were, for example, to write a small python wrapper for the SDK we couldn't necessarily rely on the SDK being installed in every python environment these bash scripts get called from. |
It's tricky for sure. I've tested by calling From poking at the web UI, it's possible to create a monitor with a failure threshold of 720 missed "check-ins", a missed "check in" threshold of 525,600 mins and a check-in timeout of 40,320 mins so having a test that hits a designated test monitor with these configured values should hopefully reduce/avoid notification noise for the team. |
5acd2eb
to
7e2c01a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good now, good job. Made some minor comments on docs.
Write key sentry-specific functions into own .sh file and source into scripts to be monitored, allowing for them to be tested independently. Testing the HTTP actions requires an out-of-test-process accessible HTTP server (e.g. pytest_httpserver) rather than, for example `responses` and so our usual approach to mocking HTTP requests doesn't work here. Assuming the URL and the params are constructed correctly (which these tests test) then this is a relatively low-risk thing to leave un-tested.
The three separate cronfiles only differ in the arg with which the import_latest_release script is called and their schedules. These can all be consolidated into a single cronfile with a line for each invocation. This simplifies the deployment to /etc/cron.d/ and allows for this to be scripted and the variables to be templated, ensuring consistency of deployment.
This previously was a manual task described in a comment in `import_latest_release.sh`, make it automatic.
7e2c01a
to
d7eb6bd
Compare
fixes #2257