-
Notifications
You must be signed in to change notification settings - Fork 29
implement stale node cleanup functionality and configuration #540
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
base: main
Are you sure you want to change the base?
Conversation
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.
Pull request overview
This PR introduces a configurable background cleanup feature to automatically remove incomplete/stale node records from the database. The implementation adds a new Cleanup module that identifies and removes nodes with default Meshtastic names and missing hardware information after a configurable minimum age. The feature is disabled by default and can be enabled via the STALE_NODE_CLEANUP_INTERVAL environment variable.
Key changes:
- Added
Cleanupmodule with automatic stale node removal based on configurable age and interval - Introduced two environment variables:
STALE_NODE_CLEANUP_INTERVAL(default: 0/disabled) andSTALE_NODE_MIN_AGE(default: 168 hours) - Integrated cleanup thread lifecycle management into the main application startup
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
web/lib/potato_mesh/application/cleanup.rb |
New module implementing stale node detection and cleanup logic with background thread management |
web/lib/potato_mesh/config.rb |
Added configuration methods for cleanup interval and minimum age with environment variable parsing |
web/lib/potato_mesh/application.rb |
Integrated Cleanup module and thread startup into application lifecycle |
README.md |
Documented new environment variables with defaults and usage examples |
web/spec/cleanup_spec.rb |
Comprehensive test coverage for cleanup functionality and configuration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
How do you determine a stale node though? |
i use the logic that was suggested here : #473 and I leave it up to the admin to decide the appropriate time frame for stale consideration. |
|
I'll review this for the next release |
This pull request introduces a new background cleanup feature to automatically remove stale or incomplete node records from the database.
Based on this : #473
The feature is configurable via environment variables and is disabled by default. Key changes include the addition of the
Cleanupmodule, configuration options for cleanup scheduling and criteria, and integration of the cleanup process into the application lifecycle.Background node cleanup feature:
Cleanupmodule (web/lib/potato_mesh/application/cleanup.rb) that provides methods to prune stale nodes, run cleanup cycles, and manage a background cleanup thread. Stale nodes are defined as those with default names and missing hardware model info, and older than a configurable minimum age.Configuration and environment variables:
README.md:STALE_NODE_CLEANUP_INTERVAL(hours between cleanup cycles, default disabled) andSTALE_NODE_MIN_AGE(minimum node age in hours before cleanup, default 168).Configto handle cleanup interval and minimum age, including helper methods for conversion and validation. [1] [2]Integration with application lifecycle:
Cleanupmodule in the main application class to ensure its methods are available and its thread is managed alongside other core features. [1] [2] [3] [4]