libvirt: the None value for the 'os_type' property is passed to glance when doing a snapshot

Bug #1240542 reported by Andrea Rosa
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Medium
Andrea Rosa

Bug Description

This change: https://review.openstack.org/42877 introduced the ability to pass os_type property to glance when we are doing a snapshot, but the change doesn't manage correctly the None value for this property.

The result of that is that we have a porperty called 'os_type': None associated with the snapshotted image.
That is a problem as this property is used when we create the backing file for the ephemeral disks.

From nova/virt/libvirt/driver/py:
 # Lookup the filesystem type if required
 os_type_with_default = instance['os_type']
 if not os_type_with_default:
     os_type_with_default = 'default'

and then we create the ephemeral file name using this rule:

fname = "ephemeral_%s_%s" % (ephemeral_gb, os_type_with_default)

Now consider an instance with a flavor with an ephemeral disk of 50 G and without the os_type defined, the resulting backing file will be:
"ephemeral_50_default"
At this point if we create a snapshot from that instance and we boot from it we will have another backing file created and called:
"ephemeral_50_None"

That is bad for at least two reasons:
1 performance issue: we need to create a new backing file which is not actually necessary
2 resources leaking: those backing files consume disk capacity on the host

Changed in nova:
assignee: nobody → Andrea Rosa (andrea-rosa-m)
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/52138

Changed in nova:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/52138
Committed: http://github.com/openstack/nova/commit/db0daa3455f114e90cefbe02e205ca1d327fc45c
Submitter: Jenkins
Branch: master

commit db0daa3455f114e90cefbe02e205ca1d327fc45c
Author: Andrea Rosa <email address hidden>
Date: Wed Oct 16 15:38:27 2013 +0100

    Manage None value for the 'os_type' property

    The I2bab617f6c1e8866650ca7dc5178b640738c9ae6 introduced a way to pass the
    'os_type' property to glance when we are doing a snapshot in the libvirt
    driver. Currently the code doesn't manage properly the None value for this
    property and so None value is passed to glance which creates an image with
    a property called 'os_type' with value 'None'.
    As results of that all instances booted from a snapshot with this property will
    have None value in the os_type field.
    That field is used to create file name for backing images for ephemeral disks.
    Now consider this scenario:
    we boot an instance from an image without the os_type property defined and
    with an ephemeral disk of 50 G
    the resulting backing file will be called ephemeral_50_default.
    At this point we take a snapshot from that instance and we boot a new instance
    using this snapshot, and because of this bug we will have a new backing file
    called ephemeral_50_None.
    That is bad because is leaking resources in the host.

    Please note that I did a small refactor of the code to make my change testable.

    Change-Id: I40bca2732ee2c911344e9d361612007da1c7c3cf
    Closes-bug: #1240542

Changed in nova:
status: In Progress → Fix Committed
Changed in nova:
importance: Undecided → Medium
tags: added: havana-backport-potential
Changed in nova:
milestone: none → icehouse-1
Thierry Carrez (ttx)
Changed in nova:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: icehouse-1 → 2014.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.