Merge lp:~jameinel/lpsetup/missing_lxc_1045728 into lp:lpsetup

Proposed by John A Meinel on 2012-09-04
Status: Merged
Merged at revision: 81
Proposed branch: lp:~jameinel/lpsetup/missing_lxc_1045728
Merge into: lp:lpsetup
Diff against target: 57 lines (+32/-2)
2 files modified
lplxcip/lxcip.py (+14/-2)
lplxcip/tests/test_lxcip.py (+18/-0)
To merge this branch: bzr merge lp:~jameinel/lpsetup/missing_lxc_1045728
Reviewer Review Type Date Requested Status
John A Meinel (community) Approve on 2012-09-07
j.c.sackett (community) 2012-09-04 Approve on 2012-09-06
Review via email: mp+122663@code.launchpad.net

Commit Message

Probe for lxc.so.0 in multiple locations because it exists in a different spot on Precise vs Quantal.

Description of the Change

This is meant to address bug #1045728. It looks like 'lxc.so' has moved between Ubuntu versions. So we need to probe for it in multiple locations.

The fix is pretty straightforward, most of the churn from the patch is to make it testable so we understand *why* we try multiple locations, and avoid regressing in the future. (Also allows us to rip out some of the code when P becomes obsolete many years from now.)

To post a comment you must log in.
j.c.sackett (jcsackett) wrote :

This looks ok to land. Thanks, John.

review: Approve
Launchpad QA Bot (lpqabot) wrote :

The attempt to merge lp:~jameinel/lpsetup/missing_lxc_1045728 into lp:lpsetup failed. Below is the output from the failed tests.

./lplxcip/tests/test_lxcip.py
      76: E301 expected 1 blank line, found 0
./lplxcip/lxcip.py
     186: local variable 'e' is assigned to but never used

+ set -o errexit
++ grep -v distribute_setup.py
++ find . -name build -prune -o -name '*.py'
+ pyfiles='./setup.py
./lplxcip/tests/utils.py
./lplxcip/tests/__init__.py
./lplxcip/tests/test_lxcip.py
./lplxcip/tests/test_helpers.py
./lplxcip/tests/test_utils.py
./lplxcip/lxcip.py
./lpsetup/utils.py
./lpsetup/__init__.py
./lpsetup/handlers.py
./lpsetup/tests/utils.py
./lpsetup/tests/__init__.py
./lpsetup/tests/test_argparser.py
./lpsetup/tests/test_cli.py
./lpsetup/tests/test_handlers.py
./lpsetup/tests/subcommands/__init__.py
./lpsetup/tests/subcommands/test_version.py
./lpsetup/tests/subcommands/test_initrepo.py
./lpsetup/tests/subcommands/test_init_target.py
./lpsetup/tests/subcommands/test_smoke.py
./lpsetup/tests/integration/common.py
./lpsetup/tests/integration/test_install_lxc.py
./lpsetup/tests/integration/test_init_target.py
./lpsetup/tests/test_utils.py
./lpsetup/subcommands/__init__.py
./lpsetup/subcommands/install_lxc.py
./lpsetup/subcommands/initlxc.py
./lpsetup/subcommands/init_target.py
./lpsetup/subcommands/update.py
./lpsetup/subcommands/initrepo.py
./lpsetup/subcommands/version.py
./lpsetup/exceptions.py
./lpsetup/argparser.py
./lpsetup/settings.py
./lpsetup/cli.py'
+ pocketlint ./setup.py ./lplxcip/tests/utils.py ./lplxcip/tests/__init__.py ./lplxcip/tests/test_lxcip.py ./lplxcip/tests/test_helpers.py ./lplxcip/tests/test_utils.py ./lplxcip/lxcip.py ./lpsetup/utils.py ./lpsetup/__init__.py ./lpsetup/handlers.py ./lpsetup/tests/utils.py ./lpsetup/tests/__init__.py ./lpsetup/tests/test_argparser.py ./lpsetup/tests/test_cli.py ./lpsetup/tests/test_handlers.py ./lpsetup/tests/subcommands/__init__.py ./lpsetup/tests/subcommands/test_version.py ./lpsetup/tests/subcommands/test_initrepo.py ./lpsetup/tests/subcommands/test_init_target.py ./lpsetup/tests/subcommands/test_smoke.py ./lpsetup/tests/integration/common.py ./lpsetup/tests/integration/test_install_lxc.py ./lpsetup/tests/integration/test_init_target.py ./lpsetup/tests/test_utils.py ./lpsetup/subcommands/__init__.py ./lpsetup/subcommands/install_lxc.py ./lpsetup/subcommands/initlxc.py ./lpsetup/subcommands/init_target.py ./lpsetup/subcommands/update.py ./lpsetup/subcommands/initrepo.py ./lpsetup/subcommands/version.py ./lpsetup/exceptions.py ./lpsetup/argparser.py ./lpsetup/settings.py ./lpsetup/cli.py

