Merge lp:~gandelman-a/nova/patch_fixups into lp:~ubuntu-server-dev/nova/essex

Proposed by Adam Gandelman on 2012-03-06
Status: Merged
Merge reported by: Chuck Short
Merged at revision: not available
Proposed branch: lp:~gandelman-a/nova/patch_fixups
Merge into: lp:~ubuntu-server-dev/nova/essex
Diff against target: 478 lines (+126/-120)
3 files modified
debian/changelog (+2/-0)
debian/patches/ec2-fixes.patch (+52/-39)
debian/patches/libvirt-use-console-pipe.patch (+72/-81)
To merge this branch: bzr merge lp:~gandelman-a/nova/patch_fixups
Reviewer Review Type Date Requested Status
Ubuntu Server Developers 2012-03-06 Pending
Review via email: mp+96050@code.launchpad.net

Description of the Change

Refreshes the ec2 + libvirt console patches. This is the version of the patch that we carried in Ubuntu on our last upload, rebased against master, with extra stuff added.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2012-03-05 16:28:43 +0000
3+++ debian/changelog 2012-03-06 03:57:20 +0000
4@@ -7,6 +7,8 @@
5 [ Adam Gandleman ]
6 * debian/patches/service_account_placeholder.patch: Add examples
7 to highlight new keystone service auth interface.
8+ * debian/patches/{ec2-fixes.patch, libvirt-console-pipe.patch}: Fix and
9+ refresh. Add dep3 headers from original git commits.
10
11 -- Chuck Short <zulcss@ubuntu.com> Mon, 05 Mar 2012 11:06:13 -0500
12
13
14=== modified file 'debian/patches/ec2-fixes.patch'
15--- debian/patches/ec2-fixes.patch 2012-03-02 16:04:08 +0000
16+++ debian/patches/ec2-fixes.patch 2012-03-06 03:57:20 +0000
17@@ -1,17 +1,34 @@
18-diff -Naurp nova-2012.1.orig/nova/api/ec2/cloud.py nova-2012.1/nova/api/ec2/cloud.py
19---- nova-2012.1.orig/nova/api/ec2/cloud.py 2012-03-01 12:45:52.000000000 -0500
20-+++ nova-2012.1/nova/api/ec2/cloud.py 2012-03-02 10:57:47.414758539 -0500
21-@@ -1424,6 +1424,9 @@ class CloudController(object):
22+From: Vishvananda Ishaya <vishvananda@gmail.com>
23+Date: Thu, 1 Mar 2012 16:52:07 -0800
24+Subject: [PATCH] Fixes for ec2 images
25+
26+ * Fixes s3 image service to convert back to uuids on update
27+ * Adds exception for attempt to update an unowned image
28+ * Adds error messages to ec2 for failure cases
29+ * Adds tests to verify changes
30+ * Fixes bug 942865
31+
32+Change-Id: I35331c635756f10c02b30dd43ab3fe0ad98bc28c
33+
34+Origin: https://review.openstack.org/#change,4788
35+Bug: https://code.launchpad.net/bugs/942865
36+Last-Updated: 2012-03-05
37+
38+Index: nova/nova/api/ec2/cloud.py
39+===================================================================
40+--- nova.orig/nova/api/ec2/cloud.py 2012-03-05 14:27:39.000000000 -0800
41++++ nova/nova/api/ec2/cloud.py 2012-03-05 14:28:45.223610255 -0800
42+@@ -1434,6 +1434,9 @@
43 def register_image(self, context, image_location=None, **kwargs):
44- if image_location is None and 'name' in kwargs:
45+ if image_location is None and kwargs.get('name'):
46 image_location = kwargs['name']
47 + if image_location is None:
48 + raise exception.EC2APIError(_('imageLocation is required'))
49 +
50 metadata = {'properties': {'image_location': image_location}}
51
52- if 'root_device_name' in kwargs:
53-@@ -1498,7 +1501,11 @@ class CloudController(object):
54+ if kwargs.get('name'):
55+@@ -1513,7 +1516,11 @@
56 del(image['id'])
57
58 image['is_public'] = (operation_type == 'add')
59@@ -24,10 +41,11 @@
60
61 def update_image(self, context, image_id, **kwargs):
62 internal_id = ec2utils.ec2_id_to_id(image_id)
63-diff -Naurp nova-2012.1.orig/nova/exception.py nova-2012.1/nova/exception.py
64---- nova-2012.1.orig/nova/exception.py 2012-03-01 12:45:52.000000000 -0500
65-+++ nova-2012.1/nova/exception.py 2012-03-02 10:57:47.414758539 -0500
66-@@ -199,7 +199,7 @@ class MelangeConnectionFailed(NovaExcept
67+Index: nova/nova/exception.py
68+===================================================================
69+--- nova.orig/nova/exception.py 2012-03-05 14:27:39.000000000 -0800
70++++ nova/nova/exception.py 2012-03-05 14:28:45.223610255 -0800
71+@@ -201,7 +201,7 @@
72
73 class NotAuthorized(NovaException):
74 message = _("Not authorized.")
75@@ -36,7 +54,7 @@
76
77
78 class AdminRequired(NotAuthorized):
79-@@ -210,6 +210,10 @@ class PolicyNotAuthorized(NotAuthorized)
80+@@ -212,6 +212,10 @@
81 message = _("Policy doesn't allow %(action)s to be performed.")
82
83
84@@ -47,10 +65,11 @@
85 class Invalid(NovaException):
86 message = _("Unacceptable parameters.")
87 code = 400
88-diff -Naurp nova-2012.1.orig/nova/image/glance.py nova-2012.1/nova/image/glance.py
89---- nova-2012.1.orig/nova/image/glance.py 2012-03-01 12:45:52.000000000 -0500
90-+++ nova-2012.1/nova/image/glance.py 2012-03-02 10:57:47.414758539 -0500
91-@@ -301,6 +301,9 @@ class GlanceImageService(object):
92+Index: nova/nova/image/glance.py
93+===================================================================
94+--- nova.orig/nova/image/glance.py 2012-03-05 14:27:39.000000000 -0800
95++++ nova/nova/image/glance.py 2012-03-05 14:28:45.223610255 -0800
96+@@ -301,6 +301,9 @@
97 image_meta = client.update_image(image_id, image_meta, data)
98 except glance_exception.NotFound:
99 raise exception.ImageNotFound(image_id=image_id)
100@@ -60,10 +79,11 @@
101
102 base_image_meta = self._translate_from_glance(image_meta)
103 return base_image_meta
104-diff -Naurp nova-2012.1.orig/nova/image/s3.py nova-2012.1/nova/image/s3.py
105---- nova-2012.1.orig/nova/image/s3.py 2012-03-01 12:45:52.000000000 -0500
106-+++ nova-2012.1/nova/image/s3.py 2012-03-02 10:57:47.414758539 -0500
107-@@ -105,6 +105,27 @@ class S3ImageService(object):
108+Index: nova/nova/image/s3.py
109+===================================================================
110+--- nova.orig/nova/image/s3.py 2012-03-05 14:27:39.000000000 -0800
111++++ nova/nova/image/s3.py 2012-03-05 14:28:45.223610255 -0800
112+@@ -105,6 +105,27 @@
113
114 return image_copy
115
116@@ -91,7 +111,7 @@
117 def create(self, context, metadata, data=None):
118 """Create an image.
119
120-@@ -120,6 +141,7 @@ class S3ImageService(object):
121+@@ -120,6 +141,7 @@
122
123 def update(self, context, image_id, metadata, data=None):
124 image_uuid = self.get_image_uuid(context, image_id)
125@@ -99,7 +119,7 @@
126 image = self.service.update(context, image_uuid, metadata, data)
127 return self._translate_uuid_to_id(context, image)
128
129-@@ -171,6 +193,11 @@ class S3ImageService(object):
130+@@ -171,6 +193,11 @@
131 image_type = 'machine'
132
133 try:
134@@ -111,7 +131,7 @@
135 kernel_id = manifest.find('machine_configuration/kernel_id').text
136 if kernel_id == 'true':
137 image_format = 'aki'
138-@@ -235,6 +262,7 @@ class S3ImageService(object):
139+@@ -235,6 +262,7 @@
140
141 metadata.update({'disk_format': image_format,
142 'container_format': image_format,
143@@ -119,18 +139,11 @@
144 'status': 'queued',
145 'is_public': False,
146 'properties': properties})
147-diff -Naurp nova-2012.1.orig/nova/tests/api/ec2/test_cloud.py nova-2012.1/nova/tests/api/ec2/test_cloud.py
148---- nova-2012.1.orig/nova/tests/api/ec2/test_cloud.py 2012-03-01 12:45:52.000000000 -0500
149-+++ nova-2012.1/nova/tests/api/ec2/test_cloud.py 2012-03-02 10:57:47.418758240 -0500
150-@@ -33,6 +33,7 @@ from nova import db
151- from nova import exception
152- from nova import flags
153- from nova.image import fake
154-+from nova.image import s3
155- from nova import log as logging
156- from nova import rpc
157- from nova import test
158-@@ -1154,7 +1155,7 @@ class CloudTestCase(test.TestCase):
159+Index: nova/nova/tests/api/ec2/test_cloud.py
160+===================================================================
161+--- nova.orig/nova/tests/api/ec2/test_cloud.py 2012-03-05 14:27:39.287612677 -0800
162++++ nova/nova/tests/api/ec2/test_cloud.py 2012-03-05 14:28:45.223610255 -0800
163+@@ -1156,7 +1156,7 @@
164 modify_image_attribute = self.cloud.modify_image_attribute
165
166 fake_metadata = {
167@@ -139,7 +152,7 @@
168 'container_format': 'ami',
169 'properties': {
170 'kernel_id': 'cedef40a-ed67-4d10-800e-17455edce175',
171-@@ -1163,11 +1164,17 @@ class CloudTestCase(test.TestCase):
172+@@ -1165,11 +1165,17 @@
173 'is_public': False}
174
175 def fake_show(meh, context, id):
176@@ -160,7 +173,7 @@
177
178 self.stubs.Set(fake._FakeImageService, 'show', fake_show)
179 self.stubs.Set(fake._FakeImageService, 'show_by_name', fake_show)
180-@@ -1175,7 +1182,31 @@ class CloudTestCase(test.TestCase):
181+@@ -1177,7 +1183,31 @@
182 result = modify_image_attribute(self.context, 'ami-00000001',
183 'launchPermission', 'add',
184 user_group=['all'])
185@@ -191,5 +204,5 @@
186 + self.assertRaises(exception.EC2APIError, register_image, self.context,
187 + image_location=None)
188
189- def test_deregister_image(self):
190- deregister_image = self.cloud.deregister_image
191+ def test_register_image_name(self):
192+ register_image = self.cloud.register_image
193
194=== modified file 'debian/patches/libvirt-use-console-pipe.patch'
195--- debian/patches/libvirt-use-console-pipe.patch 2012-03-05 16:28:43 +0000
196+++ debian/patches/libvirt-use-console-pipe.patch 2012-03-06 03:57:20 +0000
197@@ -1,23 +1,20 @@
198-From 951737bf24236dd81e635744687852f7b5fa3825 Mon Sep 17 00:00:00 2001
199-From: Chuck Short <chuck.short@canonical.com>
200-Date: Mon, 5 Mar 2012 11:23:23 -0500
201-Subject: [PATCH] Updated ringbuffer patch
202-
203-Signed-off-by: Chuck Short <chuck.short@canonical.com>
204----
205- Authors | 1 +
206- nova/tests/test_libvirt.py | 52 +++++++++++++++-
207- nova/tests/test_utils.py | 53 ++++++++++++++++
208- nova/utils.py | 131 +++++++++++++++++++++++++++++++++++++++
209- nova/virt/libvirt.xml.template | 4 +-
210- nova/virt/libvirt/connection.py | 112 ++++++++++++++++++++++++++++++---
211- 6 files changed, 340 insertions(+), 13 deletions(-)
212-
213-diff --git a/Authors b/Authors
214-index dc83d82..bcaf2b6 100644
215---- a/Authors
216-+++ b/Authors
217-@@ -151,6 +151,7 @@ Rick Clark <rick@openstack.org>
218+From: Robie Basak <robie.basak@canonical.com>
219+Date: Wed, 28 Sep 2011 14:45:30 +0100
220+Subject: [PATCH] Move console.log to a ringbuffer
221+
222+Prevent a DoS by storing console output in a ringbuffer on the host,
223+instead of allowing it to grow indefinitely. Fixes bug 832507.
224+
225+
226+Origin: https://review.openstack.org/#change,706
227+Bug: https://code.launchpad.net/bugs/832507
228+Last-Update: 2012-03-05
229+
230+Index: nova/Authors
231+===================================================================
232+--- nova.orig/Authors 2012-03-05 14:27:39.000000000 -0800
233++++ nova/Authors 2012-03-05 14:27:46.683612405 -0800
234+@@ -151,6 +151,7 @@
235 Rick Harris <rconradharris@gmail.com>
236 Rob Kost <kost@isi.edu>
237 Robert Esker <esker@netapp.com>
238@@ -25,11 +22,11 @@
239 Russell Bryant <rbryant@redhat.com>
240 Russell Sim <russell.sim@gmail.com>
241 Ryan Lane <rlane@wikimedia.org>
242-diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py
243-index a48b02f..052fa66 100644
244---- a/nova/tests/test_libvirt.py
245-+++ b/nova/tests/test_libvirt.py
246-@@ -870,7 +870,7 @@ class LibvirtConnTestCase(test.TestCase):
247+Index: nova/nova/tests/test_libvirt.py
248+===================================================================
249+--- nova.orig/nova/tests/test_libvirt.py 2012-03-05 14:27:39.000000000 -0800
250++++ nova/nova/tests/test_libvirt.py 2012-03-05 14:27:46.683612405 -0800
251+@@ -870,7 +870,7 @@
252 (lambda t: _ipv4_like(t.findall(parameter)[1].get('value'),
253 '192.168.*.1'), True),
254 (lambda t: t.find('./devices/serial/source').get(
255@@ -38,7 +35,7 @@
256 (lambda t: t.find('./memory').text, '2097152')]
257 if rescue:
258 common_checks += [
259-@@ -2304,3 +2304,53 @@ class LibvirtConnectionTestCase(test.TestCase):
260+@@ -2302,3 +2302,53 @@
261
262 ref = self.libvirtconnection.finish_revert_migration(ins_ref, None)
263 self.assertTrue(isinstance(ref, eventlet.event.Event))
264@@ -92,10 +89,10 @@
265 + os.unlink(self.ringbuffer_path)
266 + os.unlink(self.fifo_path)
267 + os.rmdir(self.directory_path)
268-diff --git a/nova/tests/test_utils.py b/nova/tests/test_utils.py
269-index e3457dd..e357ac7 100644
270---- a/nova/tests/test_utils.py
271-+++ b/nova/tests/test_utils.py
272+Index: nova/nova/tests/test_utils.py
273+===================================================================
274+--- nova.orig/nova/tests/test_utils.py 2012-03-05 14:27:39.000000000 -0800
275++++ nova/nova/tests/test_utils.py 2012-03-05 14:27:46.683612405 -0800
276 @@ -17,6 +17,7 @@
277 import __builtin__
278 import datetime
279@@ -104,7 +101,7 @@
280 import os
281 import os.path
282 import socket
283-@@ -25,6 +26,7 @@ import tempfile
284+@@ -25,6 +26,7 @@
285
286 import iso8601
287 import mox
288@@ -112,7 +109,7 @@
289
290 import nova
291 from nova import exception
292-@@ -818,6 +820,57 @@ class Iso8601TimeTest(test.TestCase):
293+@@ -818,6 +820,57 @@
294 west = utils.parse_isotime(str)
295 normed = utils.normalize_time(west)
296 self._instaneous(normed, 2012, 2, 13, 23, 53, 07, 0)
297@@ -170,11 +167,11 @@
298
299
300 class TestLockCleanup(test.TestCase):
301-diff --git a/nova/utils.py b/nova/utils.py
302-index 0ea6ee9..d19bf7e 100644
303---- a/nova/utils.py
304-+++ b/nova/utils.py
305-@@ -33,6 +33,7 @@ import re
306+Index: nova/nova/utils.py
307+===================================================================
308+--- nova.orig/nova/utils.py 2012-03-05 14:27:39.000000000 -0800
309++++ nova/nova/utils.py 2012-03-05 14:27:46.687612406 -0800
310+@@ -33,6 +33,7 @@
311 import shlex
312 import shutil
313 import socket
314@@ -182,7 +179,7 @@
315 import struct
316 import sys
317 import tempfile
318-@@ -56,6 +57,7 @@ from nova import log as logging
319+@@ -56,6 +57,7 @@
320 from nova.openstack.common import cfg
321
322
323@@ -190,7 +187,7 @@
324 LOG = logging.getLogger(__name__)
325 ISO_TIME_FORMAT = "%Y-%m-%dT%H:%M:%S"
326 PERFECT_TIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%f"
327-@@ -1530,6 +1532,135 @@ def read_file_as_root(file_path):
328+@@ -1530,6 +1532,135 @@
329 return out
330 except exception.ProcessExecutionError:
331 raise exception.FileNotFound(file_path=file_path)
332@@ -326,26 +323,11 @@
333
334
335 @contextlib.contextmanager
336-diff --git a/nova/virt/libvirt.xml.template b/nova/virt/libvirt.xml.template
337-index 9a216e1..df28081 100644
338---- a/nova/virt/libvirt.xml.template
339-+++ b/nova/virt/libvirt.xml.template
340-@@ -160,8 +160,8 @@
341-
342- #end for
343- <!-- The order is significant here. File must be defined first -->
344-- <serial type="file">
345-- <source path='${basepath}/console.log'/>
346-+ <serial type="pipe">
347-+ <source path='${basepath}/console.fifo'/>
348- <target port='1'/>
349- </serial>
350-
351-diff --git a/nova/virt/libvirt/connection.py b/nova/virt/libvirt/connection.py
352-index c9f4251..2074ece 100644
353---- a/nova/virt/libvirt/connection.py
354-+++ b/nova/virt/libvirt/connection.py
355-@@ -39,15 +39,19 @@ Supports KVM, LXC, QEMU, UML, and XEN.
356+Index: nova/nova/virt/libvirt/connection.py
357+===================================================================
358+--- nova.orig/nova/virt/libvirt/connection.py 2012-03-05 14:27:39.000000000 -0800
359++++ nova/nova/virt/libvirt/connection.py 2012-03-05 14:28:12.167611470 -0800
360+@@ -39,15 +39,19 @@
361
362 """
363
364@@ -365,20 +347,17 @@
365 from eventlet import greenthread
366 from xml.dom import minidom
367 from xml.etree import ElementTree
368-@@ -156,6 +160,12 @@ libvirt_opts = [
369- help='Number of seconds to wait for instance to shut down after'
370- ' soft reboot request is made. We fall back to hard reboot'
371- ' if instance does not shutdown within this window.'),
372-+ cfg.BoolOpt('libvirt_console_buffer',
373-+ default=False,
374-+ help='Enable libvirt console ringbuffer')
375+@@ -151,6 +155,9 @@
376+ help='Override the default disk prefix for the devices attached'
377+ ' to a server, which is dependent on libvirt_type. '
378+ '(valid options are: sd, xvd, uvd, vd)'),
379 + cfg.IntOpt('libvirt_console_log_size',
380 + default=65536,
381-+ help='libvirt console log ringbuffer size')
382- ]
383-
384- FLAGS = flags.FLAGS
385-@@ -189,6 +199,57 @@ def _get_eph_disk(ephemeral):
386++ help='libvirt console log ringbugger size'),
387+ cfg.IntOpt('libvirt_wait_soft_reboot_seconds',
388+ default=120,
389+ help='Number of seconds to wait for instance to shut down after'
390+@@ -189,6 +196,57 @@
391 return 'disk.eph' + str(ephemeral['num'])
392
393
394@@ -436,7 +415,7 @@
395 class LibvirtConnection(driver.ComputeDriver):
396
397 def __init__(self, read_only):
398-@@ -222,6 +283,8 @@ class LibvirtConnection(driver.ComputeDriver):
399+@@ -222,6 +280,8 @@
400
401 self.image_cache_manager = imagecache.ImageCacheManager()
402
403@@ -445,7 +424,7 @@
404 @property
405 def host_state(self):
406 if not self._host_state:
407-@@ -230,7 +293,11 @@ class LibvirtConnection(driver.ComputeDriver):
408+@@ -230,7 +290,11 @@
409
410 def init_host(self, host):
411 # NOTE(nsokolov): moved instance restarting to ComputeManager
412@@ -458,7 +437,7 @@
413
414 @property
415 def libvirt_xml(self):
416-@@ -307,6 +374,15 @@ class LibvirtConnection(driver.ComputeDriver):
417+@@ -307,6 +371,15 @@
418 return [self._conn.lookupByID(x).name()
419 for x in self._conn.listDomainsID()
420 if x != 0] # We skip domains with ID 0 (hypervisors).
421@@ -474,7 +453,7 @@
422
423 @staticmethod
424 def _map_to_instance_info(domain):
425-@@ -432,6 +508,7 @@ class LibvirtConnection(driver.ComputeDriver):
426+@@ -432,6 +505,7 @@
427 def _cleanup(self, instance):
428 target = os.path.join(FLAGS.instances_path, instance['name'])
429 instance_name = instance['name']
430@@ -482,7 +461,7 @@
431 LOG.info(_('Deleting instance files %(target)s') % locals(),
432 instance=instance)
433 if FLAGS.libvirt_type == 'lxc':
434-@@ -909,10 +986,10 @@ class LibvirtConnection(driver.ComputeDriver):
435+@@ -909,10 +983,10 @@
436
437 @exception.wrap_exception()
438 def get_console_output(self, instance):
439@@ -496,7 +475,7 @@
440
441 if FLAGS.libvirt_type == 'xen':
442 # Xen is special
443-@@ -920,14 +997,12 @@ class LibvirtConnection(driver.ComputeDriver):
444+@@ -920,14 +994,12 @@
445 'ttyconsole',
446 instance['name'])
447 data = self._flush_xen_console(virsh_output)
448@@ -513,7 +492,7 @@
449
450 @staticmethod
451 def get_host_ip_addr():
452-@@ -1053,8 +1128,25 @@ class LibvirtConnection(driver.ComputeDriver):
453+@@ -1053,8 +1125,25 @@
454 container_dir = '%s/rootfs' % basepath(suffix='')
455 libvirt_utils.ensure_tree(container_dir)
456
457@@ -541,6 +520,18 @@
458
459 if not disk_images:
460 disk_images = {'image_id': instance['image_ref'],
461---
462-1.7.9
463-
464+Index: nova/nova/virt/libvirt.xml.template
465+===================================================================
466+--- nova.orig/nova/virt/libvirt.xml.template 2012-03-05 14:27:39.000000000 -0800
467++++ nova/nova/virt/libvirt.xml.template 2012-03-05 14:27:46.687612406 -0800
468+@@ -160,8 +160,8 @@
469+
470+ #end for
471+ <!-- The order is significant here. File must be defined first -->
472+- <serial type="file">
473+- <source path='${basepath}/console.log'/>
474++ <serial type="pipe">
475++ <source path='${basepath}/console.fifo'/>
476+ <target port='1'/>
477+ </serial>
478+

Subscribers

People subscribed via source and target branches