feat: shorter grace period for daily-billed VMs#153
Open
isolkewo wants to merge 5 commits into
Open
Conversation
Daily-billed (short-term) VMs now get a 1-day grace period before deletion (configurable via delete-after-daily), while monthly/yearly billed VMs keep the existing delete-after grace window (default: 3 days). - New config key: delete-after-daily (default: 1) - Worker's handle_subscription_state uses grace_period_days(sub) to pick the correct grace window based on subscription.interval_type - VmLineItemHandler::on_expired notification message now shows the correct per-interval grace period - VmProvisioner carries both delete_after and delete_after_daily
Contributor
|
Make the grace period tiered by age. Age | Grace |
isolkewo
commented
Jul 3, 2026
isolkewo
left a comment
Contributor
Author
There was a problem hiding this comment.
Thanks for the PR! The idea of having different grace periods for daily-billed vs monthly/yearly VMs makes sense.
However, I'd suggest considering the tiered approach based on VM age that I mentioned in the comments:
| Age (days) | Grace Period (days) |
|---|---|
| 1 | 1 |
| 7 | 2 |
| 28 | 7 |
| 180 | 14 |
This would provide more nuanced grace periods that reward long-term customers while still cleaning up short-lived VMs quickly. It could work alongside or instead of the billing interval approach.
What do you think?
added 3 commits
July 3, 2026 13:11
Replace the binary daily/monthly grace split with a tiered policy: Interval days Grace (days) ------------- ------------ ≤ 1 1 ≤ 7 2 ≤ 28 7 ≤ 180 14 > 180 delete_after The standalone pub fn grace_period_days_for_sub() computes interval days from interval_type × interval_amount, then maps to the appropriate grace tier. Both the worker's handle_subscription_state and the subscription's VmLineItemHandler::on_expired use the same function, removing the duplicate match. Removes the delete_after_daily config knob — the tiered policy is now hardcoded, with delete_after still configurable as a floor for longer intervals.
The tiered grace period is based on how long the subscription has existed (sub.created → now), not the billing interval length. Age (days) Grace (days) ---------- ------------ ≤ 1 1 ≤ 7 2 ≤ 28 7 ≤ 180 14 > 180 delete_after Newer subscriptions get shorter grace — a brand-new daily VM won't sit around for a week. Established subscriptions get more leeway.
v0l
approved these changes
Jul 3, 2026
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.
Daily-billed (short-term) VMs now get a 1-day grace period before
deletion (configurable via
delete-after-daily), while monthly/yearlybilled VMs keep the existing
delete-aftergrace window (default: 3 days).This means VMs paid for a single day/week/etc. are cleaned up after 1 day
instead of lingering for 3 days consuming host resources.
Changes:
delete-after-daily(default: 1, serde default so existing configs work unchanged)grace_period_days(sub)on Worker picks the right grace window based onsubscription.interval_typeVmLineItemHandler::on_expirednotification message now shows the correct per-interval grace periodVmProvisionerandWorkerSettingscarry bothdelete_afteranddelete_after_dailyBackward compatible:
delete-after-dailyhas a serde default of 1 so existing config files without it continue working. Monthly/yearly VMs are completely unaffected — same grace period, same behaviour.