Files
haproxy-openmanager/backend/services
Taylan Bakırcıoğlu f1a3826334 fix(backend): Allow backends without servers to be deployed
MINIMAL FIX: Enable backend-first workflow (add servers later)

Problem:
1. User creates backend 'deneme-sil' without servers
2. Config generator SKIPs backend (no servers = skip)
3. User adds server 'server1-sil'
4. Config shows: 'server server1-sil 1.1.1.1:1233' WITHOUT backend block
5. HAProxy validation FAILS (server without backend = syntax error)

User Requirement:
- Create backend first (without servers)
- Assign backend to frontend (default_backend)
- Add servers later
- Standard HAProxy workflow

Solution (MINIMAL - 2 small changes):

1. haproxy_config.py (line 453-454):
   OLD: Skip backend if no servers (continue)
   NEW: Write backend block anyway (remove continue)

   Result:
   backend deneme-sil
       balance roundrobin
       mode http
       # (no servers yet - backend will show as DOWN)

   Valid HAProxy syntax - check

2. cluster.py (line 1600-1607):
   OLD: Only mark backends with servers as APPLIED
   NEW: Mark ALL backends as APPLIED (servers optional)

   Reason: ALL backends are now in config (even without servers)

Why This Is Better Than Previous Approach:
- Only 2 lines changed (vs 50+ lines)
- No complex logic added
- No risk to existing functionality
- HAProxy naturally handles backends without servers (shows as DOWN)
- Aligns with standard HAProxy usage patterns

Test Scenarios:
- Create backend without servers -> Backend block written to config
- Apply -> HAProxy accepts config (backend DOWN)
- Frontend can use backend (use_backend, default_backend)
- Add server later -> Server added to existing backend block
- Apply -> HAProxy accepts, backend goes UP

HAProxy Behavior:
- Backend without servers: DOWN (no available servers)
- Backend with disabled servers: DOWN (all servers disabled)
- Backend with active servers: UP (servers available)

Related: caa21f0 (has_pending_config fix)
Refs: #backend-workflow #server-optional #haproxy-syntax
2025-11-17 14:15:44 +03:00
..
2025-10-27 12:14:03 +03:00
2025-10-27 12:14:03 +03:00