diff --git a/docs/deployment.md b/docs/deployment.md
index 5781c46..10ac154 100644
--- a/docs/deployment.md
+++ b/docs/deployment.md
@@ -1152,6 +1152,12 @@ jobs use their own configured runtimes. Use a versioned command such as
### Configure PHP pool limits per website
+Use **Unlimited** in a hosting package to remove its website, scheduled task,
+database, mailbox, or storage limit. A manager package can give managers an
+unlimited number of hosting accounts within the selected hosting packages.
+Enter `0` in the scheduled task, database, mailbox count, or manager account
+field to block creation of those resources.
+
Under **Hosting packages**, set default PHP memory, upload size, request timeout,
or PHP-FPM worker limits. The panel captures these values when an operator
first requests local activation. A repeat activation preserves an installed
@@ -1162,6 +1168,8 @@ the current plan defaults. This requires permission to view the account and
**Can change site php settings**. Plan edits and reassignment take effect
when an operator reapplies the defaults. Leave individual values blank to use
the web node defaults. Coulobre's default pool allows two workers.
+Select **Unlimited** for a PHP memory, upload, or request timeout override to
+remove that cap at the PHP pool. PHP-FPM always needs a finite worker limit.
The upload setting applies per file. The pool sets the maximum POST body to
one MiB above the chosen upload size. When both limits are set, choose a memory
diff --git a/pyproject.toml b/pyproject.toml
index 755c1eb..bad4fed 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "coulobre-panel"
-version = "0.13.0rc4"
+version = "0.13.0rc5"
description = "A web hosting control panel for hosting providers and resellers."
readme = "README.md"
requires-python = ">=3.12"
diff --git a/src/coulobre/hosting/account_administration.py b/src/coulobre/hosting/account_administration.py
index 03aa1a4..de47d5e 100644
--- a/src/coulobre/hosting/account_administration.py
+++ b/src/coulobre/hosting/account_administration.py
@@ -464,9 +464,7 @@ class MoveHostingView(OperatorAuthorization, FormView):
allowed_plans = set(
destination.hosting_plans.values_list("pk", flat=True)
)
- if destination.hostingaccount_set.count() + len(
- moving
- ) > destination.account_limit or any(
+ if not destination.has_account_capacity(len(moving)) or any(
item.hosting_plan_id not in allowed_plans for item in moving
):
raise ValidationError(
diff --git a/src/coulobre/hosting/independent_websites.py b/src/coulobre/hosting/independent_websites.py
index 7f8081f..57f0375 100644
--- a/src/coulobre/hosting/independent_websites.py
+++ b/src/coulobre/hosting/independent_websites.py
@@ -86,9 +86,13 @@ def create_website(account_id, domain, version, actor):
account = lock_hosting_account(account_id, customer_id=None)
check_actor(account, actor)
require_active_services(account)
- if account_websites(account).filter(
- retired_at__isnull=True
- ).count() + 1 >= website_limit(account):
+ limit = website_limit(account)
+ if (
+ limit is not None
+ and account_websites(account).filter(retired_at__isnull=True).count()
+ + 1
+ >= limit
+ ):
raise ValidationError(
"This hosting account has reached its website limit."
)
diff --git a/src/coulobre/hosting/limit_forms.py b/src/coulobre/hosting/limit_forms.py
new file mode 100644
index 0000000..bee8c72
--- /dev/null
+++ b/src/coulobre/hosting/limit_forms.py
@@ -0,0 +1,65 @@
+from django import forms
+from django.core.exceptions import ValidationError
+
+
+class LimitWidget(forms.MultiWidget):
+ template_name = "hosting/limit_widget.html"
+ use_fieldset = False
+
+ def __init__(self, numeric, label, unlimited_value):
+ self.unlimited_value = unlimited_value
+ checkbox = forms.CheckboxInput(
+ attrs={"aria-label": f"Unlimited {label}"}
+ )
+ super().__init__({"": numeric, "unlimited": checkbox})
+
+ def decompress(self, value):
+ unlimited = value == self.unlimited_value
+ return [None if unlimited else value, unlimited]
+
+ def id_for_label(self, id_):
+ return f"{id_}_0" if id_ else ""
+
+
+class LimitField(forms.MultiValueField):
+ def __init__(self, number, *, allow_blank=False, unlimited_value=None):
+ self.allow_blank = allow_blank
+ self.unlimited_value = unlimited_value
+ super().__init__(
+ fields=(number, forms.BooleanField(required=False)),
+ widget=LimitWidget(number.widget, number.label, unlimited_value),
+ label=number.label,
+ help_text=number.help_text,
+ initial=number.initial,
+ require_all_fields=False,
+ required=False,
+ )
+
+ def clean(self, value):
+ number, unlimited = value or (None, False)
+ if unlimited:
+ return self.unlimited_value
+ number = self.fields[0].clean(number)
+ if number is None and not self.allow_blank:
+ raise ValidationError("Enter a limit or select Unlimited.")
+ return number
+
+ def compress(self, data_list):
+ return data_list[0] if data_list else None
+
+ def has_changed(self, initial, data):
+ try:
+ return self.clean(data) != initial
+ except ValidationError:
+ return True
+
+
+def add_unlimited_fields(
+ form, fields, *, allow_blank=(), unlimited_value=None
+):
+ for name in fields:
+ form.fields[name] = LimitField(
+ form.fields[name],
+ allow_blank=name in allow_blank,
+ unlimited_value=unlimited_value,
+ )
diff --git a/src/coulobre/hosting/migrations/0081_unlimited_package_limits.py b/src/coulobre/hosting/migrations/0081_unlimited_package_limits.py
new file mode 100644
index 0000000..9afdb5e
--- /dev/null
+++ b/src/coulobre/hosting/migrations/0081_unlimited_package_limits.py
@@ -0,0 +1,94 @@
+# Generated by Django 5.2.19 on 2026-11-24 13:23
+
+import django.core.validators
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("hosting", "0080_invitation_mail_settings"),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="hostingplan",
+ name="php_memory_limit_mib",
+ field=models.PositiveIntegerField(
+ blank=True,
+ help_text="Leave blank to use the web node default.",
+ null=True,
+ validators=[
+ django.core.validators.MinValueValidator(0),
+ django.core.validators.MaxValueValidator(4096),
+ ],
+ verbose_name="PHP memory limit (MiB)",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="hostingplan",
+ name="php_request_timeout_seconds",
+ field=models.PositiveIntegerField(
+ blank=True,
+ help_text="Leave blank to use the web node default.",
+ null=True,
+ validators=[
+ django.core.validators.MinValueValidator(0),
+ django.core.validators.MaxValueValidator(600),
+ ],
+ verbose_name="PHP request timeout (seconds)",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="hostingplan",
+ name="php_upload_limit_mib",
+ field=models.PositiveIntegerField(
+ blank=True,
+ help_text="Leave blank to use the web node default.",
+ null=True,
+ validators=[
+ django.core.validators.MinValueValidator(0),
+ django.core.validators.MaxValueValidator(512),
+ ],
+ verbose_name="PHP upload limit (MiB)",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="hostingplan",
+ name="website_job_limit",
+ field=models.PositiveSmallIntegerField(
+ blank=True,
+ default=0,
+ help_text=(
+ "Maximum saved jobs per account. "
+ "Enter 0 to disable scheduling."
+ ),
+ null=True,
+ validators=[django.core.validators.MaxValueValidator(50)],
+ ),
+ ),
+ migrations.AlterField(
+ model_name="hostingplan",
+ name="website_limit",
+ field=models.PositiveSmallIntegerField(
+ blank=True,
+ default=1,
+ help_text=(
+ "Maximum independent websites, including the primary site."
+ ),
+ null=True,
+ validators=[django.core.validators.MinValueValidator(1)],
+ ),
+ ),
+ migrations.AlterField(
+ model_name="reseller",
+ name="account_limit",
+ field=models.PositiveIntegerField(
+ blank=True, default=0, null=True
+ ),
+ ),
+ migrations.AlterField(
+ model_name="resellerprofile",
+ name="account_limit",
+ field=models.PositiveIntegerField(blank=True, null=True),
+ ),
+ ]
diff --git a/src/coulobre/hosting/models.py b/src/coulobre/hosting/models.py
index 85488f5..6320c48 100644
--- a/src/coulobre/hosting/models.py
+++ b/src/coulobre/hosting/models.py
@@ -37,6 +37,7 @@ from coulobre.mail_node import (
from coulobre.offsite_backup import MAX_DESTINATION_LENGTH
from coulobre.php_pool_settings import (
PHP_SETTING_BOUNDS,
+ PHP_UNLIMITED_SETTINGS,
PhpPoolSettings,
PhpPoolSettingsError,
)
@@ -57,7 +58,9 @@ class Reseller(models.Model):
"hosting_customer__isnull": True,
},
)
- account_limit = models.PositiveIntegerField(default=0)
+ account_limit = models.PositiveIntegerField(
+ default=0, null=True, blank=True
+ )
manage_resources = models.BooleanField(
default=False,
help_text="Allow database and mailbox requests and provisioning.",
@@ -75,12 +78,19 @@ class Reseller(models.Model):
return reverse("panel:reseller", kwargs={"pk": self.pk})
def may_create_accounts(self):
- return self.account_limit > 0 and self.hosting_plans.exists()
+ return self.account_limit != 0 and self.hosting_plans.exists()
+
+ def has_account_capacity(self, additional=1):
+ return (
+ self.account_limit is None
+ or self.hostingaccount_set.count() + additional
+ <= self.account_limit
+ )
class ResellerProfile(models.Model):
name = models.CharField(max_length=120, unique=True)
- account_limit = models.PositiveIntegerField()
+ account_limit = models.PositiveIntegerField(null=True, blank=True)
manage_resources = models.BooleanField(default=False)
hosting_plans = models.ManyToManyField("HostingPlan", blank=True)
default_slot = models.PositiveSmallIntegerField(
@@ -317,6 +327,8 @@ class ServiceCredentialAccess(models.Model):
def php_plan_field(option, label):
minimum, maximum = PHP_SETTING_BOUNDS[option]
+ if option in PHP_UNLIMITED_SETTINGS:
+ minimum = 0
return models.PositiveIntegerField(
label,
blank=True,
@@ -331,11 +343,15 @@ class HostingPlan(models.Model):
description = models.CharField(max_length=240, blank=True)
website_limit = models.PositiveSmallIntegerField(
default=1,
+ null=True,
+ blank=True,
validators=[MinValueValidator(1)],
help_text="Maximum independent websites, including the primary site.",
)
website_job_limit = models.PositiveSmallIntegerField(
default=0,
+ null=True,
+ blank=True,
validators=[MaxValueValidator(50)],
help_text=(
"Maximum saved jobs per account. Enter 0 to disable scheduling."
diff --git a/src/coulobre/hosting/php_settings.py b/src/coulobre/hosting/php_settings.py
index 9ba70e9..ea2dae8 100644
--- a/src/coulobre/hosting/php_settings.py
+++ b/src/coulobre/hosting/php_settings.py
@@ -4,6 +4,7 @@ from django.db import transaction
from coulobre.php_pool_settings import (
PHP_SETTING_BOUNDS,
+ PHP_UNLIMITED_SETTINGS,
PhpPoolSettings,
PhpPoolSettingsError,
)
@@ -19,6 +20,9 @@ from .sftp import site_is_active
def php_setting_input(option, label, *, help_text=""):
minimum, maximum = PHP_SETTING_BOUNDS[option]
+ if option in PHP_UNLIMITED_SETTINGS:
+ minimum = 0
+ help_text = f"{help_text} Enter 0 for no PHP limit.".strip()
return forms.IntegerField(
label=label,
min_value=minimum,
@@ -114,7 +118,9 @@ def limit_customer_php_settings(account, requested):
values = requested.manifest()
for key, limit in limits.items():
value = values[key]
- if value is not None and (limit is None or value > limit):
+ if value is not None and (
+ limit is None or (limit != 0 and (value == 0 or value > limit))
+ ):
raise ValidationError(
"Keep PHP limits within the account's hosting package."
)
diff --git a/src/coulobre/hosting/reseller_accounts.py b/src/coulobre/hosting/reseller_accounts.py
index ace5e34..8d6a591 100644
--- a/src/coulobre/hosting/reseller_accounts.py
+++ b/src/coulobre/hosting/reseller_accounts.py
@@ -123,7 +123,7 @@ def create_reseller_account(access, account):
raise ValidationError(
{NON_FIELD_ERRORS: "Your manager access has changed."}
)
- if reseller.hostingaccount_set.count() >= reseller.account_limit:
+ if not reseller.has_account_capacity():
raise ValidationError(
{NON_FIELD_ERRORS: "Your hosting account limit has been reached."}
)
diff --git a/src/coulobre/hosting/reseller_profiles.py b/src/coulobre/hosting/reseller_profiles.py
index a4d1d9d..7b5dc41 100644
--- a/src/coulobre/hosting/reseller_profiles.py
+++ b/src/coulobre/hosting/reseller_profiles.py
@@ -5,6 +5,7 @@ from django.urls import reverse_lazy
from django.views.generic import CreateView, ListView, UpdateView
from .access import OperatorOnlyMixin
+from .limit_forms import add_unlimited_fields
from .models import ResellerProfile
MANAGE_PROFILES = (
@@ -27,11 +28,18 @@ class ResellerProfileForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
+ add_unlimited_fields(self, ("account_limit",))
+ if not self.instance.pk:
+ self.initial["account_limit"] = 0
self.initial["use_as_default"] = self.instance.default_slot == 1
def clean(self):
values = super().clean()
- if values.get("account_limit") and not values.get("hosting_plans"):
+ if (
+ "account_limit" in values
+ and values["account_limit"] != 0
+ and not values.get("hosting_plans")
+ ):
self.add_error(
"hosting_plans", "Select at least one hosting package."
)
diff --git a/src/coulobre/hosting/reseller_views.py b/src/coulobre/hosting/reseller_views.py
index 28a3c71..f527b75 100644
--- a/src/coulobre/hosting/reseller_views.py
+++ b/src/coulobre/hosting/reseller_views.py
@@ -12,6 +12,7 @@ from django.views.generic import DetailView, FormView, ListView
from .access import OperatorOnlyMixin
from .invitations import InviteLoginForm, queue_invitation
+from .limit_forms import add_unlimited_fields
from .models import Reseller, ResellerProfile
from .reseller_accounts import (
create_reseller,
@@ -43,6 +44,7 @@ class ResellerPolicyForm(forms.ModelForm):
def __init__(self, *args, show_plans, **kwargs):
super().__init__(*args, **kwargs)
+ add_unlimited_fields(self, ("account_limit",))
if not show_plans:
self.fields.pop("hosting_plans")
if self.instance.pk:
@@ -57,7 +59,8 @@ class ResellerPolicyForm(forms.ModelForm):
if (
"hosting_plans" in self.fields
and not self.instance.pk
- and values.get("account_limit")
+ and "account_limit" in values
+ and values["account_limit"] != 0
and not values.get("hosting_plans")
):
self.add_error(
@@ -162,7 +165,7 @@ class ResellerCreate(
@cached_property
def policy_form(self):
profile = self.profile_for_form(use_default=True)
- initial = profile.policy() if profile else {"account_limit": None}
+ initial = profile.policy() if profile else {"account_limit": 0}
return ResellerPolicyForm(
self.request.POST if self.request.method == "POST" else None,
prefix="policy",
diff --git a/src/coulobre/hosting/static/hosting/limit-controls.js b/src/coulobre/hosting/static/hosting/limit-controls.js
new file mode 100644
index 0000000..6daf49e
--- /dev/null
+++ b/src/coulobre/hosting/static/hosting/limit-controls.js
@@ -0,0 +1,10 @@
+for (const control of document.querySelectorAll("[data-limit-control]")) {
+ const number = control.querySelector('input[type="number"]');
+ const unlimited = control.querySelector('input[type="checkbox"]');
+ const update = () => {
+ number.disabled = unlimited.checked;
+ };
+
+ unlimited.addEventListener("change", update);
+ update();
+}
diff --git a/src/coulobre/hosting/static/hosting/panel.css b/src/coulobre/hosting/static/hosting/panel.css
index 8de1b08..e27f72a 100644
--- a/src/coulobre/hosting/static/hosting/panel.css
+++ b/src/coulobre/hosting/static/hosting/panel.css
@@ -959,6 +959,24 @@ dd {
accent-color: var(--accent);
}
+.limit-control {
+ display: flex;
+ align-items: center;
+ gap: 0.65rem;
+}
+
+.limit-control input[type="number"] {
+ min-width: 0;
+}
+
+.limit-control label {
+ display: inline-flex;
+ align-items: center;
+ gap: 0.3rem;
+ margin: 0;
+ font-weight: inherit;
+}
+
.welcome-email-preview {
min-width: 0;
overflow-wrap: anywhere;
diff --git a/src/coulobre/hosting/templates/hosting/account_list.html b/src/coulobre/hosting/templates/hosting/account_list.html
index 058452c..9c3dc85 100644
--- a/src/coulobre/hosting/templates/hosting/account_list.html
+++ b/src/coulobre/hosting/templates/hosting/account_list.html
@@ -6,9 +6,9 @@
{% if is_customer %}My hosting{% elif is_reseller %}Customer hosting{% else %}Hosting accounts{% endif %}
{% if is_operator %}Manage domains and their hosting services. A linked customer login can manage them in the panel.
{% endif %}
{{ paginator.count }} account{{ paginator.count|pluralize }}{% if search %} matching your search{% endif %}
- {% if account_allowance %}{{ account_allowance.used }} of {{ account_allowance.limit }} accounts allocated
{% endif %}
+ {% if account_allowance %}{{ account_allowance.used }} of {{ account_allowance.limit|default_if_none:"Unlimited" }} accounts allocated
{% endif %}
- {% if account_allowance.may_create and account_allowance.used < account_allowance.limit or is_operator and perms.hosting.add_hostingaccount %}
+ {% if account_allowance.may_create or is_operator and perms.hosting.add_hostingaccount %}
Add hosting account
{% endif %}
diff --git a/src/coulobre/hosting/templates/hosting/hosting_plan_form.html b/src/coulobre/hosting/templates/hosting/hosting_plan_form.html
index 69c8897..d86a119 100644
--- a/src/coulobre/hosting/templates/hosting/hosting_plan_form.html
+++ b/src/coulobre/hosting/templates/hosting/hosting_plan_form.html
@@ -33,4 +33,5 @@
+
{% endblock %}
diff --git a/src/coulobre/hosting/templates/hosting/hosting_plan_list.html b/src/coulobre/hosting/templates/hosting/hosting_plan_list.html
index a24b788..bfdeac7 100644
--- a/src/coulobre/hosting/templates/hosting/hosting_plan_list.html
+++ b/src/coulobre/hosting/templates/hosting/hosting_plan_list.html
@@ -17,6 +17,7 @@
| Plan |
Description |
+ Website count |
Database limit |
Mailbox limit |
Storage per new mailbox |
@@ -36,11 +37,12 @@
{% endif %}
{{ hosting_plan.description|default:"—" }} |
+ {{ hosting_plan.website_limit|default_if_none:"Unlimited" }} |
{{ hosting_plan.database_limit|default_if_none:"Unlimited" }} |
{{ hosting_plan.mailbox_limit|default_if_none:"Unlimited" }} |
{% if hosting_plan.mailbox_quota_mib is not None %}{{ hosting_plan.mailbox_quota_mib }} MiB{% else %}Unlimited{% endif %} |
{% if hosting_plan.website_storage_limit_mib is not None %}{{ hosting_plan.website_storage_limit_mib }} MiB{% else %}Unlimited{% endif %} |
- {{ hosting_plan.website_job_limit }} |
+ {{ hosting_plan.website_job_limit|default_if_none:"Unlimited" }} |
{% if hosting_plan.get_php_settings.has_overrides %}Configured{% else %}Server defaults{% endif %} |
{% endfor %}
diff --git a/src/coulobre/hosting/templates/hosting/limit_widget.html b/src/coulobre/hosting/templates/hosting/limit_widget.html
new file mode 100644
index 0000000..e3c3df6
--- /dev/null
+++ b/src/coulobre/hosting/templates/hosting/limit_widget.html
@@ -0,0 +1,9 @@
+
+ {% with number=widget.subwidgets.0 unlimited=widget.subwidgets.1 %}
+ {% include number.template_name with widget=number %}
+
+ {% endwith %}
+
diff --git a/src/coulobre/hosting/templates/hosting/panel_invitation.txt b/src/coulobre/hosting/templates/hosting/panel_invitation.txt
index fbc93d6..b577da8 100644
--- a/src/coulobre/hosting/templates/hosting/panel_invitation.txt
+++ b/src/coulobre/hosting/templates/hosting/panel_invitation.txt
@@ -12,12 +12,12 @@ Set your password by opening this link within 48 hours:
{% if account %}Your hosting account is {{ account.primary_domain }}.{% if account.hosting_plan %}
Hosting package: {{ account.hosting_plan.name }}
-Website limit: {{ account.hosting_plan.website_limit }}
-Scheduled tasks per account: {{ account.hosting_plan.website_job_limit }}
+Website limit: {{ account.hosting_plan.website_limit|default_if_none:"Unlimited" }}
+Scheduled tasks per account: {{ account.hosting_plan.website_job_limit|default_if_none:"Unlimited" }}
Database limit: {{ account.hosting_plan.database_limit|default_if_none:"Unlimited" }}
-Mailbox limit: {{ account.hosting_plan.mailbox_limit|default_if_none:"Unlimited" }}{% if account.hosting_plan.mailbox_quota_mib %}
-Storage per new mailbox: {{ account.hosting_plan.mailbox_quota_mib }} MiB{% endif %}{% if account.hosting_plan.website_storage_limit_mib %}
-Default website storage limit: {{ account.hosting_plan.website_storage_limit_mib }} MiB{% endif %}{% endif %}
+Mailbox limit: {{ account.hosting_plan.mailbox_limit|default_if_none:"Unlimited" }}
+Storage per new mailbox: {{ account.hosting_plan.mailbox_quota_mib|default_if_none:"Unlimited" }}{% if account.hosting_plan.mailbox_quota_mib %} MiB{% endif %}
+Default website storage limit: {{ account.hosting_plan.website_storage_limit_mib|default_if_none:"Unlimited" }}{% if account.hosting_plan.website_storage_limit_mib %} MiB{% endif %}{% endif %}
{% if nameservers %}
To use Coulobre DNS, set these nameservers at your registrar:
{% for server in nameservers %}{{ server }}
diff --git a/src/coulobre/hosting/templates/hosting/panel_invitation_body.html b/src/coulobre/hosting/templates/hosting/panel_invitation_body.html
index 40d277c..022844b 100644
--- a/src/coulobre/hosting/templates/hosting/panel_invitation_body.html
+++ b/src/coulobre/hosting/templates/hosting/panel_invitation_body.html
@@ -26,12 +26,12 @@
{% if package %}
Hosting package
{{ package.name }}
- - Websites · {{ package.website_limit }}
- - Scheduled tasks · {{ package.website_job_limit }}
+ - Websites · {{ package.website_limit|default_if_none:"Unlimited" }}
+ - Scheduled tasks · {{ package.website_job_limit|default_if_none:"Unlimited" }}
- Databases · {{ package.database_limit|default_if_none:"Unlimited" }}
- Mailboxes · {{ package.mailbox_limit|default_if_none:"Unlimited" }}
- {% if package.mailbox_quota_mib %}- Storage per new mailbox · {{ package.mailbox_quota_mib }} MiB
{% endif %}
- {% if package.website_storage_limit_mib %}- Default website storage limit · {{ package.website_storage_limit_mib }} MiB
{% endif %}
+ - Storage per new mailbox · {{ package.mailbox_quota_mib|default_if_none:"Unlimited" }}{% if package.mailbox_quota_mib %} MiB{% endif %}
+ - Default website storage limit · {{ package.website_storage_limit_mib|default_if_none:"Unlimited" }}{% if package.website_storage_limit_mib %} MiB{% endif %}
{% endif %}
{% endwith %}
diff --git a/src/coulobre/hosting/templates/hosting/php_setting_values.html b/src/coulobre/hosting/templates/hosting/php_setting_values.html
index 5ab1b8f..e90cd74 100644
--- a/src/coulobre/hosting/templates/hosting/php_setting_values.html
+++ b/src/coulobre/hosting/templates/hosting/php_setting_values.html
@@ -1,6 +1,6 @@
- - PHP memory limit
- {% if limits.memory_limit_mib %}{{ limits.memory_limit_mib }} MiB{% else %}Server default{% endif %}
- - PHP upload limit
- {% if limits.upload_limit_mib %}{{ limits.upload_limit_mib }} MiB{% else %}Server default{% endif %}
- - PHP request timeout
- {% if limits.request_timeout_seconds %}{{ limits.request_timeout_seconds }} s{% else %}Server default{% endif %}
+ - PHP memory limit
- {% if limits.memory_limit_mib == 0 %}Unlimited{% elif limits.memory_limit_mib %}{{ limits.memory_limit_mib }} MiB{% else %}Server default{% endif %}
+ - PHP upload limit
- {% if limits.upload_limit_mib == 0 %}Unlimited{% elif limits.upload_limit_mib %}{{ limits.upload_limit_mib }} MiB{% else %}Server default{% endif %}
+ - PHP request timeout
- {% if limits.request_timeout_seconds == 0 %}Unlimited{% elif limits.request_timeout_seconds %}{{ limits.request_timeout_seconds }} s{% else %}Server default{% endif %}
- Maximum PHP-FPM workers
- {{ limits.worker_limit }}
diff --git a/src/coulobre/hosting/templates/hosting/reseller_detail.html b/src/coulobre/hosting/templates/hosting/reseller_detail.html
index 15a816a..2c97ce3 100644
--- a/src/coulobre/hosting/templates/hosting/reseller_detail.html
+++ b/src/coulobre/hosting/templates/hosting/reseller_detail.html
@@ -18,7 +18,7 @@
{% block page_content %}
- Panel sign-in
- {{ reseller.user.is_active|yesno:"Active,Suspended" }}
- - Accounts allocated
- {{ account_count }} of {{ reseller.account_limit }}
+ - Accounts allocated
- {{ account_count }} of {{ reseller.account_limit|default_if_none:"Unlimited" }}
{% if perms.hosting.view_hostingplan %}
- Allowed hosting packages
@@ -73,7 +73,7 @@
{{ event.get_action_display }}
{% if event.account_domain %}
{{ event.account_domain }}
{% endif %}
{% if event.changes.account_limit %}
-
Account limit {{ event.changes.account_limit.before|default_if_none:"—" }} → {{ event.changes.account_limit.after }}
+
Account limit {{ event.changes.account_limit.before|default_if_none:"—" }} → {{ event.changes.account_limit.after|default_if_none:"Unlimited" }}
{% endif %}
{% if event.changes.customer %}
{{ event.changes.customer }}
{% endif %}
{% if event.changes.resource %}
{{ event.changes.type|capfirst }} {{ event.changes.resource }}
{% endif %}
diff --git a/src/coulobre/hosting/templates/hosting/reseller_form.html b/src/coulobre/hosting/templates/hosting/reseller_form.html
index 0b07767..44d09fa 100644
--- a/src/coulobre/hosting/templates/hosting/reseller_form.html
+++ b/src/coulobre/hosting/templates/hosting/reseller_form.html
@@ -1,4 +1,5 @@
{% extends "hosting/workspace_page.html" %}
+{% load panel_assets %}
{% block title %}{{ page_title }} · Coulobre Panel{% endblock %}
{% block page_title %}{{ page_title }}{% endblock %}
{% block page_context %}
@@ -43,4 +44,5 @@
+
{% endblock %}
diff --git a/src/coulobre/hosting/templates/hosting/reseller_list.html b/src/coulobre/hosting/templates/hosting/reseller_list.html
index 4dd833c..68ac1eb 100644
--- a/src/coulobre/hosting/templates/hosting/reseller_list.html
+++ b/src/coulobre/hosting/templates/hosting/reseller_list.html
@@ -37,7 +37,7 @@
| {{ reseller }} |
{{ reseller.user.is_active|yesno:"Active,Suspended" }} |
- {{ reseller.account_count }} of {{ reseller.account_limit }} |
+ {{ reseller.account_count }} of {{ reseller.account_limit|default_if_none:"Unlimited" }} |
{% endfor %}
diff --git a/src/coulobre/hosting/templates/hosting/reseller_profile_form.html b/src/coulobre/hosting/templates/hosting/reseller_profile_form.html
index 2da668e..f0d3bb2 100644
--- a/src/coulobre/hosting/templates/hosting/reseller_profile_form.html
+++ b/src/coulobre/hosting/templates/hosting/reseller_profile_form.html
@@ -1,4 +1,5 @@
{% extends "hosting/workspace_page.html" %}
+{% load panel_assets %}
{% block title %}{% if object %}Edit manager package{% else %}Add manager package{% endif %} · Coulobre Panel{% endblock %}
{% block page_title %}{% if object %}Edit manager package{% else %}Add manager package{% endif %}{% endblock %}
{% block page_context %}
@@ -12,4 +13,5 @@
+
{% endblock %}
diff --git a/src/coulobre/hosting/templates/hosting/reseller_profile_list.html b/src/coulobre/hosting/templates/hosting/reseller_profile_list.html
index c89c34f..c5e558e 100644
--- a/src/coulobre/hosting/templates/hosting/reseller_profile_list.html
+++ b/src/coulobre/hosting/templates/hosting/reseller_profile_list.html
@@ -18,7 +18,7 @@
{% for profile in object_list %}
| {{ profile.name }}{% if profile.default_slot %} · Default{% endif %} |
- {% if profile.account_limit %}{{ profile.account_limit }}{% else %}Manage existing accounts only{% endif %} |
+ {% if profile.account_limit == 0 %}Manage existing accounts only{% else %}{{ profile.account_limit|default_if_none:"Unlimited" }}{% endif %} |
{% empty %}
| No manager packages yet. Add one to reuse account limits and a set of hosting packages. |
diff --git a/src/coulobre/hosting/templates/hosting/website_jobs.html b/src/coulobre/hosting/templates/hosting/website_jobs.html
index a5cb1a2..8a6374b 100644
--- a/src/coulobre/hosting/templates/hosting/website_jobs.html
+++ b/src/coulobre/hosting/templates/hosting/website_jobs.html
@@ -4,7 +4,7 @@
Scheduled website jobs
-
{{ rows|length }} of {{ limit }} saved jobs
+
{{ rows|length }} of {{ limit|default_if_none:"Unlimited" }} saved jobs
{% if add_job %}
Add job
diff --git a/src/coulobre/hosting/test_hosting_plans.py b/src/coulobre/hosting/test_hosting_plans.py
index bb4da73..4feda23 100644
--- a/src/coulobre/hosting/test_hosting_plans.py
+++ b/src/coulobre/hosting/test_hosting_plans.py
@@ -38,6 +38,32 @@ class HostingPlanTests(TestCase):
self.assertContains(response, "including paused tasks")
self.assertNotContains(response, "Examples and explanations")
+ def test_unlimited_limits_preserve_disabled_and_inherited_values(self):
+ self.client.force_login(self.operator)
+ list_url = reverse("panel:hosting_plans")
+ response = self.client.post(
+ reverse("panel:hosting_plan_create"),
+ {
+ "name": "Flexible",
+ "website_limit_unlimited": "on",
+ "website_job_limit": 0,
+ "database_limit": 0,
+ "mailbox_limit_unlimited": "on",
+ "website_storage_limit_mib_unlimited": "on",
+ "php_memory_limit_mib_unlimited": "on",
+ },
+ )
+ self.assertRedirects(response, list_url)
+ plan = HostingPlan.objects.get()
+ self.assertIsNone(plan.website_limit)
+ self.assertIsNone(plan.mailbox_limit)
+ self.assertIsNone(plan.website_storage_limit_mib)
+ self.assertEqual(plan.website_job_limit, 0)
+ self.assertEqual(plan.database_limit, 0)
+ self.assertEqual(plan.php_memory_limit_mib, 0)
+ self.assertIsNone(plan.php_upload_limit_mib)
+ self.assertContains(self.client.get(list_url), "Unlimited")
+
def test_operator_can_create_assign_and_edit_a_plan(self):
self.client.force_login(self.operator)
list_url = reverse("panel:hosting_plans")
diff --git a/src/coulobre/hosting/test_independent_websites.py b/src/coulobre/hosting/test_independent_websites.py
index 053b6c0..37fe61f 100644
--- a/src/coulobre/hosting/test_independent_websites.py
+++ b/src/coulobre/hosting/test_independent_websites.py
@@ -189,6 +189,15 @@ class IndependentWebsiteTests(TestCase):
self.operation(website, Operation.SUSPEND).status_code, 404
)
+ def test_unlimited_website_package_allows_additional_sites(self):
+ HostingPlan.objects.filter(pk=self.plan.pk).update(website_limit=None)
+ self.create_website()
+ self.assertRedirects(
+ self.client.post(self.add, {"domain": "second.example.test"}),
+ self.account.get_absolute_url(),
+ )
+ self.assertEqual(IndependentWebsite.objects.count(), 2)
+
def test_tls_and_retirement_leave_primary_reservation_intact(self):
website = self.active_website()
self.assertRedirects(
diff --git a/src/coulobre/hosting/test_php_settings.py b/src/coulobre/hosting/test_php_settings.py
index d37b83b..b734304 100644
--- a/src/coulobre/hosting/test_php_settings.py
+++ b/src/coulobre/hosting/test_php_settings.py
@@ -244,6 +244,23 @@ class NativePhpSettingsTests(SimpleTestCase):
):
parse_web_request(payload)
+ def test_unlimited_php_overrides_render_valid_pool_values(self):
+ options = PhpPoolSettings(0, 0, 0)
+ pool = self.site.render("php-fpm", php_settings=options)
+ self.paths.pool.write_text(pool, encoding="utf-8")
+ self.assertEqual(
+ read_managed_php_pool(self.site, self.paths.pool), (pool, options)
+ )
+ for line in (
+ "php_admin_value[memory_limit] = -1",
+ "php_admin_value[upload_max_filesize] = 0",
+ "php_admin_value[post_max_size] = 0",
+ "php_admin_value[max_execution_time] = 0",
+ "request_terminate_timeout = 0s",
+ "pm.max_children = 2",
+ ):
+ self.assertIn(line + "\n", pool)
+
def test_generated_php_settings_survive_activation(
self,
):
diff --git a/src/coulobre/hosting/test_resellers.py b/src/coulobre/hosting/test_resellers.py
index 36353db..6a0bd23 100644
--- a/src/coulobre/hosting/test_resellers.py
+++ b/src/coulobre/hosting/test_resellers.py
@@ -11,6 +11,7 @@ from .models import (
HostingPlan,
Reseller,
ResellerAuditEvent,
+ ResellerProfile,
WebProvisioningPlan,
)
from .reseller_accounts import create_reseller_account
@@ -234,6 +235,50 @@ class ResellerAccountCreationTests(TestCase):
self.assertIn("hosting_plan", response.context["form"].errors)
self.assertEqual(self.reseller.hostingaccount_set.count(), 1)
+ def test_unlimited_manager_package_keeps_its_hosting_package_scope(self):
+ self.client.force_login(self.operator)
+ self.assertRedirects(
+ self.client.post(
+ reverse("panel:reseller_profile_create"),
+ {
+ "name": "Unlimited accounts",
+ "account_limit_unlimited": "on",
+ "hosting_plans": [self.allowed.pk],
+ },
+ ),
+ reverse("panel:reseller_profiles"),
+ )
+ profile = ResellerProfile.objects.get()
+ self.assertIsNone(profile.account_limit)
+ self.assertRedirects(
+ self.client.post(
+ reverse("panel:reseller_edit", args=[self.reseller.pk]),
+ {
+ "is_active": "on",
+ "account_limit_unlimited": "on",
+ "hosting_plans": [self.allowed.pk],
+ },
+ ),
+ self.reseller.get_absolute_url(),
+ )
+ self.client.force_login(self.user)
+ for domain in ("first.example", "second.example", "third.example"):
+ response = self.client.post(
+ self.create_url,
+ {
+ "name": domain,
+ "primary_domain": domain,
+ "hosting_plan": self.allowed.pk,
+ },
+ )
+ self.assertEqual(response.status_code, 302)
+ self.assertEqual(self.reseller.hostingaccount_set.count(), 4)
+ overview = self.client.get(reverse("panel:accounts"))
+ self.assertContains(overview, "Add hosting account")
+ self.assertNotContains(
+ self.client.get(self.create_url), self.unavailable.name
+ )
+
def test_plan_revoked_after_form_validation_is_rejected(self):
def revoke_before_create(access, account):
self.reseller.hosting_plans.remove(self.allowed)
diff --git a/src/coulobre/hosting/test_website_jobs.py b/src/coulobre/hosting/test_website_jobs.py
index a883292..ad4eecf 100644
--- a/src/coulobre/hosting/test_website_jobs.py
+++ b/src/coulobre/hosting/test_website_jobs.py
@@ -231,6 +231,23 @@ class WebsiteJobWorkflowTests(TestCase):
)
self.assertEqual(self.account.website_jobs.count(), 2)
+ def test_unlimited_task_package_allows_creation_and_dispatch(self):
+ HostingPlan.objects.filter(pk=self.plan.pk).update(
+ website_job_limit=None
+ )
+ due = self.job()
+ self.job(enabled=False, next_run_at=None)
+ with (
+ patch(CLOCK, return_value=NOW),
+ patch.object(execute_website_job, "apply_async") as publish,
+ ):
+ self.assertRedirects(
+ self.client.post(self.add_url, self.form()), self.jobs_url
+ )
+ dispatch_website_jobs.run()
+ self.assertEqual(self.account.website_jobs.count(), 3)
+ self.assertEqual(publish.call_args.kwargs["args"][1], due.pk)
+
def test_operator_needs_permission_and_feature_is_optional(self):
self.client.force_login(self.operator)
self.operator.user_permissions.add(
diff --git a/src/coulobre/hosting/views.py b/src/coulobre/hosting/views.py
index fee7bfc..6104be0 100644
--- a/src/coulobre/hosting/views.py
+++ b/src/coulobre/hosting/views.py
@@ -30,6 +30,7 @@ from django.views.generic.detail import SingleObjectMixin
from coulobre.dns_node import MAX_SOA_SERIAL
from coulobre.mail_dns import MANAGED_DKIM_SELECTOR, matches_version
from coulobre.mail_node import INVALID_LOCAL_PART
+from coulobre.php_pool_settings import PHP_UNLIMITED_SETTINGS
from coulobre.php_runtime import available_php_versions
from coulobre.sftp_keys import public_key_fingerprint
@@ -101,6 +102,7 @@ from .installation_features import (
panel_feature_paused,
)
from .invitations import InviteLoginForm, queue_invitation
+from .limit_forms import add_unlimited_fields
from .mail_policy_views import mail_policy_enabled
from .models import (
AccountBackupJob,
@@ -396,10 +398,15 @@ class AccountList(TenantScopeMixin, PermissionRequiredMixin, ListView):
context["show_customer_website_link"] = settings.WEBSITE_USAGE
reseller = reseller_for_user(self.request.user)
if reseller is not None:
+ used = reseller.hostingaccount_set.count()
context["account_allowance"] = {
- "used": reseller.hostingaccount_set.count(),
+ "used": used,
"limit": reseller.account_limit,
- "may_create": reseller.may_create_accounts(),
+ "may_create": reseller.may_create_accounts()
+ and (
+ reseller.account_limit is None
+ or used < reseller.account_limit
+ ),
}
return context
@@ -666,7 +673,7 @@ class AccountDetail(TenantScopeMixin, PermissionRequiredMixin, DetailView):
context["manage_website_jobs"] = can_manage_website_jobs(
self.request
) and (
- website_job_limit(self.object) > 0
+ website_job_limit(self.object) != 0
or self.object.website_jobs.exists()
)
context["primary_file_access"] = manage_files and site_is_active(
@@ -685,9 +692,11 @@ class AccountDetail(TenantScopeMixin, PermissionRequiredMixin, DetailView):
(website, website_actions(website) if can_manage else ())
for website in websites
]
+ limit = website_limit(self.object)
context["add_independent_website"] = can_manage and (
- sum(website.retired_at is None for website in websites) + 1
- < website_limit(self.object)
+ limit is None
+ or sum(website.retired_at is None for website in websites) + 1
+ < limit
)
context["can_retire_account"] = not tenant and user.has_perms(
RETIRE_ACCOUNTS
@@ -2579,12 +2588,21 @@ class HostingPlanEditor:
kwargs = super().get_form_kwargs()
if "data" in kwargs:
defaults = {"website_limit": 1, "website_job_limit": 0}
- missing = defaults.keys() - kwargs["data"].keys()
+ missing = [
+ field
+ for field in defaults
+ if field not in kwargs["data"]
+ and f"{field}_unlimited" not in kwargs["data"]
+ ]
if missing:
data = kwargs["data"].copy()
instance = kwargs.get("instance")
for field in missing:
- data[field] = getattr(instance, field, defaults[field])
+ limit = getattr(instance, field, defaults[field])
+ if limit is None:
+ data[f"{field}_unlimited"] = "on"
+ else:
+ data[field] = limit
kwargs["data"] = data
return kwargs
@@ -2601,17 +2619,34 @@ class HostingPlanEditor:
form.fields[field].help_text += " Enter 1024 for 1 GiB."
php_help = {
"php_memory_limit_mib": "Memory a PHP script can use.",
- "php_upload_limit_mib": "Maximum size of an uploaded file.",
+ "php_upload_limit_mib": (
+ "PHP's upload limit. Web server limits apply separately."
+ ),
"php_request_timeout_seconds": (
"How long PHP-FPM lets a request run before stopping it."
),
"php_max_children": (
- "How many PHP requests a website can process at once."
+ "PHP-FPM requires a numeric worker limit for each pool."
),
}
for name, description in php_help.items():
field = form.fields[name]
field.help_text = f"{description} {field.help_text}"
+ optional_limits = (
+ "database_limit",
+ "mailbox_limit",
+ "mailbox_quota_mib",
+ "website_storage_limit_mib",
+ )
+ add_unlimited_fields(
+ form,
+ ("website_limit", "website_job_limit", *optional_limits),
+ allow_blank=optional_limits,
+ )
+ php_limits = tuple(f"php_{name}" for name in PHP_UNLIMITED_SETTINGS)
+ add_unlimited_fields(
+ form, php_limits, allow_blank=php_limits, unlimited_value=0
+ )
return form
diff --git a/src/coulobre/hosting/website_job_views.py b/src/coulobre/hosting/website_job_views.py
index fb6f9a4..a6a53da 100644
--- a/src/coulobre/hosting/website_job_views.py
+++ b/src/coulobre/hosting/website_job_views.py
@@ -139,7 +139,7 @@ class WebsiteJobList(WebsiteJobAccountView):
available = (
(job.website_id, job.domain) in active
and job.enabled
- and enabled_count <= limit
+ and (limit is None or enabled_count <= limit)
)
rows.append((job, available))
return render(
@@ -149,7 +149,8 @@ class WebsiteJobList(WebsiteJobAccountView):
"account": account,
"rows": rows,
"limit": limit,
- "add_job": len(jobs) < limit and bool(sites),
+ "add_job": bool(sites)
+ and (limit is None or len(jobs) < limit),
},
)
diff --git a/src/coulobre/hosting/website_jobs.py b/src/coulobre/hosting/website_jobs.py
index 0f7afaa..f021fe7 100644
--- a/src/coulobre/hosting/website_jobs.py
+++ b/src/coulobre/hosting/website_jobs.py
@@ -69,7 +69,8 @@ def save_website_job(account_id, job_id, values, actor):
check_actor(account, actor)
if job_id is None:
require_active_services(account)
- if account.website_jobs.count() >= website_job_limit(account):
+ limit = website_job_limit(account)
+ if limit is not None and account.website_jobs.count() >= limit:
raise ValidationError(
"This hosting account has reached its scheduled job limit."
)
@@ -124,8 +125,9 @@ def due_website_jobs(now):
next_run_at__lte=now,
account__retired_at__isnull=True,
account__services_suspended=False,
- account__hosting_plan__website_job_limit__gt=0,
+ account__hosting_plan__isnull=False,
)
+ .exclude(account__hosting_plan__website_job_limit=0)
.filter(
Q(dispatched_at__isnull=True)
| Q(dispatched_at__lte=now - DISPATCH_INTERVAL),
@@ -164,7 +166,7 @@ def claim_website_job(account_id, job_id, expected_run):
site is not None
and now - expected_run <= MISSED_WINDOW
and job.run_token is None
- and older_jobs.count() < limit
+ and (limit is None or older_jobs.count() < limit)
):
token = uuid4()
request = WebsiteJobRequest(site, token.hex, job.command)
diff --git a/src/coulobre/hosting/workspace_onboarding.py b/src/coulobre/hosting/workspace_onboarding.py
index fd0e9c6..2ba0e49 100644
--- a/src/coulobre/hosting/workspace_onboarding.py
+++ b/src/coulobre/hosting/workspace_onboarding.py
@@ -88,10 +88,7 @@ def onboarding_context(request):
manager = reseller_for_user(user)
has_packages = manager.hosting_plans.exists()
accounts = active.filter(reseller=manager)
- may_create = (
- has_packages
- and manager.hostingaccount_set.count() < manager.account_limit
- )
+ may_create = has_packages and manager.has_account_capacity()
steps.extend(
(
(
diff --git a/src/coulobre/php_pool_settings.py b/src/coulobre/php_pool_settings.py
index 5c8abd0..25d2659 100644
--- a/src/coulobre/php_pool_settings.py
+++ b/src/coulobre/php_pool_settings.py
@@ -9,6 +9,11 @@ PHP_SETTING_BOUNDS = {
"request_timeout_seconds": (1, 600),
"max_children": (1, 32),
}
+PHP_UNLIMITED_SETTINGS = (
+ "memory_limit_mib",
+ "upload_limit_mib",
+ "request_timeout_seconds",
+)
class PhpPoolSettingsError(ValueError):
@@ -27,16 +32,22 @@ class PhpPoolSettings:
def __post_init__(self):
for field, (minimum, maximum) in PHP_SETTING_BOUNDS.items():
value = getattr(self, field)
- if value is not None and (
- type(value) is not int or not minimum <= value <= maximum
+ if (
+ value is not None
+ and not (
+ type(value) is int
+ and value == 0
+ and field in PHP_UNLIMITED_SETTINGS
+ )
+ and (type(value) is not int or not minimum <= value <= maximum)
):
raise PhpPoolSettingsError(
field,
f"Enter a whole number between {minimum} and {maximum}.",
)
if (
- self.memory_limit_mib is not None
- and self.post_limit_mib is not None
+ self.memory_limit_mib
+ and self.post_limit_mib
and self.memory_limit_mib < self.post_limit_mib
):
raise PhpPoolSettingsError(
@@ -46,11 +57,9 @@ class PhpPoolSettings:
@property
def post_limit_mib(self):
- return (
- self.upload_limit_mib + 1
- if self.upload_limit_mib is not None
- else None
- )
+ if self.upload_limit_mib:
+ return self.upload_limit_mib + 1
+ return self.upload_limit_mib
@property
def worker_limit(self):
@@ -80,15 +89,19 @@ class PhpPoolSettings:
+ json.dumps(self.manifest(), separators=(",", ":"))
]
if self.memory_limit_mib is not None:
- lines.append(
- f"php_admin_value[memory_limit] = {self.memory_limit_mib}M"
+ memory = (
+ f"{self.memory_limit_mib}M" if self.memory_limit_mib else "-1"
)
+ lines.append(f"php_admin_value[memory_limit] = {memory}")
if self.upload_limit_mib is not None:
+ upload = (
+ f"{self.upload_limit_mib}M" if self.upload_limit_mib else "0"
+ )
+ post = f"{self.post_limit_mib}M" if self.post_limit_mib else "0"
lines.extend(
(
- "php_admin_value[upload_max_filesize] = "
- f"{self.upload_limit_mib}M",
- f"php_admin_value[post_max_size] = {self.post_limit_mib}M",
+ f"php_admin_value[upload_max_filesize] = {upload}",
+ f"php_admin_value[post_max_size] = {post}",
)
)
if self.request_timeout_seconds is not None: