quick fix to update the default TTL from 7 days to 14 days#1136
Conversation
… agents and jobs from disappearing within a given reservation time
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1136 +/- ##
=======================================
Coverage 77.90% 77.90%
=======================================
Files 118 118
Lines 12350 12350
Branches 1018 1018
=======================================
Hits 9621 9621
Misses 2508 2508
Partials 221 221
*This pull request uses carry forward flags. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR increases the server’s default MongoDB TTL window from 7 days to 14 days to reduce the likelihood that jobs/logs/artifacts/agents/advertised queues expire while still relevant to longer-running reservations.
Changes:
- Updated the shared
DEFAULT_EXPIRATIONTTL constant from 7 days to 14 days. - Updated inline comments describing TTL behavior to match the new 14-day expiration.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def create_indexes(): | ||
| """Initialize collections and indexes in case they don't exist already.""" | ||
| # Automatically expire jobs after 7 days if nothing runs them | ||
| # Automatically expire jobs after 14 days if nothing runs them | ||
| mongo.db.jobs.create_index( | ||
| "created_at", expireAfterSeconds=DEFAULT_EXPIRATION | ||
| ) |
| # Remove logs after 14 days | ||
| mongo.db.logs.create_index( | ||
| "updated_at", expireAfterSeconds=DEFAULT_EXPIRATION | ||
| ) |
| # Remove artifacts after 14 days | ||
| mongo.db["fs.chunks"].create_index( | ||
| "uploadDate", expireAfterSeconds=DEFAULT_EXPIRATION | ||
| ) | ||
| mongo.db["fs.files"].create_index( | ||
| "uploadDate", expireAfterSeconds=DEFAULT_EXPIRATION | ||
| ) |
| # Remove agents that haven't checked in for 14 days | ||
| mongo.db.agents.create_index( | ||
| "updated_at", expireAfterSeconds=DEFAULT_EXPIRATION | ||
| ) |
| # Remove advertised queues that haven't updated in over 14 days | ||
| mongo.db.queues.create_index( | ||
| "updated_at", expireAfterSeconds=DEFAULT_EXPIRATION | ||
| ) |
rene-oromtz
left a comment
There was a problem hiding this comment.
Thanks for the quick fix, increasing to 14 days makes sense, following Copilot suggestion, can you please use collMod instead. This is also the suggestion from MongoDB Docs:
https://www.mongodb.com/docs/manual/tutorial/manage-indexes/#modify-an-index
The issue that I'm having with this suggestion is that the code we have in place appears to be for creating the db schema in cases where it does not yet exist, yet the use of The two cases: create vs modify should be differentiated better and proper hooks be put in place such that they are called at the right time. In a k8s environment, only the very first workload in the pod needs to configure the database, and even then if the database exists the actions would be different than when the database doesn't exist. |
|
I think the proposal of a helper
Perhaps this could be helpful in case we ever want to tweak any other TTL |
Description
Resolved issues
N/A
Documentation
N/A — this is an internal TTL configuration change in the server database setup. No public documentation changes are required.
Web service API changes