Merge lp:~johannes.erdfelt/nova/bug723996 into lp:~hudson-openstack/nova/trunk

Proposed by Johannes Erdfelt
Status: Merged
Approved by: Vish Ishaya
Approved revision: 980
Merged at revision: 1090
Proposed branch: lp:~johannes.erdfelt/nova/bug723996
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 25 lines (+8/-0)
1 file modified
nova/virt/xenapi/vm_utils.py (+8/-0)
To merge this branch: bzr merge lp:~johannes.erdfelt/nova/bug723996
Reviewer Review Type Date Requested Status
Vish Ishaya (community) Approve
Cory Wright (community) Needs Information
Rick Harris (community) Approve
Devin Carlen (community) Approve
Brian Waldon (community) Approve
Review via email: mp+57367@code.launchpad.net

Description of the change

Add new flag 'max_kernel_ramdisk_size' to specify a maximum size of kernel or ramdisk so we don't copy large files to dom0 and fill up /boot/guest

To post a comment you must log in.
Revision history for this message
Brian Waldon (bcwaldon) wrote :

Looks good. Are there any other related image sizes we want to check with regards to this bug?

review: Approve
Revision history for this message
Brian Waldon (bcwaldon) wrote :

Actually, now that I think about it, would it make sense to add support for other virt drivers?

Revision history for this message
Johannes Erdfelt (johannes.erdfelt) wrote :

On Tue, Apr 12, 2011, Brian Waldon <email address hidden> wrote:
> Actually, now that I think about it, would it make sense to add support
> for other virt drivers?

Depends on if they need to store kernels and ramdisks on the VM host
filesystem like XenServer does.

I'm not familiar enough with other virt drivers to know if they need
similar checks.

JE

Revision history for this message
Devin Carlen (devcamcar) wrote :

Not a Xen expert but this looks pretty reasonable. Minor grammar/style nit:

21 + _("Kernel/Ramdisk image is too large, %(vdi_size)d bytes "
22 + "(max %(max_size)d bytes)") %

Should be:

"Kernel/Ramdisk image is too large: %(vdi_size)d bytes "

(colon instead of comma)

review: Approve
lp:~johannes.erdfelt/nova/bug723996 updated
979. By Johannes Erdfelt

Minor formatting cleanup

Revision history for this message
Rick Harris (rconradharris) wrote :

Looks good, thanks Johannes.

Some thoughts:

* I noticed that FLAGS seem to be split between vm_utils.py and xenapi_conn.py. Is there a semantic distinction or was that more-or-less arbitrary. If possible, I'd like to see all of the flags go in one place; in this case, xenapi_conn since that's where most already exist.

Should we move the newly-created flag there and create a bug to move the other two flags?

* Should we log the fact that an excessively large kernel was attempted? Basically, extracting the msg part of the exception and then logging it before raising:

  msg = _("helpful message here")
  LOG.error(msg)
  raise exception.Error(msg)

This is a pretty common pattern; wonder if a util.raise_with_logging(exc_class, msg) helper would be useful?

Just a couple of suggestions, will leave up to you whether to update the patch. Thanks again.

review: Approve
Revision history for this message
Cory Wright (corywright) wrote :

Johannes, would you like to respond to Rick's comments from above?

review: Needs Information
lp:~johannes.erdfelt/nova/bug723996 updated
980. By Johannes Erdfelt

Merge with trunk

Revision history for this message
Johannes Erdfelt (johannes.erdfelt) wrote :

The FLAGS are defined where they are used. I don't see why changing it is better.

I'm pretty sure exceptions get logged as is. Perhaps I don't understand what the advantage of logging the error twice is?

Revision history for this message
Vish Ishaya (vishvananda) wrote :

going to merge this. Rick, if you want to add the exception logging thing lets do it in another patch

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nova/virt/xenapi/vm_utils.py'
2--- nova/virt/xenapi/vm_utils.py 2011-04-26 22:48:28 +0000
3+++ nova/virt/xenapi/vm_utils.py 2011-05-09 15:52:50 +0000
4@@ -48,6 +48,8 @@
5 flags.DEFINE_string('default_os_type', 'linux', 'Default OS type')
6 flags.DEFINE_integer('block_device_creation_timeout', 10,
7 'time to wait for a block device to be created')
8+flags.DEFINE_integer('max_kernel_ramdisk_size', 16 * 1024 * 1024,
9+ 'maximum size in bytes of kernel or ramdisk images')
10
11 XENAPI_POWER_STATE = {
12 'Halted': power_state.SHUTDOWN,
13@@ -444,6 +446,12 @@
14 if image_type == ImageType.DISK:
15 # Make room for MBR.
16 vdi_size += MBR_SIZE_BYTES
17+ elif image_type == ImageType.KERNEL_RAMDISK and \
18+ vdi_size > FLAGS.max_kernel_ramdisk_size:
19+ max_size = FLAGS.max_kernel_ramdisk_size
20+ raise exception.Error(
21+ _("Kernel/Ramdisk image is too large: %(vdi_size)d bytes, "
22+ "max %(max_size)d bytes") % locals())
23
24 name_label = get_name_label_for_image(image)
25 vdi_ref = cls.create_vdi(session, sr_ref, name_label, vdi_size, False)