Fix: config-sync sidecar logging (stderr + idle heartbeat) #89

Merged
k.renner merged 1 commits from fix-config-sync-logging into master 2026-06-29 20:21:50 +00:00
+10 -1
View File
@@ -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"