2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-23 01:53:28 +00:00

Handle unclean loss of current proxy host

If transition is less than gentle, provide a path to restore automatic
if it gets moved.
This commit is contained in:
Jarrod Johnson 2018-07-18 14:32:39 -04:00
parent dcad9f5a75
commit 32f944e67c

View File

@ -678,7 +678,13 @@ class ProxyConsole(object):
def write(self, data):
# Relay data to the collective manager
tlvdata.send(self.remote, data)
try:
tlvdata.send(self.remote, data)
except Exception:
if self.clisession:
self.clisession.detach()
self.clisession = None
def attachsession(self, session):
self.clisession = session
@ -694,13 +700,20 @@ class ProxyConsole(object):
#facilitate redirect rather than relay on manager change
},
}
remote = socket.create_connection((self.managerinfo['address'], 13001))
remote = ssl.wrap_socket(remote, cert_reqs=ssl.CERT_NONE,
keyfile='/etc/confluent/privkey.pem',
certfile='/etc/confluent/srvcert.pem')
if not util.cert_matches(self.managerinfo['fingerprint'],
remote.getpeercert(binary_form=True)):
raise Exception('Invalid peer certificate')
try:
remote = socket.create_connection((self.managerinfo['address'], 13001))
remote = ssl.wrap_socket(remote, cert_reqs=ssl.CERT_NONE,
keyfile='/etc/confluent/privkey.pem',
certfile='/etc/confluent/srvcert.pem')
if not util.cert_matches(self.managerinfo['fingerprint'],
remote.getpeercert(binary_form=True)):
raise Exception('Invalid peer certificate')
except Exception:
eventlet.sleep(3)
if self.clisession:
self.clisession.detach()
self.detachsession(None)
return
tlvdata.recv(remote)
tlvdata.recv(remote)
tlvdata.send(remote, termreq)
@ -710,7 +723,10 @@ class ProxyConsole(object):
def detachsession(self, session):
# we will disappear, so just let that happen...
if self.remote:
tlvdata.send(self.remote, {'operation': 'stop'})
try:
tlvdata.send(self.remote, {'operation': 'stop'})
except Exception:
pass
self.clisession = None
def send_break(self):