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:
@@ -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)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user