fix: persist and recover the Agent's real installation_id (heartbeat activation)
POST /v1/agents/enroll now returns installation_id; new installs persist it to agent.env immediately. Runtime recovery precedence: existing SQLite installation_identity -> configured INSTALLATION_ID -> authenticated GET /v1/agents/me/identity. Recovery fails closed on missing/malformed/ mismatched identity rather than inventing a UUID (which the Hub would then reject as a conflicting Installation on an already-enrolled Agent). An explicit AGENT_JOBS_ENABLED gate stops the service from claiming a job right after the first heartbeat. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -73,6 +73,7 @@ def write_agent_env(install_dir_path: Path, enroll_result: dict) -> None:
|
||||
lines = [
|
||||
(f"GTI_HUB_URL={enroll_result.get('hub_url') or hub_url()}"),
|
||||
(f"AGENT_ID={enroll_result.get('agent_id') or ''}"),
|
||||
(f"INSTALLATION_ID={enroll_result.get('installation_id') or ''}"),
|
||||
("COMPANY_ID="),
|
||||
("COMPANY_UF="),
|
||||
("FIREBIRD_DATABASE_PATH="),
|
||||
@@ -182,4 +183,4 @@ def audit_event(agent_token: str, hub: str, event_type: str, message: str) -> No
|
||||
)
|
||||
response.raise_for_status()
|
||||
except Exception: # noqa: BLE001 — best effort only
|
||||
return
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user