Merge ~bjornt/maas:bug-2053033-failed-login-virsh into maas:master

Proposed by Björn Tillenius
Status: Merged
Approved by: Björn Tillenius
Approved revision: 38785a9d631fd9d8d71101f8614717d395491207
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~bjornt/maas:bug-2053033-failed-login-virsh
Merge into: maas:master
Diff against target: 49 lines (+25/-1)
2 files modified
src/provisioningserver/drivers/pod/tests/test_virsh.py (+23/-0)
src/provisioningserver/drivers/pod/virsh.py (+2/-1)
Reviewer Review Type Date Requested Status
MAAS Lander Approve
Adam Collard (community) Approve
Review via email: mp+460490@code.launchpad.net

Commit message

Bug #2053033: Creating MAAS Virsh VM does not work (libvirt: error)

For some reason virsh prints out an error about executing
pkttyagent. This happens only on some machines, and we don't know why.

But the error seems harmless. This patch ignores the error and
lets the connection succeed.

To post a comment you must log in.
Revision history for this message
Adam Collard (adam-collard) wrote :

Nice find, +1

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b bug-2053033-failed-login-virsh lp:~bjornt/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: 38785a9d631fd9d8d71101f8614717d395491207

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/src/provisioningserver/drivers/pod/tests/test_virsh.py b/src/provisioningserver/drivers/pod/tests/test_virsh.py
index 89e5f6d..479804f 100644
--- a/src/provisioningserver/drivers/pod/tests/test_virsh.py
+++ b/src/provisioningserver/drivers/pod/tests/test_virsh.py
@@ -572,7 +572,30 @@ class TestVirshSSH(MAASTestCase):
572 self.assertFalse(conn.login(poweraddr=factory.make_name("poweraddr")))572 self.assertFalse(conn.login(poweraddr=factory.make_name("poweraddr")))
573 mock_close.assert_called_once_with()573 mock_close.assert_called_once_with()
574574
575 def test_pkttyagent_permission_denied(self):
576 # Sometimes pkttyagent can't be executed in the snap. The connection
577 # itself still works, though.
578 # See https://bugs.launchpad.net/maas/+bug/2053033
579 virsh_outputs = [
580 "libvirt: error : cannot execute binary /usr/bin/pkttyagent: Permission denied",
581 "Welcome to virsh, the virtualization interactive terminal.",
582 "",
583 "Type: 'help' for help with commands",
584 " 'quit' to quit",
585 "",
586 "virsh # ",
587 ]
588 conn = self.configure_virshssh_pexpect(virsh_outputs)
589 self.assertTrue(conn.login(poweraddr=factory.make_name("poweraddr")))
590
575 def test_login_invalid(self):591 def test_login_invalid(self):
592 virsh_outputs = ["Permission denied, please try again."]
593 conn = self.configure_virshssh_pexpect(virsh_outputs)
594 mock_close = self.patch(conn, "close")
595 self.assertFalse(conn.login(poweraddr=factory.make_name("poweraddr")))
596 mock_close.assert_called_once_with()
597
598 def test_unknown(self):
576 virsh_outputs = [factory.make_string()]599 virsh_outputs = [factory.make_string()]
577 conn = self.configure_virshssh_pexpect(virsh_outputs)600 conn = self.configure_virshssh_pexpect(virsh_outputs)
578 mock_close = self.patch(conn, "close")601 mock_close = self.patch(conn, "close")
diff --git a/src/provisioningserver/drivers/pod/virsh.py b/src/provisioningserver/drivers/pod/virsh.py
index fb2bff3..f357205 100644
--- a/src/provisioningserver/drivers/pod/virsh.py
+++ b/src/provisioningserver/drivers/pod/virsh.py
@@ -286,7 +286,8 @@ class VirshSSH(pexpect.spawn):
286 PROMPT = r"virsh \#"286 PROMPT = r"virsh \#"
287 PROMPT_SSHKEY = "(?i)are you sure you want to continue connecting"287 PROMPT_SSHKEY = "(?i)are you sure you want to continue connecting"
288 PROMPT_PASSWORD = "(?i)(?:password)|(?:passphrase for key)"288 PROMPT_PASSWORD = "(?i)(?:password)|(?:passphrase for key)"
289 PROMPT_DENIED = "(?i)permission denied"289 # Credential problems
290 PROMPT_DENIED = "(?i)permission denied, please try again"
290 PROMPT_CLOSED = "(?i)connection closed by remote host"291 PROMPT_CLOSED = "(?i)connection closed by remote host"
291292
292 PROMPTS = [293 PROMPTS = [

Subscribers

People subscribed via source and target branches