Launchpad QA Bot (lpqabot) wrote :

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

John A Meinel (jameinel) wrote :

So... QA Bot, you rejected the submission because it had some lint, I fixed the lint, and now you say I need more review. I reject your hypothesis on trivial revisions, and submit my own fix yet again. :)

review: Approve
Launchpad QA Bot (lpqabot) wrote :
Download full text (7.1 KiB)

The attempt to merge lp:~jameinel/lpsetup/missing_lxc_1045728 into lp:lpsetup failed. Below is the output from the failed tests.

 * Reloading AppArmor profiles
   ...done.
WARNING: this command will destroy the 'lpsetup-testing-lxc' environment (type: local).
This includes all machines, services, data, and other resources. Continue [y/N]**********************************************************************
* Checking test environment. *
**********************************************************************
**********************************************************************
* Setting up the test environment for LXC container. *
**********************************************************************
----------------------------------------------------------------------
check_call:
juju bootstrap -e lpsetup-testing-lxc
----------------------------------------------------------------------
**********************************************************************
None
**********************************************************************
**********************************************************************
* Cleaning up. *
**********************************************************************

**********************************************************************
* Run time: 0:00:22.655719 *
**********************************************************************

+ set -o errexit
++ grep -v distribute_setup.py
++ find . -name build -prune -o -name '*.py'
+ pyfiles='./setup.py
./lplxcip/tests/utils.py
./lplxcip/tests/__init__.py
./lplxcip/tests/test_lxcip.py
./lplxcip/tests/test_helpers.py
./lplxcip/tests/test_utils.py
./lplxcip/lxcip.py
./lpsetup/utils.py
./lpsetup/__init__.py
./lpsetup/handlers.py
./lpsetup/tests/utils.py
./lpsetup/tests/__init__.py
./lpsetup/tests/test_argparser.py
./lpsetup/tests/test_cli.py
./lpsetup/tests/test_handlers.py
./lpsetup/tests/subcommands/__init__.py
./lpsetup/tests/subcommands/test_version.py
./lpsetup/tests/subcommands/test_initrepo.py
./lpsetup/tests/subcommands/test_init_target.py
./lpsetup/tests/subcommands/test_smoke.py
./lpsetup/tests/integration/common.py
./lpsetup/tests/integration/test_install_lxc.py
./lpsetup/tests/integration/test_init_target.py
./lpsetup/tests/test_utils.py
./lpsetup/subcommands/__init__.py
./lpsetup/subcommands/install_lxc.py
./lpsetup/subcommands/initlxc.py
./lpsetup/subcommands/init_target.py
./lpsetup/subcommands/update.py
./lpsetup/subcommands/initrepo.py
./lpsetup/subcommands/version.py
./lpsetup/exceptions.py
./lpsetup/argparser.py
./lpsetup/settings.py
./lpsetup/cli.py'
+ pocketlint ./setup.py ./lplxcip/tests/utils.py ./lplxcip/tests/__init__.py ./lplxcip/tests/test_lxcip.py ./lplxcip/tests/test_helpers.py ./lplxcip/tests/test_utils.py ./lplxcip/lxcip.py ./lpsetup/utils.py ./lpsetup/__init__.py ./lpsetup/handlers.py ./lpsetup/tests/utils.py ./lpsetup/tests/__init__.py ./lpsetup/tests/test_argparser.py ./lpsetup/tests/test_cli.py ./lpsetup/tests/test_handlers.py ./lpsetup/tests/subcommands/__init__.py ./lpsetup/tests/subcommands/...

Read more...

Launchpad QA Bot (lpqabot) wrote :
Download full text (7.0 KiB)

The attempt to merge lp:~jameinel/lpsetup/missing_lxc_1045728 into lp:lpsetup failed. Below is the output from the failed tests.

lxc.aa_profile = lxc-container-with-nesting
WARNING: this command will destroy the 'lpsetup-testing-lxc' environment (type: local).
This includes all machines, services, data, and other resources. Continue [y/N]**********************************************************************
* Checking test environment. *
**********************************************************************
**********************************************************************
* Setting up the test environment for LXC container. *
**********************************************************************
----------------------------------------------------------------------
check_call:
juju bootstrap -e lpsetup-testing-lxc
----------------------------------------------------------------------
**********************************************************************
None
**********************************************************************
**********************************************************************
* Cleaning up. *
**********************************************************************

**********************************************************************
* Run time: 0:00:23.530643 *
**********************************************************************

