Skip to content

Added Cleanup Loop/Reaper for Expired TTL VMs#16

Merged
yulmwu merged 4 commits into
mainfrom
feat/cleanup-loop
May 28, 2026
Merged

Added Cleanup Loop/Reaper for Expired TTL VMs#16
yulmwu merged 4 commits into
mainfrom
feat/cleanup-loop

Conversation

@yulmwu

@yulmwu yulmwu commented May 28, 2026

Copy link
Copy Markdown
Member

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 vms table. By default, the cleanup loop runs every 30 minutes.

The newly added environment variable is as follows:

VM_CLEANUP_INTERVAL=30m

For more details, please refer to the changes included in this PR.

@yulmwu yulmwu requested a review from Copilot May 28, 2026 04:03
@yulmwu yulmwu added the enhancement New feature or request label May 28, 2026
@codecov

codecov Bot commented May 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 70.17544% with 17 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/service/vm_service.go 65.78% 7 Missing and 6 partials ⚠️
internal/repo/vm_repo.go 66.66% 2 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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.

Comment thread docs/docs/vms.md Outdated
Comment thread cmd/server/main.go Outdated
yulmwu and others added 3 commits May 28, 2026 13:15
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>
@yulmwu yulmwu merged commit 65525cf into main May 28, 2026
2 checks passed
@yulmwu yulmwu deleted the feat/cleanup-loop branch May 28, 2026 04:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants