From 5850ef835842b31568d17d90f0c9db4d4963a58a Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 15 Jan 2026 17:39:40 +0100 Subject: [PATCH] fix: avoid update failure on /opt/sk cwd --- CHANGELOG.md | 1 + backend/update.py | 6 ++++- .../requirements/bugs/BUG_000001.md | 26 +++++++++++++++++++ scripts/update_client.sh | 8 ++++++ 4 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 project-management/requirements/bugs/BUG_000001.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 90ca51a..0ba2a9d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -82,6 +82,7 @@ By: Codex (GPT-5) | 15.01.2026 | ⚙️ Code | ID: EPIC_000013 System Telemetry Endpoint und UI umgesetzt. By: Codex (GPT-5) | | 15.01.2026 | 📝 Req | ID: EPIC_000009 Update Webservice als erledigt markiert. By: Codex (GPT-5) | | 15.01.2026 | 🚀 Release | ID: VERSION auf 0.2.2 erhoeht. By: Codex (GPT-5) | +| 15.01.2026 | 🐞 Fix | ID: BUG_000001 Update-Apply scheitert nicht mehr an WorkingDirectory. By: Codex (GPT-5) | | 15.01.2026 | ⚙️ Code | ID: Makefile restart-Target hinzugefuegt. By: Codex (GPT-5) | --- diff --git a/backend/update.py b/backend/update.py index b30d40e..e4a963f 100644 --- a/backend/update.py +++ b/backend/update.py @@ -188,7 +188,11 @@ def _run_async(script_path: Path, settings: Settings) -> None: env["SKD_UPDATE_STATUS_FILE"] = settings.update_status_file env["SKD_UPDATE_LOG_FILE"] = settings.update_log_file subprocess.Popen( - [str(script_path)], env=env, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL + [str(script_path)], + env=env, + cwd="/", + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, ) diff --git a/project-management/requirements/bugs/BUG_000001.md b/project-management/requirements/bugs/BUG_000001.md new file mode 100644 index 0000000..074618d --- /dev/null +++ b/project-management/requirements/bugs/BUG_000001.md @@ -0,0 +1,26 @@ +ID: BUG_000001 | Version: 0.2.2 | Status: Draft +By: Codex (GPT-5) + +# BUG_000001: Update scheitert wegen WorkingDirectory /opt/sk + +## Beschreibung +Beim Update-Apply bricht `scripts/update_client.sh` ab, wenn `/opt/sk` verschoben wird, +weil der Prozess selbst im Verzeichnis arbeitet (WorkingDirectory=/opt/sk). +Das fuehrt zu einem Abbruch ohne Abschlussstatus (status bleibt `in_progress`). + +## Schritte zur Reproduktion +1. `skd.service` laeuft mit `WorkingDirectory=/opt/sk`. +2. Update ueber UI oder `POST /update/apply` starten. +3. Script stoppt Service und versucht `mv /opt/sk ...`. +4. Fehler wegen busy CWD, Script bricht ab, Service bleibt gestoppt. + +## Erwartetes Verhalten +Update-Prozess laeuft aus einem neutralen CWD (z.B. `/`), und Fehler werden als `failed` +in Status/Logs vermerkt. + +## Ist-Verhalten +Update bleibt im Status `in_progress`, Service bleibt gestoppt. + +## Fix-Idee +- `subprocess.Popen(..., cwd="/")` fuer Update-Client. +- Fehlertrap in `scripts/update_client.sh` fuer `failed` Status. diff --git a/scripts/update_client.sh b/scripts/update_client.sh index 5831736..a15cf58 100755 --- a/scripts/update_client.sh +++ b/scripts/update_client.sh @@ -87,6 +87,14 @@ cleanup() { } trap cleanup EXIT +error_exit() { + local msg="${1:-update failed}" + SKD_VERSION="${VERSION:-unknown}" SKD_STATUS="failed" SKD_ERROR="${msg}" \ + SKD_TIMESTAMP="$(date -u '+%Y-%m-%dT%H:%M:%SZ')" SKD_STATUS_FILE="${STATUS_FILE}" \ + SKD_LOG_FILE="${LOG_FILE}" report_status "failed" "${msg}" +} +trap 'error_exit "update failed at line ${LINENO}"' ERR + require_cmd() { if ! command -v "$1" >/dev/null 2>&1; then echo "Required command not found: $1" >&2