Fix cluster client issues

- Extract real client IP address from websocket connection
- Preserve connected_at timestamp for accurate uptime calculation
- Send full GPU device info from client to master for proper VRAM reporting
parent e5e3cc98
......@@ -86,13 +86,7 @@ class ClusterClient:
'capabilities': capabilities,
'weight': self.client_weight,
'shared_dir': self.shared_dir,
'gpu_info': {
'cuda_available': gpu_info['cuda'],
'rocm_available': gpu_info['rocm'],
'cuda_devices': gpu_info['cuda_devices'],
'rocm_devices': gpu_info['rocm_devices'],
'available_backends': available_backends
}
'gpu_info': gpu_info # Send full gpu_info including device details
}
}
await self.websocket.send(json.dumps(auth_msg))
......
......@@ -209,7 +209,11 @@ class ClusterMaster:
# Get hostname and IP
hostname = client_info.get('hostname', 'unknown')
ip_address = '127.0.0.1' # Placeholder, could be extracted from websocket
# Try to get real IP address from websocket
try:
ip_address = websocket.remote_address[0] if websocket.remote_address else '127.0.0.1'
except:
ip_address = '127.0.0.1'
# Save client to database
weight = client_info.get('weight', 100)
......
......@@ -1665,8 +1665,22 @@ def save_cluster_client(client_id: str, token: str, hostname: str, ip_address: s
last_seen = CURRENT_TIMESTAMP
''', (client_id, token, hostname, ip_address, weight, gpu_info_json, available_backends_json))
else:
# For SQLite, preserve connected_at if client already exists
cursor.execute('SELECT connected_at FROM cluster_clients WHERE client_id = ?', (client_id,))
existing = cursor.fetchone()
if existing and existing['connected_at']:
# Update existing client, preserve connected_at
cursor.execute('''
UPDATE cluster_clients SET
hostname = ?, ip_address = ?, weight = ?, gpu_info = ?, available_backends = ?,
connected = 1, last_seen = CURRENT_TIMESTAMP
WHERE client_id = ?
''', (hostname, ip_address, weight, gpu_info_json, available_backends_json, client_id))
else:
# Insert new client
cursor.execute('''
INSERT OR REPLACE INTO cluster_clients
INSERT INTO cluster_clients
(client_id, token, hostname, ip_address, weight, gpu_info, available_backends, connected, connected_at, last_seen)
VALUES (?, ?, ?, ?, ?, ?, ?, 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)
''', (client_id, token, hostname, ip_address, weight, gpu_info_json, available_backends_json))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment