NSX-mh: Failover controller connections on socket failures
Upon a socket connection failure, release the current connection and acquire a new one to a different controller. This is achieved by treating socket connection failures as 503 errors returned by the controller. Also, ensure an even distribution of initial connection priorities across controllers. Change-Id: I988b46a4d1f51e4ad6b22ed3d892eab6a96a3acd Closes-Bug: 1485883
This commit is contained in:
parent
3225db15ab
commit
1602baf661
|
@ -66,8 +66,8 @@ class EventletApiClient(base.ApiClientBase):
|
|||
# Connection pool is a list of queues.
|
||||
self._conn_pool = eventlet.queue.PriorityQueue()
|
||||
self._next_conn_priority = 1
|
||||
for host, port, is_ssl in api_providers:
|
||||
for _ in range(concurrent_connections):
|
||||
for _ in range(concurrent_connections):
|
||||
for host, port, is_ssl in api_providers:
|
||||
conn = self._create_connection(host, port, is_ssl)
|
||||
self._conn_pool.put((self._next_conn_priority, conn))
|
||||
self._next_conn_priority += 1
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
import abc
|
||||
import copy
|
||||
import socket
|
||||
import time
|
||||
|
||||
import eventlet
|
||||
|
@ -186,9 +187,12 @@ class ApiRequest(object):
|
|||
'url': self._url, 'status': response.status})
|
||||
raise Exception(_('Server error return: %s'), response.status)
|
||||
return response
|
||||
except socket.error:
|
||||
is_conn_service_unavail = True
|
||||
except Exception as e:
|
||||
if isinstance(e, httplib.BadStatusLine):
|
||||
msg = (_("Invalid server response"))
|
||||
|
||||
else:
|
||||
msg = str(e)
|
||||
if response is None:
|
||||
|
|
Loading…
Reference in New Issue