fix: avoid update failure on /opt/sk cwd

This commit is contained in:
2026-01-15 17:39:40 +01:00
parent 835244b7e0
commit 5850ef8358
4 changed files with 40 additions and 1 deletions

View File

@ -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 | ⚙️ 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 | 📝 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 | 🚀 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) | | 15.01.2026 | ⚙️ Code | ID: Makefile restart-Target hinzugefuegt. By: Codex (GPT-5) |
--- ---

View File

@ -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_STATUS_FILE"] = settings.update_status_file
env["SKD_UPDATE_LOG_FILE"] = settings.update_log_file env["SKD_UPDATE_LOG_FILE"] = settings.update_log_file
subprocess.Popen( 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,
) )

View File

@ -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.

View File

@ -87,6 +87,14 @@ cleanup() {
} }
trap cleanup EXIT 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() { require_cmd() {
if ! command -v "$1" >/dev/null 2>&1; then if ! command -v "$1" >/dev/null 2>&1; then
echo "Required command not found: $1" >&2 echo "Required command not found: $1" >&2