Skip to content

fix(site): Skip rate limit on all dedicated server plans - #7266

Open
balamurali27 wants to merge 4 commits into
developfrom
dedicated-site-rate-limit
Open

fix(site): Skip rate limit on all dedicated server plans#7266
balamurali27 wants to merge 4 commits into
developfrom
dedicated-site-rate-limit

Conversation

@balamurali27

Copy link
Copy Markdown
Contributor

Problem

Sites on a dedicated server must not be usage tracked. Site.get_plan_config() skipped the rate_limit config for those sites, but it decided by plan name:

UNLIMITED_PLANS = ["Unlimited", "Unlimited - Supported"]

Nine Site Plans have dedicated_server_plan set, and all of them have cpu_time_per_day > 0. The list covers two. The other seven get a real rate_limit written into site config on insert and on every plan change:

Unlimited - DigitalOcean, Unlimited - Hetzner, Unlimited - Supported - Hetzner, Unlimited - Low, Unlimited - Low - Hetzner, Unlimited - Low - Supported, Unlimited - Low - Supported - Hetzner

Site Plan is autoname: Prompt, so the name is free text. Each new region or tier drops out of the list without a sign. plan_title is no better — three of these plans share the title Large.

Change

Check the dedicated_server_plan flag instead of the name, and delete UNLIMITED_PLANS (this was its only use).

if plan and frappe.db.get_value("Site Plan", plan, "dedicated_server_plan"):
	# PERF: do not enable usage tracking on dedicated server sites.
	config["rate_limit"] = {}

Patch

New code only helps sites created or moved to a new plan after the deploy. The patch pushes rate_limit: {} to the dedicated server sites that already have a limit in their config, which is what a plan change to Unlimited already does today. frappe.rate_limiter.apply() does if rate_limit:, so an empty dict turns the limiter off. One agent job per affected site, failures are logged and skipped so an unreachable bench does not stop the migration.

Tests

Two tests on Site.get_plan_config() — a dedicated plan gets {}, a shared plan keeps the limit from cpu_time_per_day. create_test_plan gains a dedicated_server_plan argument.

bench --site test_frappe_cloud run-tests --app press --module press.press.doctype.site.test_site --test test_dedicated_server_plan_does_not_get_a_rate_limit
bench --site test_frappe_cloud run-tests --app press --module press.press.doctype.site.test_site --test test_shared_server_plan_gets_a_rate_limit_from_cpu_time
bench --site test_frappe_cloud run-tests --app press --module press.press.doctype.site_plan.test_site_plan

All pass.

🤖 Generated with Claude Code

The exemption matched the plan name against UNLIMITED_PLANS, which held
only "Unlimited" and "Unlimited - Supported". Seven of the nine plans with
dedicated_server_plan set have other names (regional and Low variants), so
their sites got a rate_limit in site config and were usage tracked.

Check the dedicated_server_plan flag instead of the name. Site Plan is
autonamed by prompt, so a new region or tier silently fell out of the list.

The patch pushes an empty rate_limit to the sites that already have one,
the same way plan changes clear it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@balamurali27 balamurali27 added the backport-master For mergify backport to master label Aug 19, 2026
@greptile-apps

greptile-apps Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Reviews (4): Last reviewed commit: "Merge branch 'develop' into dedicated-si..." | Re-trigger Greptile

Comment thread press/patches/v0_8_0/unset_rate_limit_for_dedicated_server_sites.py
Comment thread press/patches/v0_8_0/unset_rate_limit_for_dedicated_server_sites.py
@codecov-commenter

codecov-commenter commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.88%. Comparing base (b0ac3ab) to head (7de0320).
⚠️ Report is 4 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff              @@
##           develop    #7266       +/-   ##
============================================
- Coverage    87.72%   59.88%   -27.84%     
============================================
  Files          129     1047      +918     
  Lines        22974    95548    +72574     
  Branches      1267     1268        +1     
============================================
+ Hits         20154    57221    +37067     
- Misses        2792    38299    +35507     
  Partials        28       28               
Flag Coverage Δ
dashboard 87.72% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

balamurali27 and others added 3 commits August 19, 2026 13:41
Unsuspending only pushes maintenance_mode (site.py:3067), so a site that
was suspended while the patch ran would keep its rate limit for good.
Only Archived sites are skipped now, since those are gone from the bench.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@balamurali27
balamurali27 enabled auto-merge August 19, 2026 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-master For mergify backport to master

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants