Added Cleanup Loop/Reaper for Expired TTL VMs#16
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds automatic cleanup for expired VM database rows so stale VM records no longer remain indefinitely after their TTL passes.
Changes:
- Adds VM cleanup configuration via
VM_CLEANUP_INTERVAL. - Adds service/repo cleanup logic plus a background TTL reaper.
- Adds tests and documentation for expired VM row cleanup behavior.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
internal/service/vm_service.go |
Adds per-user expired VM cleanup and background TTL reaper logic. |
internal/service/vm_service_test.go |
Adds service tests for cleanup behavior. |
internal/repo/vm_repo.go |
Adds bulk deletion of expired VM rows. |
internal/repo/vm_repo_test.go |
Adds repository coverage for expired-row deletion. |
internal/config/config.go |
Adds cleanup interval config loading, validation, and logging. |
internal/config/config_test.go |
Adds config tests for cleanup interval defaults/custom/invalid values. |
docs/docs/vms.md |
Updates VM documentation for automatic cleanup behavior. |
cmd/server/main.go |
Starts the VM TTL reaper during server startup. |
.env.example |
Documents VM_CLEANUP_INTERVAL. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, even after a VM's TTL had expired, it remained in the platform database unless manually deleted.
Since this could cause UX issues, this PR adds logic to periodically remove expired VMs from the
vmstable. By default, the cleanup loop runs every 30 minutes.The newly added environment variable is as follows:
VM_CLEANUP_INTERVAL=30mFor more details, please refer to the changes included in this PR.