From f45228c06711085e4b0194c347d750e5814ebd0c Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 21 Jun 2018 15:14:56 -0400 Subject: [PATCH] Auto-migrate open console session on loss of management This will keep consoles connected across a manager change. Note that as it stands, a console session enduring multiple changes will become increasingly convoluted as the redirect chain will increase every time, rather than shorting back to the entry point. --- confluent_server/confluent/consoleserver.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/confluent_server/confluent/consoleserver.py b/confluent_server/confluent/consoleserver.py index 59011880..293b82f6 100644 --- a/confluent_server/confluent/consoleserver.py +++ b/confluent_server/confluent/consoleserver.py @@ -240,6 +240,7 @@ class ConsoleHandler(object): # Do not do console connect for nodes managed by another # confluent collective member self._is_local = False + self._detach() self._disconnect() else: self._is_local = True @@ -306,6 +307,10 @@ class ConsoleHandler(object): 'none or interactive,\r\nconnection loss, or service restart]') self.clearpending = True + def _detach(self): + for ses in list(self.livesessions): + ses.detach() + def _disconnect(self): if self.connectionthread: self.connectionthread.kill() @@ -752,9 +757,6 @@ class ConsoleSession(object): it is a hook for confluent to abstract the concept of a terminal between console and shell. """ - #TODO(jjohnosn2): collective mode, connect to collective manager - #if not self. This avoids sockapi and httpapi from having to - #understand the situation self.conshdl = connect_node(self.node, self.configmanager, self.username) def send_break(self): @@ -794,7 +796,10 @@ class ConsoleSession(object): :return: """ - pass + self.conshdl.detachsession(self) + self.connect_session() + self.conshdl.attachsession(self) + self.write = self.conshdl.write def got_data(self, data): """Receive data from console and buffer