mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-11 04:36:48 +00:00
fix(console): a serial console worker's failure reaches socketiod's log
- The worker told why a console did not open or closed only in the user's terminal (as users see errors: a host that cannot be reached is not named). It now also logs the full reason to socketiod's own stderr, the journal or docker logs, which socketiod hands it as a descriptor. - A refused token says the link has expired or the user may no longer open the console: a valid link for a user who lost access was told only that it had expired. - A send that takes nothing (0 bytes) waits like a busy stream instead of spinning.
This commit is contained in:
parent
060a3cc86b
commit
6744838850
4 changed files with 26 additions and 6 deletions
|
|
@ -34,6 +34,7 @@ from django.conf import settings # noqa: E402
|
|||
from console.tokens import authorize # noqa: E402
|
||||
|
||||
CONSOLECALLBACK = os.path.join(ROOT_PATH, "conf", "daemon", "consolecallback")
|
||||
LOG_FD = os.dup(2) # this daemon's stderr: a worker logs there on its fd 3
|
||||
MAX_SESSIONS = 20
|
||||
|
||||
logger = logging.getLogger("socketiod")
|
||||
|
|
@ -62,7 +63,7 @@ def connect(sid, environ, auth):
|
|||
try:
|
||||
instance, user = authorize((auth or {}).get("token"))
|
||||
except PermissionError:
|
||||
raise refused("The console link has expired: reload the page")
|
||||
raise refused("The console link has expired, or you may no longer open this console: reload the page")
|
||||
finally:
|
||||
db.close_old_connections()
|
||||
taken = None
|
||||
|
|
@ -81,7 +82,9 @@ def connect(sid, environ, auth):
|
|||
try:
|
||||
# pty.fork's master is inheritable: without this each worker would
|
||||
# hold the other sessions' consoles open
|
||||
os.closerange(3, os.sysconf("SC_OPEN_MAX"))
|
||||
os.dup2(LOG_FD, 3)
|
||||
os.closerange(4, os.sysconf("SC_OPEN_MAX"))
|
||||
os.environ["CONSOLECALLBACK_LOG_FD"] = "3"
|
||||
os.execv(sys.executable, [sys.executable, CONSOLECALLBACK, str(instance.pk), str(user.pk)])
|
||||
finally:
|
||||
os._exit(1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue