ephemeral devices on LVM don't get mkfs'd

Bug #1083424 reported by Adam Jacob Muller
16
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
High
Rafi Khardalian

Bug Description

ephemeral device creation when using LVM devices does not cause the resulting filesystem to get newfs'd

Reading through nova code:
in utils.py/LibvirtDriver/_create_image
            fn = functools.partial(self._create_ephemeral,
                                   fs_label='ephemeral0',
                                   os_type=instance["os_type"])
then:
            image('disk.local').cache(fetch_func=fn,
                                      filename=fname,
                                      size=size,
                                      ephemeral_size=ephemeral_gb)
is called

cache() then calls imagebackend.py/Lvm/create_image
create_image() then calls libvirt_utils.create_lvm_image, which creates the LVM
prepare_template() is then called, leading us cache.call_if_not_exists
call_if_not_exists contains the following check:
            if not os.path.exists(target):
since create_image has already created the lvm device, the /dev/ entry exists and therefore our fetch_func (self._create_ephemeral) never gets called, and no filesystem is created on the ephemeral device.

Michael Still (mikal)
Changed in nova:
status: New → Triaged
importance: Undecided → Critical
Revision history for this message
Adam Jacob Muller (78luphr0rnk2nuqimstywepozxn9kl19tqh0tx66b5dki1xxsh5mkz9gl21a5rlwfnr8jn6ln0m3jxne2k9x1ohg85w3jabxlrqbgszpjpwcmvk-launchpad) wrote :

I have an absolutely hackish patch for this, that I'm 100% sure isn't the right way.

In, call_if_not_exists I changed:
if not os.path.exists(target):
to
if not os.path.exists(target) and 'ephemeral_size' not in kwargs:
and
    def _create_ephemeral(self, target, ephemeral_size, fs_label, os_type):
        if not os.path.exists(target):
                self._create_local(target, ephemeral_size)
        disk.mkfs(os_type, fs_label, target)
This is bad, but it works :)

Thierry Carrez (ttx)
Changed in nova:
importance: Critical → High
milestone: none → grizzly-2
Thierry Carrez (ttx)
Changed in nova:
milestone: grizzly-2 → grizzly-3
Thierry Carrez (ttx)
Changed in nova:
milestone: grizzly-3 → grizzly-rc1
Revision history for this message
Stuart Stent (stuart-stent) wrote :

Is there any progress on this?

Revision history for this message
Rafi Khardalian (rkhardalian) wrote :

I've been working with this code lately so I'll take a stab at fixing this.

Changed in nova:
assignee: nobody → Rafi Khardalian (rkhardalian)
status: Triaged → In Progress
Revision history for this message
Rafi Khardalian (rkhardalian) wrote :

I've been thinking about this and wonder whether we should be doing a mkfs at all. Doing so means we're making an assumption that the instance is running Linux. If the instance happens to be targeted for Windows, that filesystem we just built is completely useless. Even with non-LVM backed instances, we rely on cloud-init (or similar guest-level automation) to setup ephemeral devices. So, unless I have misunderstood the report, I don't see a problem here.

TL;DR: I don't think we should be doing anything with ephemeral via Nova aside from providing the instance a usable block device.

Revision history for this message
Rafi Khardalian (rkhardalian) wrote :

Vish just pointed out that we're conditionally mkfs'ing based on image metadata. Thus, this bug is valid and we should be doing the same for LVM.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.openstack.org/23253

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/23253
Committed: http://github.com/openstack/nova/commit/8bd8da476c9e7718cea6552e767ea51727d28418
Submitter: Jenkins
Branch: master

commit 8bd8da476c9e7718cea6552e767ea51727d28418
Author: Rafi Khardalian <email address hidden>
Date: Fri Mar 1 08:53:52 2013 +0000

    Fix ephemeral devices on LVM don't get mkfs'd

    Fixes bug 1083424

    Updated imagebackend to run the necessary callback conditionally
    based on whether LVM is configured for use and ephemeral_size is
    defined. The callback function was updated not to invoke qemu-img
    for LVM, since the ephemeral disk is already present/created via
    LVM. Lastly, the mkfs call had to be changed to be run as root,
    since we are dealing with raw devices.

    Change-Id: Ieb1febb0ea086f8e5063d92ca376d349fcd43a43

Changed in nova:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in nova:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: grizzly-rc1 → 2013.1
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.