Merge ~bjornt/maas:bug-2053033-3.3-hotfix into maas:branch-3.3.5-hotfix-bug-2053033

Proposed by Björn Tillenius
Status: Merged
Approved by: Björn Tillenius
Approved revision: 0ebcfb72c2af06a9cc800668002004e8737e21bf
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~bjornt/maas:bug-2053033-3.3-hotfix
Merge into: maas:branch-3.3.5-hotfix-bug-2053033
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
Björn Tillenius Approve
Review via email: mp+460509@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.

(cherry picked from commit f0005e39bcadfc366c76e713c444739179743c84)
(cherry picked from commit 9eb3ca242e3c57f1b7ab1a1b6537ee4dfffb2aa6)
(cherry picked from commit 052a895bfac55e414bf5b02e5e28122bff12a532)

To post a comment you must log in.
Revision history for this message
Björn Tillenius (bjornt) wrote :

Self-approve backport.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/provisioningserver/drivers/pod/tests/test_virsh.py b/src/provisioningserver/drivers/pod/tests/test_virsh.py
2index 629f277..4721db5 100644
3--- a/src/provisioningserver/drivers/pod/tests/test_virsh.py
4+++ b/src/provisioningserver/drivers/pod/tests/test_virsh.py
5@@ -575,7 +575,30 @@ class TestVirshSSH(MAASTestCase):
6 self.assertFalse(conn.login(poweraddr=factory.make_name("poweraddr")))
7 self.assertThat(mock_close, MockCalledOnceWith())
8
9+ def test_pkttyagent_permission_denied(self):
10+ # Sometimes pkttyagent can't be executed in the snap. The connection
11+ # itself still works, though.
12+ # See https://bugs.launchpad.net/maas/+bug/2053033
13+ virsh_outputs = [
14+ "libvirt: error : cannot execute binary /usr/bin/pkttyagent: Permission denied",
15+ "Welcome to virsh, the virtualization interactive terminal.",
16+ "",
17+ "Type: 'help' for help with commands",
18+ " 'quit' to quit",
19+ "",
20+ "virsh # ",
21+ ]
22+ conn = self.configure_virshssh_pexpect(virsh_outputs)
23+ self.assertTrue(conn.login(poweraddr=factory.make_name("poweraddr")))
24+
25 def test_login_invalid(self):
26+ virsh_outputs = ["Permission denied, please try again."]
27+ conn = self.configure_virshssh_pexpect(virsh_outputs)
28+ mock_close = self.patch(conn, "close")
29+ self.assertFalse(conn.login(poweraddr=factory.make_name("poweraddr")))
30+ mock_close.assert_called_once_with()
31+
32+ def test_unknown(self):
33 virsh_outputs = [factory.make_string()]
34 conn = self.configure_virshssh_pexpect(virsh_outputs)
35 mock_close = self.patch(conn, "close")
36diff --git a/src/provisioningserver/drivers/pod/virsh.py b/src/provisioningserver/drivers/pod/virsh.py
37index c490cbc..94529ee 100644
38--- a/src/provisioningserver/drivers/pod/virsh.py
39+++ b/src/provisioningserver/drivers/pod/virsh.py
40@@ -288,7 +288,8 @@ class VirshSSH(pexpect.spawn):
41 PROMPT = r"virsh \#"
42 PROMPT_SSHKEY = "(?i)are you sure you want to continue connecting"
43 PROMPT_PASSWORD = "(?i)(?:password)|(?:passphrase for key)"
44- PROMPT_DENIED = "(?i)permission denied"
45+ # Credential problems
46+ PROMPT_DENIED = "(?i)permission denied, please try again"
47 PROMPT_CLOSED = "(?i)connection closed by remote host"
48
49 PROMPTS = [

Subscribers

People subscribed via source and target branches