mirror of
https://github.com/xcat2/confluent.git
synced 2025-04-19 11:37:18 +00:00
Numerous fixes for shell server
On exit, clear the terminal buffer and invalidate the session. This avoids the web ui being very attached to a closed, dead session, and leaking stale buffer to a reused sessionid. For confetty, treat starting a shell session more like starting a console session. If an attempt to resize a dead session is attempted, ignore failures.
This commit is contained in:
parent
35e3ca1f1f
commit
f11473c736
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python2
|
||||
#!/usr/bin/python3
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
# Copyright 2014 IBM Corporation
|
||||
@ -654,13 +654,17 @@ def quitconfetty(code=0, fullexit=False, fixterm=True):
|
||||
def get_session_node(shellargs):
|
||||
# straight to node console
|
||||
if len(shellargs) == 1 and ' ' not in shellargs[0]:
|
||||
return shellargs[0]
|
||||
targ = "/nodes/%s/console/session" % shellargs[0]
|
||||
return targ, shellargs[0]
|
||||
if len(shellargs) == 2 and shellargs[0] == 'start':
|
||||
args = [s for s in shellargs[1].split('/') if s]
|
||||
if len(args) == 4 and args[0] == 'nodes' and args[2] == 'console' and \
|
||||
args[3] == 'session':
|
||||
return args[1]
|
||||
return None
|
||||
return shellargs[1], args[1]
|
||||
if len(args) == 5 and args[0] == 'nodes' and args[2] == 'shell' and \
|
||||
args[3] == 'sessions':
|
||||
return shellargs[1], args[1]
|
||||
return None, None
|
||||
|
||||
|
||||
def run_inline_command(path, arg, completion, **kwargs):
|
||||
@ -917,10 +921,10 @@ def main():
|
||||
doexit = False
|
||||
inconsole = False
|
||||
pendingcommand = ""
|
||||
session_node = get_session_node(shellargs)
|
||||
targ, session_node = get_session_node(shellargs)
|
||||
if session_node is not None:
|
||||
consoleonly = True
|
||||
do_command("start /nodes/%s/console/session" % session_node, netserver)
|
||||
do_command("start %s" % targ, netserver)
|
||||
doexit = True
|
||||
elif shellargs:
|
||||
do_command(shellargs, netserver)
|
||||
|
@ -93,7 +93,10 @@ class SshShell(conapi.Console):
|
||||
self.height = height
|
||||
if not self.connected:
|
||||
return
|
||||
self.shell.resize_pty(width=width, height=height)
|
||||
try:
|
||||
self.shell.resize_pty(width=width, height=height)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def recvdata(self):
|
||||
while self.connected:
|
||||
@ -254,6 +257,7 @@ class SshShell(conapi.Console):
|
||||
self.shell.sendall(data)
|
||||
|
||||
def close(self):
|
||||
self.connected = False
|
||||
if self.ssh is not None:
|
||||
self.ssh.close()
|
||||
self.datacallback = None
|
||||
|
@ -73,6 +73,7 @@ class _ShellHandler(consoleserver.ConsoleHandler):
|
||||
self._send_rcpts({'connectstate': self.connectstate})
|
||||
for session in list(self.livesessions):
|
||||
session.destroy()
|
||||
self.feedbuffer('\x1bc')
|
||||
|
||||
|
||||
|
||||
@ -136,9 +137,14 @@ class ShellSession(consoleserver.ConsoleSession):
|
||||
while str(self.sessionid) in activesessions[(tenant, self.node, self.username)]:
|
||||
self.sessionid += 1
|
||||
self.sessionid = str(self.sessionid)
|
||||
if self.sessionid not in activesessions[(tenant, self.node, self.username)]:
|
||||
conshdl = activesessions[(tenant, self.node, self.username)].get(self.sessionid, None)
|
||||
if conshdl and conshdl.connectstate == 'closed':
|
||||
del activesessions[(tenant, self.node, self.username)][self.sessionid]
|
||||
conshdl = None
|
||||
if not conshdl:
|
||||
activesessions[(tenant, self.node, self.username)][self.sessionid] = _ShellHandler(self.node, self.configmanager, width=self.width, height=self.height, prefix='s_{}_{}'.format(self.username, self.sessionid))
|
||||
self.conshdl = activesessions[(self.configmanager.tenant, self.node, self.username)][self.sessionid]
|
||||
conshdl = activesessions[(self.configmanager.tenant, self.node, self.username)][self.sessionid]
|
||||
self.conshdl = conshdl
|
||||
self.conshdl.numusers += 1
|
||||
|
||||
def destroy(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user