fix(crowdsec): cscli-Aufrufe nur wenn Agent läuft — v1.2.64

Wenn CrowdSec gestoppt war, hing ServiceStatus auf cscli decisions/alerts/
bouncers/machines (Socket des gestoppten Agents). Der Status-Endpoint
antwortete nie → status=undefined im UI → Switch war disabled (rotes Schild).

Fix: cscli-Datenabrufe (decisions, alerts, bouncers, machines) nur wenn
AgentRunning=true. Version-Abruf via cscli version bleibt (schlägt schnell
fehl wenn Agent gestoppt, kein Hang).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Debian
2026-06-02 09:09:39 +02:00
parent 414dad6b3b
commit 9580070a50
2 changed files with 6 additions and 2 deletions

View File

@@ -1 +1 @@
1.2.63 1.2.64

View File

@@ -172,8 +172,12 @@ func ServiceStatus(ctx context.Context) Status {
st.Version = strings.TrimSpace(scanner.Text()) st.Version = strings.TrimSpace(scanner.Text())
} }
} }
}
// Best-effort counts — ignore errors (agent may be stopped). // Only query cscli data endpoints when the agent is running — cscli
// hangs on its local socket when the agent is stopped, which would
// block the entire status response and leave the UI with no data.
if st.AgentRunning {
if decisions, err := Decisions(ctx); err == nil { if decisions, err := Decisions(ctx); err == nil {
st.DecisionCount = len(decisions) st.DecisionCount = len(decisions)
} }