Merge lp:~townsend/libertine/fix-missing-log into lp:libertine

Proposed by Christopher Townsend
Status: Merged
Approved by: Larry Price
Approved revision: 261
Merged at revision: 261
Proposed branch: lp:~townsend/libertine/fix-missing-log
Merge into: lp:libertine
Diff against target: 34 lines (+10/-3)
1 file modified
python/libertine/LxcContainer.py (+10/-3)
To merge this branch: bzr merge lp:~townsend/libertine/fix-missing-log
Reviewer Review Type Date Requested Status
Larry Price Approve
Libertine CI Bot continuous-integration Approve
Review via email: mp+298633@code.launchpad.net

Commit message

Check if the LXC container is defined before trying to start it.
Catch any errors when trying to open the LXC log on container start failure.

To post a comment you must log in.
Revision history for this message
Libertine CI Bot (libertine-ci-bot) wrote :

PASSED: Continuous integration, rev:261
https://jenkins.canonical.com/libertine/job/lp-libertine-ci/33/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/libertine/job/build/126
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=vivid+overlay,testname=default/88
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=default/88
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=yakkety,testname=default/88
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=vivid+overlay,testname=default/88
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=xenial+overlay,testname=default/88
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=yakkety,testname=default/88
    None: https://jenkins.canonical.com/libertine/job/lp-generic-update-mp/103/console
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-0-fetch/129
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-1-sourcepkg/release=vivid+overlay/114
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-1-sourcepkg/release=xenial+overlay/114
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-1-sourcepkg/release=yakkety/114
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=vivid+overlay/107
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=vivid+overlay/107/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=xenial+overlay/107
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=xenial+overlay/107/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=yakkety/107
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=yakkety/107/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=vivid+overlay/107
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=vivid+overlay/107/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=xenial+overlay/107
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=xenial+overlay/107/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=yakkety/107
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=yakkety/107/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/libertine/job/lp-libertine-ci/33/rebuild

review: Approve (continuous-integration)
Revision history for this message
Larry Price (larryprice) wrote :

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-06-28 20:16:55 +0000
3+++ python/libertine/LxcContainer.py 2016-06-29 12:57:00 +0000
4@@ -18,6 +18,7 @@
5 import psutil
6 import shlex
7 import subprocess
8+import sys
9 import tempfile
10
11 from .Libertine import BaseContainer
12@@ -100,6 +101,9 @@
13 return True
14
15 def start_container(self):
16+ if not self.container.defined:
17+ raise RuntimeError("Container %s is not valid" % self.container_id)
18+
19 if not self.container.running:
20 self._set_lxc_log()
21 if not self.container.start():
22@@ -305,6 +309,9 @@
23 self.container.append_config_item("lxc.logpriority", "3")
24
25 def _dump_lxc_log(self):
26- with open(self.lxc_log_file, 'r') as fd:
27- for line in fd:
28- print(line.lstrip())
29+ try:
30+ with open(self.lxc_log_file, 'r') as fd:
31+ for line in fd:
32+ print(line.lstrip())
33+ except Exception as ex:
34+ print("Could not open LXC log file: %s" % ex, file=sys.stderr)

Subscribers

People subscribed via source and target branches