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
1=== modified file 'python/libertine/LxcContainer.py'
2--- python/libertine/LxcContainer.py 2016-05-20 14:37:56 +0000
3+++ python/libertine/LxcContainer.py 2016-06-10 20:44:27 +0000
4@@ -18,6 +18,8 @@
5 import psutil
6 import shlex
7 import subprocess
8+import tempfile
9+
10 from .Libertine import BaseContainer
11 from . import utils
12 from socket import *
13@@ -82,6 +84,9 @@
14 super().__init__(container_id)
15 self.container_type = "lxc"
16 self.container = lxc_container(container_id)
17+ self.lxc_log_file = os.path.join(tempfile.mkdtemp(), 'lxc-start.log')
18+ self.container.append_config_item("lxc.logfile", self.lxc_log_file)
19+ self.container.append_config_item("lxc.logpriority", "3")
20
21 def is_running(self):
22 return self.container.running
23@@ -100,8 +105,10 @@
24 def start_container(self):
25 if not self.container.running:
26 if not self.container.start():
27+ self._dump_lxc_log()
28 raise RuntimeError("Container failed to start")
29 if not self.container.wait("RUNNING", 10):
30+ self._dump_lxc_log()
31 raise RuntimeError("Container failed to enter the RUNNING state")
32
33 if not self.container.get_ips(timeout=30):
34@@ -298,3 +305,8 @@
35 # Receive the reply from libertine-lxc-manager (ignore it for now).
36 data = libertine_lxc_mgr_sock.recv(1024)
37 libertine_lxc_mgr_sock.close()
38+
39+ def _dump_lxc_log(self):
40+ with open(self.lxc_log_file, 'r') as fd:
41+ for line in fd:
42+ print(line.lstrip())

Subscribers

People subscribed via source and target branches