Merge lp:~townsend/libertine/track-running-apps into lp:libertine

Proposed by Christopher Townsend
Status: Merged
Approved by: Larry Price
Approved revision: 313
Merged at revision: 314
Proposed branch: lp:~townsend/libertine/track-running-apps
Merge into: lp:libertine
Diff against target: 87 lines (+35/-10)
2 files modified
python/libertine/ContainersConfig.py (+11/-0)
python/libertine/Libertine.py (+24/-10)
To merge this branch: bzr merge lp:~townsend/libertine/track-running-apps
Reviewer Review Type Date Requested Status
Larry Price Approve
Libertine CI Bot continuous-integration Approve
Review via email: mp+308394@code.launchpad.net

Commit message

Add a new entry to ContainersConfig for keeping track of running processes in a container.

Description of the change

I have put a 'pid' field that is not used in this MP. However, I will add code to use it once the refactor-app-wrapper MP is merged.

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

PASSED: Continuous integration, rev:313
https://jenkins.canonical.com/libertine/job/lp-libertine-ci/163/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/libertine/job/build/399
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=vivid+overlay,testname=default/317
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=default/317
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=yakkety,testname=default/317
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=vivid+overlay,testname=default/317
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=xenial+overlay,testname=default/317
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=yakkety,testname=default/317
    None: https://jenkins.canonical.com/libertine/job/lp-generic-update-mp/304/console
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-0-fetch/401
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-1-sourcepkg/release=vivid+overlay/383
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-1-sourcepkg/release=xenial+overlay/383
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-1-sourcepkg/release=yakkety/383
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=vivid+overlay/382
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=vivid+overlay/382/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=xenial+overlay/382
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=xenial+overlay/382/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=yakkety/382
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=yakkety/382/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=vivid+overlay/382
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=vivid+overlay/382/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=xenial+overlay/382
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=xenial+overlay/382/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=yakkety/382
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=yakkety/382/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/libertine/job/lp-libertine-ci/163/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/ContainersConfig.py'
2--- python/libertine/ContainersConfig.py 2016-10-11 19:54:52 +0000
3+++ python/libertine/ContainersConfig.py 2016-10-13 15:05:19 +0000
4@@ -326,6 +326,17 @@
5 package_name)
6
7 """
8+ Operations for running apps in a Libertine container.
9+ """
10+ def add_running_app(self, container_id, app_exec_name, pid=0):
11+ app_obj = {'appExecName': app_exec_name, 'pid': pid}
12+ self._set_value_by_key(container_id, 'runningApps', app_obj)
13+
14+ def delete_running_app(self, container_id, app_exec_name):
15+ self._delete_array_object_by_key_value(container_id, 'runningApps',
16+ 'appExecName', app_exec_name)
17+
18+ """
19 Fetcher functions for various configuration information.
20 """
21 def get_container_distro(self, container_id):
22
23=== modified file 'python/libertine/Libertine.py'
24--- python/libertine/Libertine.py 2016-10-06 16:23:48 +0000
25+++ python/libertine/Libertine.py 2016-10-13 15:05:19 +0000
26@@ -655,24 +655,39 @@
27 :param app_exec_line: The exec line used to start the app in the container.
28 """
29 def __init__(self, container_id, app_exec_line):
30- signal.signal(signal.SIGTERM, self.cleanup_lsb)
31- signal.signal(signal.SIGINT, self.cleanup_lsb)
32+ signal.signal(signal.SIGTERM, self.cleanup)
33+ signal.signal(signal.SIGINT, self.cleanup)
34
35 self.container_id = container_id
36 self.app_exec_line = app_exec_line
37 self.lsb = None
38 self.pasted = None
39
40- def cleanup_lsb(self, signum, frame):
41- self.close_lsb()
42-
43- def close_lsb(self):
44+ def cleanup(self, signum, frame):
45+ self.cleanup_helpers()
46+
47+ def cleanup_helpers(self):
48+ self._remove_running_app()
49+ self._close_lsb()
50+ self._close_pasted()
51+
52+ def _close_lsb(self):
53 if self.lsb is not None:
54 self.lsb_process.terminate()
55
56 while active_children():
57 time.sleep(1)
58
59+ def _close_pasted(self):
60+ if self.pasted is not None:
61+ self.pasted.terminate()
62+
63+ def _add_running_app(self):
64+ ContainersConfig().add_running_app(self.container_id, self.app_exec_line[0])
65+
66+ def _remove_running_app(self):
67+ ContainersConfig().delete_running_app(self.container_id, self.app_exec_line[0])
68+
69 """
70 Launches the libertine session bridge. This creates a proxy socket to read to and from
71 for abstract sockets such as dbus.
72@@ -699,12 +714,11 @@
73 raise RuntimeError("Container ID %s does not exist." % self.container_id)
74
75 container = LibertineContainer(self.container_id)
76+ self._add_running_app()
77+
78 try:
79 container.launch_application(self.app_exec_line)
80 except:
81 raise
82 finally:
83- self.close_lsb()
84-
85- if self.pasted is not None:
86- self.pasted.terminate()
87+ self.cleanup_helpers()

Subscribers

People subscribed via source and target branches