Skip to content

feat: shorter grace period for daily-billed VMs#153

Open
isolkewo wants to merge 5 commits into
LNVPS:masterfrom
isolkewo:shorter-grace-daily-vms
Open

feat: shorter grace period for daily-billed VMs#153
isolkewo wants to merge 5 commits into
LNVPS:masterfrom
isolkewo:shorter-grace-daily-vms

Conversation

@isolkewo

@isolkewo isolkewo commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

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

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:

  • New config key: delete-after-daily (default: 1, serde default so existing configs work unchanged)
  • grace_period_days(sub) on Worker picks the right grace window based on subscription.interval_type
  • VmLineItemHandler::on_expired notification message now shows the correct per-interval grace period
  • VmProvisioner and WorkerSettings carry both delete_after and delete_after_daily

Backward compatible: delete-after-daily has a serde default of 1 so existing config files without it continue working. Monthly/yearly VMs are completely unaffected — same grace period, same behaviour.

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
@v0l

v0l commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Make the grace period tiered by age.

Age | Grace
1, 1
7, 2
28, 7
180, 14

@isolkewo isolkewo left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

isolkewo 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants