Merge lp:~gandelman-a/charms/precise/quantum-gateway/headers_fix into lp:~openstack-charmers/charms/precise/quantum-gateway/python-redux

Proposed by Adam Gandelman on 2013-10-13
Status: Merged
Merged at revision: 63
Proposed branch: lp:~gandelman-a/charms/precise/quantum-gateway/headers_fix
Merge into: lp:~openstack-charmers/charms/precise/quantum-gateway/python-redux
Diff against target: 181 lines (+49/-11)
3 files modified
hooks/charmhelpers/contrib/openstack/neutron.py (+15/-6)
hooks/quantum_utils.py (+13/-2)
unit_tests/test_quantum_utils.py (+21/-3)
To merge this branch: bzr merge lp:~gandelman-a/charms/precise/quantum-gateway/headers_fix
Reviewer Review Type Date Requested Status
James Page 2013-10-13 Approve on 2013-10-14
Review via email: mp+190844@code.launchpad.net

Description of the change

Minor fixes that fix some issues I had running /w curtin installer.

* Installs the running kernel's headers package along with any DKMS package.

* Ensures the openvswitch-switch service is running prior to doing any OVS configuration. This was failing to start for reasons unrelated to the charm, but rather than the hook error'ing it just spins indefinitely waiting for a socket connection. At least try to start the service and catch any errors there before attempting config, to produce a noticeable hook error.

To post a comment you must log in.
James Page (james-page) wrote :

I think this generally looks OK; I have a concern as to why you are getting a running system without the associated kernel-headers; I've never hit this to-date so this might be covering up an bug in curtin.

I guess its also possible that the running kernels headers are no longer in the -updates pocket; but that is unlikely.

This reminds me that we need to update the force-restart helper for ovs to deal with the version in Saucy and Havana CA to use the new upstart configuration.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/charmhelpers/contrib/openstack/neutron.py'
2--- hooks/charmhelpers/contrib/openstack/neutron.py 2013-09-25 16:37:11 +0000
3+++ hooks/charmhelpers/contrib/openstack/neutron.py 2013-10-13 22:56:13 +0000
4@@ -1,5 +1,7 @@
5 # Various utilies for dealing with Neutron and the renaming from Quantum.
6
7+from subprocess import check_output
8+
9 from charmhelpers.core.hookenv import (
10 config,
11 log,
12@@ -9,6 +11,13 @@
13 from charmhelpers.contrib.openstack.utils import os_release
14
15
16+def headers_package():
17+ """Ensures correct linux-headers for running kernel are installed,
18+ for building DKMS package"""
19+ kver = check_output(['uname', '-r']).strip()
20+ return 'linux-headers-%s' % kver
21+
22+
23 # legacy
24 def quantum_plugins():
25 from charmhelpers.contrib.openstack import context
26@@ -23,15 +32,15 @@
27 database=config('neutron-database'),
28 relation_prefix='neutron')],
29 'services': ['quantum-plugin-openvswitch-agent'],
30- 'packages': ['quantum-plugin-openvswitch-agent',
31- 'openvswitch-datapath-dkms'],
32+ 'packages': [['openvswitch-datapath-dkms', headers_package()],
33+ ['quantum-plugin-openvswitch-agent']],
34 },
35 'nvp': {
36 'config': '/etc/quantum/plugins/nicira/nvp.ini',
37 'driver': 'quantum.plugins.nicira.nicira_nvp_plugin.'
38 'QuantumPlugin.NvpPluginV2',
39 'services': [],
40- 'packages': ['quantum-plugin-nicira'],
41+ 'packages': [],
42 }
43 }
44
45@@ -49,15 +58,15 @@
46 database=config('neutron-database'),
47 relation_prefix='neutron')],
48 'services': ['neutron-plugin-openvswitch-agent'],
49- 'packages': ['neutron-plugin-openvswitch-agent',
50- 'openvswitch-datapath-dkms'],
51+ 'packages': [['openvswitch-datapath-dkms', headers_package()],
52+ ['quantum-plugin-openvswitch-agent']],
53 },
54 'nvp': {
55 'config': '/etc/neutron/plugins/nicira/nvp.ini',
56 'driver': 'neutron.plugins.nicira.nicira_nvp_plugin.'
57 'NeutronPlugin.NvpPluginV2',
58 'services': [],
59- 'packages': ['neutron-plugin-nicira'],
60+ 'packages': [],
61 }
62 }
63
64
65=== modified file 'hooks/quantum_utils.py'
66--- hooks/quantum_utils.py 2013-09-04 11:56:18 +0000
67+++ hooks/quantum_utils.py 2013-10-13 22:56:13 +0000
68@@ -1,3 +1,4 @@
69+from charmhelpers.core.host import service_running
70 from charmhelpers.core.hookenv import (
71 log,
72 config,
73@@ -8,15 +9,18 @@
74 )
75 from charmhelpers.contrib.network.ovs import (
76 add_bridge,
77- add_bridge_port
78+ add_bridge_port,
79+ full_restart,
80 )
81 from charmhelpers.contrib.openstack.utils import (
82 configure_installation_source,
83 get_os_codename_install_source,
84 get_os_codename_package
85 )
86+
87 import charmhelpers.contrib.openstack.context as context
88 import charmhelpers.contrib.openstack.templating as templating
89+from charmhelpers.contrib.openstack.neutron import headers_package
90 from quantum_contexts import (
91 CORE_PLUGIN, OVS, NVP,
92 NEUTRON, QUANTUM,
93@@ -97,10 +101,15 @@
94 def get_early_packages():
95 '''Return a list of package for pre-install based on configured plugin'''
96 if config('plugin') in EARLY_PACKAGES:
97- return EARLY_PACKAGES[config('plugin')]
98+ pkgs = EARLY_PACKAGES[config('plugin')]
99 else:
100 return []
101
102+ # ensure headers are installed build any required dkms packages
103+ if [p for p in pkgs if 'dkms' in p]:
104+ return pkgs + [headers_package()]
105+ return pkgs
106+
107
108 def get_packages():
109 '''Return a list of packages for install based on the configured plugin'''
110@@ -384,6 +393,8 @@
111
112
113 def configure_ovs():
114+ if not service_running('openvswitch-switch'):
115+ full_restart()
116 if config('plugin') == OVS:
117 add_bridge(INT_BRIDGE)
118 add_bridge(EXT_BRIDGE)
119
120=== modified file 'unit_tests/test_quantum_utils.py'
121--- unit_tests/test_quantum_utils.py 2013-09-04 10:57:52 +0000
122+++ unit_tests/test_quantum_utils.py 2013-10-13 22:56:13 +0000
123@@ -1,6 +1,9 @@
124 from mock import MagicMock, call
125+
126 import charmhelpers.contrib.openstack.templating as templating
127+
128 templating.OSConfigRenderer = MagicMock()
129+
130 import quantum_utils
131
132 from test_utils import (
133@@ -19,7 +22,10 @@
134 'log',
135 'add_bridge',
136 'add_bridge_port',
137- 'networking_name'
138+ 'networking_name',
139+ 'headers_package',
140+ 'full_restart',
141+ 'service_running',
142 ]
143
144
145@@ -27,6 +33,7 @@
146 def setUp(self):
147 super(TestQuantumUtils, self).setUp(quantum_utils, TO_PATCH)
148 self.networking_name.return_value = 'neutron'
149+ self.headers_package.return_value = 'linux-headers-2.6.18'
150
151 def tearDown(self):
152 # Reset cached cache
153@@ -44,8 +51,9 @@
154
155 def test_get_early_packages_ovs(self):
156 self.config.return_value = 'ovs'
157- self.assertEquals(quantum_utils.get_early_packages(),
158- ['openvswitch-datapath-dkms'])
159+ self.assertEquals(
160+ quantum_utils.get_early_packages(),
161+ ['openvswitch-datapath-dkms', 'linux-headers-2.6.18'])
162
163 def test_get_early_packages_nvp(self):
164 self.config.return_value = 'nvp'
165@@ -56,6 +64,16 @@
166 self.config.return_value = 'ovs'
167 self.assertNotEqual(quantum_utils.get_packages(), [])
168
169+ def test_configure_ovs_starts_service_if_required(self):
170+ self.service_running.return_value = False
171+ quantum_utils.configure_ovs()
172+ self.assertTrue(self.full_restart.called)
173+
174+ def test_configure_ovs_doesnt_restart_service(self):
175+ self.service_running.return_value = True
176+ quantum_utils.configure_ovs()
177+ self.assertFalse(self.full_restart.called)
178+
179 def test_configure_ovs_ovs_ext_port(self):
180 self.config.side_effect = self.test_config.get
181 self.test_config.set('plugin', 'ovs')

Subscribers

People subscribed via source and target branches