mirror of
https://github.com/taylanbakircioglu/haproxy-openmanager.git
synced 2026-09-16 23:55:13 +00:00
8418025744
PROBLEM: - Agents registered with pool_id = NULL - UI doesn't show agents without pool assignment - Auto-healing only works when server_statuses present - New agents with empty HAProxy config never get pool_id ROOT CAUSE: - Agent auto-register INSERT excluded pool_id column - Auto-healing (line 1417-1422) only triggers inside 'if server_statuses:' block - Fresh agents send no server_statuses → auto-healing never runs - Agent sits with pool_id = NULL indefinitely ANALYSIS: - Previous commit 1f9d8c2 added auto-healing for edge case (cluster before pool) - But auto-healing has conditional prerequisite: server_statuses must exist - New agents: empty HAProxy config → no server_statuses → no healing - This was working before because agents had config from start SOLUTION: - Extract pool_id from cluster_id during registration - Query haproxy_clusters for pool_id using heartbeat's cluster_id - Insert agent with pool_id immediately (no wait for auto-heal) - Two auto-register paths fixed: with API key + without API key EDGE CASES HANDLED: 1. cluster_id missing → pool_id = NULL → auto-healing fallback ✅ 2. cluster deleted → pool_id = NULL → auto-healing fallback ✅ 3. cluster pool_id NULL → pool_id = NULL → auto-healing works ✅ 4. Old agent script → no cluster_id → auto-healing works ✅ COMPATIBILITY: - Auto-healing preserved (line 1417-1422 untouched) - Two mechanisms work together harmoniously - Backward compatible with existing agents - No breaking changes IMPACT: - New agents visible in UI immediately - Faster registration (no wait for auto-heal) - Reduced heartbeat cycles to full functionality - Better user experience TESTING REQUIRED: 1. Delete agent from database 2. Install fresh agent with cluster_id in config 3. Verify pool_id populated on registration 4. Verify agent appears in UI immediately 5. Verify existing agents unaffected