+ set -o errexit
++ grep -v distribute_setup.py
++ find . -name build -prune -o -name '*.py'
+ pyfiles='./setup.py
./lplxcip/tests/utils.py
./lplxcip/tests/__init__.py
./lplxcip/tests/test_lxcip.py
./lplxcip/tests/test_helpers.py
./lplxcip/tests/test_utils.py
./lplxcip/lxcip.py
./lpsetup/utils.py
./lpsetup/__init__.py
./lpsetup/handlers.py
./lpsetup/tests/utils.py
./lpsetup/tests/__init__.py
./lpsetup/tests/test_argparser.py
./lpsetup/tests/test_cli.py
./lpsetup/tests/test_handlers.py
./lpsetup/tests/subcommands/__init__.py
./lpsetup/tests/subcommands/test_version.py
./lpsetup/tests/subcommands/test_initrepo.py
./lpsetup/tests/subcommands/test_init_target.py
./lpsetup/tests/subcommands/test_smoke.py
./lpsetup/tests/integration/common.py
./lpsetup/tests/integration/test_install_lxc.py
./lpsetup/tests/integration/test_init_target.py
./lpsetup/tests/test_utils.py
./lpsetup/subcommands/__init__.py
./lpsetup/subcommands/install_lxc.py
./lpsetup/subcommands/initlxc.py
./lpsetup/subcommands/init_target.py
./lpsetup/subcommands/update.py
./lpsetup/subcommands/initrepo.py
./lpsetup/subcommands/version.py
./lpsetup/exceptions.py
./lpsetup/argparser.py
./lpsetup/settings.py
./lpsetup/cli.py'
+ pocketlint ./setup.py ./lplxcip/tests/utils.py ./lplxcip/tests/__init__.py ./lplxcip/tests/test_lxcip.py ./lplxcip/tests/test_helpers.py ./lplxcip/tests/test_utils.py ./lplxcip/lxcip.py ./lpsetup/utils.py ./lpsetup/__init__.py ./lpsetup/handlers.py ./lpsetup/tests/utils.py ./lpsetup/tests/__init__.py ./lpsetup/tests/test_argparser.py ./lpsetup/tests/test_cli.py ./lpsetup/tests/test_handlers.py ./lpsetup/tests/subcommands/__init__.py ./lpsetup/tests/subcommands...

Read more...

j.c.sackett (jcsackett) wrote :

John, just noticed this was still sitting in my +activereviews; are you still trying to land this, or can we mark it as abandoned?

Colin Watson (cjwatson) wrote :

I merged this manually (with a follow-up fix for API changes in liblxc.so.1), since I have no idea where the Tarmac instance for this lives (if anywhere now) and this surprised us when preparing buildbot for xenial.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lplxcip/lxcip.py'
2--- lplxcip/lxcip.py 2012-05-09 14:20:51 +0000
3+++ lplxcip/lxcip.py 2012-09-07 06:30:30 +0000
4@@ -169,10 +169,22 @@
5
6 Raise OSError if LXC is not installed or the container is not found.
7 """
8+ return _get_pid(name)
9+
10+
11+def _get_pid(name, loader=None):
12+ """Return the pid of an LXC.
13+
14+ This is a private implementation detail, to allow for testing with a custom
15+ loader.
16+ """
17 try:
18- liblxc = _load_library('lxc/liblxc.so.0')
19+ liblxc = _load_library('lxc/liblxc.so.0', loader=loader)
20 except OSError:
21- raise _error('not_installed')
22+ try:
23+ liblxc = _load_library('liblxc.so.0', loader=loader)
24+ except OSError:
25+ raise _error('not_installed')
26 get_init_pid = _wrap(liblxc.get_init_pid, 'not_found')
27 # Redirect the system stderr in order to get rid of the error raised by
28 # the underlying C function call if the container is not found.
29
30=== modified file 'lplxcip/tests/test_lxcip.py'
31--- lplxcip/tests/test_lxcip.py 2012-05-03 11:26:37 +0000
32+++ lplxcip/tests/test_lxcip.py 2012-09-07 06:30:30 +0000
33@@ -67,6 +67,24 @@
34 name = lxc.name
35 interfaces = ['eth0']
36
37+ def test__get_pid_tries_double_locations(self):
38+ # See bug #1045728
39+ # The location of 'lxc.so' is different on Quantal than Precise, so we
40+ # make sure that the loading function checks both locations before
41+ # giving up.
42+ paths = []
43+
44+ def failing_loader(path):
45+ paths.append(path)
46+ raise OSError('not loading from path: %s' % (path,))
47+ # The OSError we get at the end should be 'not_installed'
48+ self.assertRaises(OSError,
49+ lxcip._get_pid, self.name, loader=failing_loader)
50+ # The location on Precise
51+ self.assertIn('/usr/lib/lxc/lxc.so.0', paths)
52+ # The location on Quantal
53+ self.assertIn('/usr/lib/lxc.so.0', paths)
54+
55 def test_ip_address(self):
56 # Ensure the ip address of the container is correctly retrieved.
57 pid = utils.get_pid(self.name)

Subscribers

People subscribed via source and target branches