mirror of
https://github.com/DeBrosOfficial/orama.git
synced 2026-03-17 09:16:57 +00:00
feat: enhance WebRTC port allocation with existing allocation checks and increase upload timeout
This commit is contained in:
parent
f1dc3014fc
commit
3e9ef5ac6c
@ -1054,8 +1054,14 @@ func (g *Gateway) handleNamespaceGatewayRequest(w http.ResponseWriter, r *http.R
|
|||||||
proxyReq.Header.Set(HeaderInternalAuthNamespace, validatedNamespace)
|
proxyReq.Header.Set(HeaderInternalAuthNamespace, validatedNamespace)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Use a longer timeout for upload paths (IPFS add can be slow for large files)
|
||||||
|
proxyTimeout := 30 * time.Second
|
||||||
|
if strings.HasPrefix(r.URL.Path, "/v1/storage/upload") || strings.HasPrefix(r.URL.Path, "/v1/storage/pin") {
|
||||||
|
proxyTimeout = 300 * time.Second
|
||||||
|
}
|
||||||
|
|
||||||
// Execute proxy request using shared transport for connection pooling
|
// Execute proxy request using shared transport for connection pooling
|
||||||
httpClient := &http.Client{Timeout: 30 * time.Second, Transport: g.proxyTransport}
|
httpClient := &http.Client{Timeout: proxyTimeout, Transport: g.proxyTransport}
|
||||||
resp, err := httpClient.Do(proxyReq)
|
resp, err := httpClient.Do(proxyReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cb.RecordFailure()
|
cb.RecordFailure()
|
||||||
|
|||||||
@ -331,6 +331,7 @@ func (cm *ClusterManager) getClusterNodesWithIPs(ctx context.Context, clusterID
|
|||||||
FROM namespace_cluster_nodes ncn
|
FROM namespace_cluster_nodes ncn
|
||||||
JOIN dns_nodes dn ON ncn.node_id = dn.id
|
JOIN dns_nodes dn ON ncn.node_id = dn.id
|
||||||
WHERE ncn.namespace_cluster_id = ?
|
WHERE ncn.namespace_cluster_id = ?
|
||||||
|
GROUP BY ncn.node_id
|
||||||
`
|
`
|
||||||
if err := cm.db.Query(internalCtx, &rows, query, clusterID); err != nil {
|
if err := cm.db.Query(internalCtx, &rows, query, clusterID); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@ -49,6 +49,13 @@ func (wpa *WebRTCPortAllocator) AllocateSFUPorts(ctx context.Context, nodeID, na
|
|||||||
retryDelay := 100 * time.Millisecond
|
retryDelay := 100 * time.Millisecond
|
||||||
|
|
||||||
for attempt := 0; attempt < maxRetries; attempt++ {
|
for attempt := 0; attempt < maxRetries; attempt++ {
|
||||||
|
// Re-check for existing allocation (handles read-after-write lag on retries)
|
||||||
|
if attempt > 0 {
|
||||||
|
if existing, err := wpa.GetSFUPorts(ctx, namespaceClusterID, nodeID); err == nil && existing != nil {
|
||||||
|
return existing, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
block, err := wpa.tryAllocateSFUPorts(internalCtx, nodeID, namespaceClusterID)
|
block, err := wpa.tryAllocateSFUPorts(internalCtx, nodeID, namespaceClusterID)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
wpa.logger.Info("SFU ports allocated",
|
wpa.logger.Info("SFU ports allocated",
|
||||||
@ -148,6 +155,13 @@ func (wpa *WebRTCPortAllocator) AllocateTURNPorts(ctx context.Context, nodeID, n
|
|||||||
retryDelay := 100 * time.Millisecond
|
retryDelay := 100 * time.Millisecond
|
||||||
|
|
||||||
for attempt := 0; attempt < maxRetries; attempt++ {
|
for attempt := 0; attempt < maxRetries; attempt++ {
|
||||||
|
// Re-check for existing allocation (handles read-after-write lag on retries)
|
||||||
|
if attempt > 0 {
|
||||||
|
if existing, err := wpa.GetTURNPorts(ctx, namespaceClusterID, nodeID); err == nil && existing != nil {
|
||||||
|
return existing, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
block, err := wpa.tryAllocateTURNPorts(internalCtx, nodeID, namespaceClusterID)
|
block, err := wpa.tryAllocateTURNPorts(internalCtx, nodeID, namespaceClusterID)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
wpa.logger.Info("TURN ports allocated",
|
wpa.logger.Info("TURN ports allocated",
|
||||||
|
|||||||
@ -75,6 +75,10 @@ resolve_nodes "$@" | while IFS='|' read -r user host pass; do
|
|||||||
echo "[$i/$node_count] $user@$host"
|
echo "[$i/$node_count] $user@$host"
|
||||||
upgrade_node "$user" "$host" "$pass"
|
upgrade_node "$user" "$host" "$pass"
|
||||||
echo " ✓ Done"
|
echo " ✓ Done"
|
||||||
|
if [ "$i" -lt "$node_count" ]; then
|
||||||
|
echo " Waiting 30s before next node..."
|
||||||
|
sleep 30
|
||||||
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user