Automated Trial Cleanup with Grace Period #583
No reviewers
Labels
No labels
API
Billing
UI/UX
dependencies
bug
change
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
servala/servala-portal!583
Loading…
Reference in a new issue
No description provided.
Delete branch "trial-cleanup-grace-period"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Trial cleanup: scale-down at expiration, grace period, and automated deletion
TL;DR — Give trial organizations a proper, safe end-of-life. When a trial expires, the org goes read-only and its instances are scaled down (stopped, not deleted). After a configurable grace period the org is automatically decommissioned (instances, namespaces, and org archived). Trial timings are aligned to human-friendly weekday mornings (10:00) so a stopped service is noticed during support hours, and the Odoo billing window is kept far enough ahead of the actual teardown that a trial is never invoiced.
The lifecycle
expiration_date(weekday 10:00)instances: 0(reusing the existingpause()primitive)deletion_date(weekday 10:00)Scale-down and deletion only apply when a grace period is configured; otherwise today's behavior (read-only, nothing deleted) is preserved.
Non-technical summary
Today, when a customer's free trial runs out, their organization is frozen (they can no longer change anything) and they receive reminder emails - but their services keep running indefinitely until someone on our team cleans them up by hand. Nothing is ever deleted automatically.
This plan gives trials a tidy, customer-friendly ending:
The grace period is optional per customer group: where none is configured, behavior stays exactly as today (frozen, but never deleted automatically).
What's new / changed
OrganizationLimitProfile.grace_period_days(nullable) gates the whole flow. Unset = no automated deletion. DerivedOrganizationproperties:deletion_date,days_until_deletion,is_pending_deletion.expiration_dateanddeletion_dateare rounded up to the next weekday at 10:00 (SERVALA_TRIAL_ACTION_HOUR/SERVALA_TRIAL_ACTION_TIMEZONE, defaultEurope/Zurich). Ceiling (never rounding earlier) guarantees a trial is never shortened and keeps the Odoo trial window forward-only for free.cleanup_expired_organizationsmanagement command (hourly cron,--dry-run,@scopes_disabled, per-org row lock) owns the full teardown: pause instances for expired-but-in-grace orgs, decommission orgs past grace. Best-effort per-instance pausing; failed decommissions are logged and retried next run.trial_end_date = (deletion_date or expiration_date) + 2h margin, pushed forward tonow + teardown_buffer + 2hright before decommission (SERVALA_TRIAL_TEARDOWN_BUFFER_DAYS, default 1). No analytic line can ever fall after the trial window, even across async K8s teardown lag.decommission_datestays informational only.validity_daysorgrace_period_dayschanges.send_expiration_reminders): existing 7/3/0-day emails reworded to mention that services are stopped at expiration and permanently deleted ondeletion_date, plus adeletion_1_dayfinal-notice email and a post-deletion confirmation email.grace_period_dayssurfaced on the limit-profile admin.Restore path
While an org is in grace it's read-only, so members can't self-resume. Support extends the trial (which lifts read-only); the member or support then resumes the stopped instances. No auto-unpause.
Safety / defaults
NULL).--dry-runtouches nothing (no Odoo, K8s, DB, or email).6ccef3355ff843fff26aWIP: Automated Trial Cleanup with Grace Periodto Automated Trial Cleanup with Grace Periodc1f3b638736ae0c91939