From e228fc02fb356b6b9e14eceef58cec2c3ebea55d Mon Sep 17 00:00:00 2001 From: kappa Date: Sun, 8 Feb 2026 11:18:37 +0900 Subject: [PATCH] Fix K8s deployment crash: ensure DB directory exists on startup init_db() now creates the parent directory for the SQLite database file before connecting. Also sets HAPROXY_DB_FILE in the K8s deployment to /app/data/ since the container doesn't have /opt/haproxy/conf/. Co-Authored-By: Claude Opus 4.6 --- haproxy_mcp/db.py | 5 +++++ k8s/deployment.yaml | 2 ++ 2 files changed, 7 insertions(+) diff --git a/haproxy_mcp/db.py b/haproxy_mcp/db.py index ec7caa5..e0d2a77 100644 --- a/haproxy_mcp/db.py +++ b/haproxy_mcp/db.py @@ -63,6 +63,11 @@ def init_db() -> None: Creates tables if they don't exist, then checks for existing JSON/map files to migrate data from. """ + # Ensure parent directory exists for the database file + db_dir = os.path.dirname(DB_FILE) + if db_dir: + os.makedirs(db_dir, exist_ok=True) + conn = get_connection() cur = conn.cursor() diff --git a/k8s/deployment.yaml b/k8s/deployment.yaml index 0a5a5ec..f0b959a 100644 --- a/k8s/deployment.yaml +++ b/k8s/deployment.yaml @@ -41,6 +41,8 @@ spec: value: "/root/.ssh/id_rsa" - name: SSH_PORT value: "22" + - name: HAPROXY_DB_FILE + value: "/app/data/haproxy_mcp.db" - name: LOG_LEVEL value: "INFO" volumeMounts: