agent/bootstrap: Debug-Modus automatisch beim allerersten Bootstrap aktivieren
Vor dem UPDATE geprueft, ob agent_secret_issued_at noch NIE gesetzt war - nur dann (echte Neuinstallation, nicht ein spaeterer Self-Heal-Re- Bootstrap bei 401 auf checkin) wird debug_mode_until gleich mit auf jetzt+DEBUG_MODE_DURATION_HOURS gesetzt. Nutzer-Wunsch (02.09.2026): kurz nach dem ersten Boot des fertig installierten Systems soll ein frisch zugewiesenes Merkmal ohne stundenlange Wartezeit (normales Poll-Intervall: 6 Stunden) ankommen - der Debug-Modus (60s-Intervall) ist dafuer schon vorhanden, sprang bisher aber nie automatisch an.
This commit is contained in:
1 parent
c09aff49df
commit
d826505bdb
1 file changed
+25
@@ -2694,6 +2694,23 @@ def agent_bootstrap(payload: AgentBootstrapRequest):
|
|||||||
|
|
||||||
with get_database_connection() as conn:
|
with get_database_connection() as conn:
|
||||||
with conn.cursor() as cur:
|
with conn.cursor() as cur:
|
||||||
|
# Vor dem Update geprueft: war agent_secret_issued_at NOCH NIE
|
||||||
|
# gesetzt? Das unterscheidet den ALLERERSTEN Bootstrap (echte
|
||||||
|
# Neuinstallation, siehe postinstall.sh) von einem spaeteren
|
||||||
|
# Self-Heal-Re-Bootstrap (401 auf checkin, agent.py) - nur beim
|
||||||
|
# allerersten Mal wird gleich anschliessend automatisch der
|
||||||
|
# Debug-Modus aktiviert (Nutzer-Wunsch 02.09.2026: kurz nach dem
|
||||||
|
# ersten Boot des fertig installierten Systems soll ein frisch
|
||||||
|
# zugewiesenes Merkmal ohne stundenlange Wartezeit ankommen,
|
||||||
|
# ohne dass der Debug-Modus jedesmal bei jedem Re-Bootstrap
|
||||||
|
# erneut anspringt).
|
||||||
|
cur.execute(
|
||||||
|
"SELECT agent_secret_issued_at FROM devices WHERE id = %s",
|
||||||
|
(payload.device_id,),
|
||||||
|
)
|
||||||
|
vorher = cur.fetchone()
|
||||||
|
ist_erstinstallation = vorher is not None and vorher[0] is None
|
||||||
|
|
||||||
cur.execute(
|
cur.execute(
|
||||||
"""
|
"""
|
||||||
UPDATE devices
|
UPDATE devices
|
||||||
@@ -2715,6 +2732,14 @@ def agent_bootstrap(payload: AgentBootstrapRequest):
|
|||||||
(payload.device_id,),
|
(payload.device_id,),
|
||||||
)
|
)
|
||||||
existing = cur.fetchone()
|
existing = cur.fetchone()
|
||||||
|
elif ist_erstinstallation:
|
||||||
|
cur.execute(
|
||||||
|
"UPDATE devices SET debug_mode_until = %s WHERE id = %s",
|
||||||
|
(
|
||||||
|
datetime.now(timezone.utc) + timedelta(hours=DEBUG_MODE_DURATION_HOURS),
|
||||||
|
payload.device_id,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
if updated is None:
|
if updated is None:
|
||||||
if existing is not None and existing[0] is not None:
|
if existing is not None and existing[0] is not None:
|
||||||
|
|||||||
Reference in new issue
Block a user