mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-08 11:16:47 +00:00
fix(console): a serial console whose VM was deleted meanwhile says so
consolecallback read the VM's record with .get(): one deleted between socketiod's accept and the worker's start ended with a Python traceback in the user's terminal, which is the worker's stderr. It now says the VM is no longer in the panel.
This commit is contained in:
parent
c8fb778d08
commit
51aa712802
2 changed files with 11 additions and 1 deletions
|
|
@ -115,7 +115,10 @@ def main():
|
|||
if os.environ.get("CONSOLECALLBACK_LOG_FD"):
|
||||
log.addHandler(logging.StreamHandler(os.fdopen(int(os.environ["CONSOLECALLBACK_LOG_FD"]), "w", buffering=1)))
|
||||
log.propagate = False
|
||||
instance = Instance.objects.select_related("compute").get(pk=int(sys.argv[1]))
|
||||
instance = Instance.objects.select_related("compute").filter(pk=int(sys.argv[1])).first()
|
||||
if instance is None: # deleted since socketiod accepted the token
|
||||
say("The VM is no longer in the panel")
|
||||
sys.exit(1)
|
||||
user_id = int(sys.argv[2])
|
||||
c = instance.compute
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -106,3 +106,10 @@ class AccessTests(DjangoTestCase):
|
|||
ownership.delete()
|
||||
self.assertFalse(cb.may_still_open(owner.pk, vm))
|
||||
self.assertFalse(cb.may_still_open(999999, vm))
|
||||
|
||||
def test_a_vm_deleted_since_the_connect_is_told_not_a_traceback(self):
|
||||
cb = load()
|
||||
with patch.object(cb.sys, "argv", ["consolecallback", "999999", "1"]), patch.object(cb, "say") as say, \
|
||||
self.assertRaises(SystemExit):
|
||||
cb.main()
|
||||
say.assert_called_once_with("The VM is no longer in the panel")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue