From 987db9eb0b774d84cd1cb7a253a232aa67e697fd Mon Sep 17 00:00:00 2001 From: Konstantin Renner Date: Mon, 29 Jun 2026 22:06:42 +0200 Subject: [PATCH] fix(home-assistant): make config-sync logs reliable + observable Only the "starting" line surfaced in `kubectl logs`: busybox sh block-buffers stdout when it's a pipe, so subsequent lines could sit unflushed for the life of the loop. Log to stderr instead (unbuffered; still captured in the container log). Also emit a one-time "initial check: config in sync" line so an idle loop is observably alive even when there's nothing to sync. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01GgbyKgrN1yYWrkAA32rJE5 --- kubernetes/apps/home-assistant/config-sync.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/kubernetes/apps/home-assistant/config-sync.sh b/kubernetes/apps/home-assistant/config-sync.sh index ef788b92..afea91c2 100644 --- a/kubernetes/apps/home-assistant/config-sync.sh +++ b/kubernetes/apps/home-assistant/config-sync.sh @@ -23,7 +23,11 @@ HA_URL="${HA_URL:-http://127.0.0.1:8123}" # (notably www/ and untracked runtime files) is left untouched. PATHS="automations.yaml automations packages scripts.yaml templates.yaml configuration.yaml notify.yaml groups.yaml powercalc.yaml blueprints" -log() { echo "$(date -Iseconds) config-sync: $*"; } +# Log to stderr: busybox sh block-buffers stdout when it is a pipe (as under +# kubelet), so stdout log lines can sit unflushed for the lifetime of the loop. +# stderr is unbuffered, so lines reach `kubectl logs` immediately. Both streams +# are captured into the container log. +log() { echo "$(date -Iseconds) config-sync: $*" >&2; } reload_ha() { if [ -z "${HA_TOKEN:-}" ]; then @@ -53,6 +57,7 @@ git config --global pack.windowMemory 32m 2>/dev/null || true git config --global pack.deltaCacheSize 32m 2>/dev/null || true git config --global core.deltaBaseCacheLimit 16m 2>/dev/null || true +FIRST=1 while true; do if git fetch --quiet origin "${BRANCH}" 2>/dev/null; then REMOTE="$(git rev-parse "origin/${BRANCH}" 2>/dev/null || echo none)" @@ -80,7 +85,11 @@ while true; do # paths. Advance the ref to keep git status clean — but do NOT reload. git update-ref "refs/heads/${BRANCH}" "${REMOTE}" log "non-config commit; advanced ref to ${REMOTE} (no reload)" + elif [ "${FIRST}" = 1 ]; then + # Nothing to do on startup — log once so an idle loop is observably alive. + log "initial check: config in sync with origin/${BRANCH} at $(git rev-parse --short "${REMOTE}")" fi + FIRST=0 fi else log "WARN git fetch failed; will retry" -- 2.54.0