Merge lp:~townsend/libertine/verbose-lxc-errors into lp:libertine

Proposed by Christopher Townsend
Status: Merged
Approved by: Larry Price
Approved revision: 241
Merged at revision: 244
Proposed branch: lp:~townsend/libertine/verbose-lxc-errors
Merge into: lp:libertine
Diff against target: 42 lines (+12/-0)
1 file modified
python/libertine/LxcContainer.py (+12/-0)
To merge this branch: bzr merge lp:~townsend/libertine/verbose-lxc-errors
Reviewer Review Type Date Requested Status
Larry Price Approve
Libertine CI Bot continuous-integration Approve
Review via email: mp+297111@code.launchpad.net

Commit message

Be more verbose when the LXC container won't start.

To post a comment you must log in.
Revision history for this message
Libertine CI Bot (libertine-ci-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Larry Price (larryprice) wrote :

Although the raw errors still aren't super helpful for regular users, this should do wonders for debugging.

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'python/libertine/LxcContainer.py'
--- python/libertine/LxcContainer.py 2016-05-20 14:37:56 +0000
+++ python/libertine/LxcContainer.py 2016-06-10 20:44:27 +0000
@@ -18,6 +18,8 @@
18import psutil18import psutil
19import shlex19import shlex
20import subprocess20import subprocess
21import tempfile
22
21from .Libertine import BaseContainer23from .Libertine import BaseContainer
22from . import utils24from . import utils
23from socket import *25from socket import *
@@ -82,6 +84,9 @@
82 super().__init__(container_id)84 super().__init__(container_id)
83 self.container_type = "lxc"85 self.container_type = "lxc"
84 self.container = lxc_container(container_id)86 self.container = lxc_container(container_id)
87 self.lxc_log_file = os.path.join(tempfile.mkdtemp(), 'lxc-start.log')
88 self.container.append_config_item("lxc.logfile", self.lxc_log_file)
89 self.container.append_config_item("lxc.logpriority", "3")
8590
86 def is_running(self):91 def is_running(self):
87 return self.container.running92 return self.container.running
@@ -100,8 +105,10 @@
100 def start_container(self):105 def start_container(self):
101 if not self.container.running:106 if not self.container.running:
102 if not self.container.start():107 if not self.container.start():
108 self._dump_lxc_log()
103 raise RuntimeError("Container failed to start")109 raise RuntimeError("Container failed to start")
104 if not self.container.wait("RUNNING", 10):110 if not self.container.wait("RUNNING", 10):
111 self._dump_lxc_log()
105 raise RuntimeError("Container failed to enter the RUNNING state")112 raise RuntimeError("Container failed to enter the RUNNING state")
106113
107 if not self.container.get_ips(timeout=30):114 if not self.container.get_ips(timeout=30):
@@ -298,3 +305,8 @@
298 # Receive the reply from libertine-lxc-manager (ignore it for now).305 # Receive the reply from libertine-lxc-manager (ignore it for now).
299 data = libertine_lxc_mgr_sock.recv(1024)306 data = libertine_lxc_mgr_sock.recv(1024)
300 libertine_lxc_mgr_sock.close()307 libertine_lxc_mgr_sock.close()
308
309 def _dump_lxc_log(self):
310 with open(self.lxc_log_file, 'r') as fd:
311 for line in fd:
312 print(line.lstrip())

Subscribers

People subscribed via source and target branches