feat(server): Add skip-standby-site-creation flag#6678
Conversation
Adds a `Skip Standby Site Creation` Check field to the Server doctype. When enabled, the scheduler will not pick that server when replenishing standby site pools. The flag is respected in all three pool systems: - `product_trial.get_server_from_cluster` (product trial pools) - `saas_site.get_saas_bench` (legacy SaaS app pools) - `erpnext_site.get_erpnext_bench` (ERPNext site pool) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Confidence Score: 4/5Safe to merge for the two ORM/raw-SQL paths; The flag is applied consistently and the schema change is correct. The only gap is in press/press/doctype/site/saas_site.py — the
|
| Filename | Overview |
|---|---|
| press/press/doctype/server/server.json | Adds skip_standby_site_creation Check field (default 0) — schema change is correct and straightforward. |
| press/press/doctype/server/server.py | Adds typed annotation skip_standby_site_creation: DF.Check — matches the JSON schema addition, no issues. |
| press/press/doctype/site/erpnext_site.py | Appends AND server.skip_standby_site_creation = 0 to existing parameterized raw SQL — literal value, no injection risk. |
| press/press/doctype/site/saas_site.py | Adds filter to raw SQL, but empty result set (all servers flagged) causes IndexError at line 117 — pre-existing flaw now operator-triggerable. |
| press/saas/doctype/product_trial/product_trial.py | Uses query builder Server.skip_standby_site_creation == 0 correctly; also reformats a get_all call with no logic change. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Standby Site Pool Replenishment] --> B{Which pool system?}
B --> C[product_trial.get_server_from_cluster]
B --> D[saas_site.get_saas_bench]
B --> E[erpnext_site.get_erpnext_bench]
C --> F[frappe.qb WHERE Server.skip_standby_site_creation == 0]
D --> G[SQL AND server.skip_standby_site_creation = 0]
E --> H[SQL AND server.skip_standby_site_creation = 0]
F --> I[Eligible servers list]
G --> J{bench_servers empty?}
H --> K[Return bench name]
J -->|No| L[Build signup_server_sub_str → select lowest CPU server]
J -->|Yes| M[⚠️ IndexError: signup_servers index 0 out of range]
I --> N[Count standby sites per server → pick min]
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
press/press/doctype/site/saas_site.py:117
**IndexError when all servers are skipped**
If `skip_standby_site_creation` is enabled on every server that would otherwise match the query, `bench_servers` will be empty, making `signup_servers` an empty tuple. The `else` branch on this line then accesses `signup_servers[0]`, raising an `IndexError`. Before this PR the same crash was theoretically possible, but the new flag makes it a realistic operator-triggered failure path (e.g., a DBA flags all servers in a cluster during maintenance).
Reviews (1): Last reviewed commit: "feat(server): Add skip-standby-site-crea..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests.
Additional details and impacted files@@ Coverage Diff @@
## develop #6678 +/- ##
============================================
- Coverage 62.85% 47.10% -15.76%
============================================
Files 117 875 +758
Lines 18093 65412 +47319
Branches 526 0 -526
============================================
+ Hits 11373 30812 +19439
- Misses 6688 34600 +27912
+ Partials 32 0 -32
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Adds a
Skip Standby Site CreationCheck field to the Server doctype. When enabled, the scheduler will not pick that server when replenishing standby site pools.The flag is respected in all three pool systems:
product_trial.get_server_from_cluster(product trial pools)saas_site.get_saas_bench(legacy SaaS app pools)erpnext_site.get_erpnext_bench(ERPNext site pool)