Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(bench): Add field to allow configuring custom redis memory limit #2388

Merged
merged 3 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion press/docker/config/redis-cache.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ dir /home/frappe/frappe-bench/config/pids
pidfile /home/frappe/frappe-bench/config/pids/redis-cache.pid
bind 127.0.0.1
port 13000
maxmemory 512mb
maxmemory {{ doc.redis_cache_size }}mb
maxmemory-policy allkeys-lru
appendonly no
save ""
Expand Down
1 change: 1 addition & 0 deletions press/patches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -135,5 +135,6 @@ press.press.doctype.server.patches.set_plan_and_subscription
press.patches.v0_7_0.move_site_db_access_users_to_site_db_perm_manager
press.press.doctype.drip_email.patches.set_correct_field_for_html
press.patches.v0_7_0.set_label_for_site_database_user
press.press.doctype.press_settings.patches.set_redis_cache_size
press.press.doctype.virtual_machine.patches.set_root_disk_size
press.press.doctype.virtual_machine_image.patches.set_root_size
10 changes: 9 additions & 1 deletion press/press/doctype/deploy_candidate/deploy_candidate.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"docker_image_tag",
"feature_flags_section",
"is_redisearch_enabled",
"redis_cache_size",
"use_app_cache",
"compress_app_cache",
"column_break_tkdd",
Expand Down Expand Up @@ -415,6 +416,13 @@
"fieldname": "no_cache",
"fieldtype": "Check",
"label": "No Cache"
},
{
"default": "512",
"fetch_from": "group.redis_cache_size",
"fieldname": "redis_cache_size",
"fieldtype": "Int",
"label": "Redis Cache Size (MB)"
}
],
"links": [
Expand All @@ -431,7 +439,7 @@
"link_fieldname": "document_name"
}
],
"modified": "2024-06-21 14:12:47.335402",
"modified": "2024-12-27 11:59:09.917364",
"modified_by": "Administrator",
"module": "Press",
"name": "Deploy Candidate",
Expand Down
1 change: 1 addition & 0 deletions press/press/doctype/deploy_candidate/deploy_candidate.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class DeployCandidate(Document):
pending_duration: DF.Time | None
pending_end: DF.Datetime | None
pending_start: DF.Datetime | None
redis_cache_size: DF.Int
retry_count: DF.Int
scheduled_time: DF.Datetime | None
status: DF.Literal["Draft", "Scheduled", "Pending", "Preparing", "Running", "Success", "Failure"]
Expand Down
11 changes: 11 additions & 0 deletions press/press/doctype/press_settings/patches/set_redis_cache_size.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import frappe
from frappe.core.utils import find


def execute():
frappe.reload_doctype("Press Settings")
settings = frappe.get_single("Press Settings")
if not settings.redis_cache_size:
redis_cache_size_field = find(settings.meta.fields, lambda x: x.fieldname == "redis_cache_size")
settings.redis_cache_size = redis_cache_size_field.default
settings.save()
15 changes: 14 additions & 1 deletion press/press/doctype/press_settings/press_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@
"use_staging_ca",
"ssh_section",
"ssh_certificate_authority",
"bench_section",
"redis_cache_size",
"monitoring_section",
"monitor_server",
"monitor_token",
Expand Down Expand Up @@ -1272,11 +1274,22 @@
"fieldname": "enable_email_pre_verification",
"fieldtype": "Check",
"label": "Enable Email Pre-Verification"
},
{
"fieldname": "bench_section",
"fieldtype": "Section Break",
"label": "Bench"
},
{
"default": "512",
"fieldname": "redis_cache_size",
"fieldtype": "Int",
"label": "Redis Cache Size (MB)"
}
],
"issingle": 1,
"links": [],
"modified": "2024-12-10 15:07:57.494659",
"modified": "2024-12-27 11:44:09.454080",
"modified_by": "Administrator",
"module": "Press",
"name": "Press Settings",
Expand Down
1 change: 1 addition & 0 deletions press/press/doctype/press_settings/press_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class PressSettings(Document):
razorpay_key_secret: DF.Password | None
razorpay_webhook_secret: DF.Data | None
realtime_job_updates: DF.Check
redis_cache_size: DF.Int
remote_access_key_id: DF.Data | None
remote_link_expiry: DF.Int
remote_secret_access_key: DF.Password | None
Expand Down
9 changes: 8 additions & 1 deletion press/press/doctype/release_group/release_group.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"column_break_14",
"bench_config",
"gunicorn_threads_per_worker",
"redis_cache_size",
"automatic_worker_allocation_section",
"min_gunicorn_workers",
"min_background_workers",
Expand Down Expand Up @@ -367,10 +368,16 @@
"fieldtype": "Link",
"label": "Build Server",
"options": "Server"
},
{
"default": "512",
"fieldname": "redis_cache_size",
"fieldtype": "Int",
"label": "Redis Cache Size (MB)"
}
],
"links": [],
"modified": "2024-09-17 14:44:01.541194",
"modified": "2024-12-27 11:58:29.907938",
"modified_by": "Administrator",
"module": "Press",
"name": "Release Group",
Expand Down
10 changes: 9 additions & 1 deletion press/press/doctype/release_group/release_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ class ReleaseGroup(Document, TagHelpers):
from press.press.doctype.release_group_variable.release_group_variable import (
ReleaseGroupVariable,
)
from press.press.doctype.resource_tag.resource_tag import ResourceTag
from press.press.doctype.resource_tag.resource_tag import (
ResourceTag,
)

apps: DF.Table[ReleaseGroupApp]
bench_config: DF.Code | None
Expand All @@ -111,6 +113,7 @@ class ReleaseGroup(Document, TagHelpers):
mounts: DF.Table[ReleaseGroupMount]
packages: DF.Table[ReleaseGroupPackage]
public: DF.Check
redis_cache_size: DF.Int
saas_app: DF.Link | None
saas_bench: DF.Check
servers: DF.Table[ReleaseGroupServer]
Expand Down Expand Up @@ -371,11 +374,16 @@ def update_config_in_release_group(self, common_site_config, bench_config):
else:
value = d.value
self.append("common_site_config_table", {"key": d.key, "value": value, "type": d.type})
# redis_cache_size is a field on release group but we want to treat it as config key
# TODO: add another interface for updating similar values
if d["key"] == "redis_cache_size":
self.redis_cache_size = int(d.value)

for d in bench_config:
if d["key"] == "http_timeout":
# http_timeout should be the only thing configurable in bench_config
self.bench_config = json.dumps({"http_timeout": int(d["value"])}, indent=4)

if bench_config == []:
self.bench_config = json.dumps({})

Expand Down
Loading