mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 17:36:05 +00:00
fix(instances): a VM whose guest agent hangs no longer stops its page
The VM page read the guest's addresses with interfaceAddresses() from the agent, and the OS details with agent commands without a timeout. A connected agent that hangs (a frozen guest) kept the page from loading at all and held a worker: seen still loading after 120 s. Both now go through the 10 s guest agent command the root password and SSH key use. The addresses come from guest-network-get-interfaces, in the form the page's address code already reads; an agent that does not answer leaves the ARP address. With the agent frozen the page loads in about 10 s and the OS details answer with the agent's error (400) in 5 s, instead of a server error.
This commit is contained in:
parent
dab449bcd2
commit
80d934741f
4 changed files with 88 additions and 60 deletions
|
|
@ -183,3 +183,21 @@ class GuestAgentAccessTestCase(TestCase):
|
|||
self.proxy.set_user_password.side_effect = err
|
||||
self.assertEqual(self.post("rootpasswd", {"passwd": "S3cret-pass"}),
|
||||
["The host of this virtual machine cannot be reached right now."])
|
||||
|
||||
|
||||
class OsInfoErrorTestCase(TestCase):
|
||||
"""The VM page asks for the guest's OS details; an agent that does not
|
||||
answer in time is an error answer, not a server error."""
|
||||
|
||||
def setUp(self):
|
||||
self.client.login(request=RequestFactory().get("/"), username="admin", password="admin")
|
||||
compute = Compute.objects.create(name="osinfo-compute", hostname="192.0.2.1", type=1)
|
||||
self.instance = Instance.objects.create(compute=compute, name="osinfo-vm",
|
||||
uuid="22222222-3333-4444-5555-666666666666")
|
||||
|
||||
@patch.object(Instance, "proxy")
|
||||
def test_a_silent_agent_is_an_error_answer(self, proxy):
|
||||
proxy.osinfo.side_effect = libvirtError("guest agent didn't respond to command within '10' seconds")
|
||||
response = self.client.get(reverse("instances:osinfo", args=[self.instance.id]))
|
||||
self.assertEqual(response.status_code, 400)
|
||||
self.assertEqual(response.json(), {"error": "guest agent didn't respond to command within '10' seconds"})
|
||||
|
|
|
|||
|
|
@ -420,9 +420,10 @@ def stats(request, pk):
|
|||
|
||||
def osinfo(request, pk):
|
||||
instance = get_instance(request.user, pk)
|
||||
results = instance.proxy.osinfo()
|
||||
|
||||
return JsonResponse(results)
|
||||
try:
|
||||
return JsonResponse(instance.proxy.osinfo())
|
||||
except libvirtError as err:
|
||||
return JsonResponse({"error": error_text(request, err)}, status=400)
|
||||
|
||||
|
||||
@superuser_only
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue