min_disk and size information wrong when creating an instance image

Bug #1369854 reported by Julie Pichon
18
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Glance
Invalid
Undecided
Unassigned
OpenStack Compute (nova)
Fix Released
Medium
Feodor Tersin

Bug Description

If I launch an instance from an image that has min_disk set to 2GB, then create an image from the instance, the min_disk attribute is not set correctly on the image (it's set to 0). Instead of being set as an attribute, it exists as a property instead. This can cause issues when other services rely on min_disk to make decisions about size (e.g. bug 1368600 for Horizon, not sure if Cinder is affected too).

This doesn't seem to happen when creating a basic instance from an instance, only when there is also a volume involved.

I'm not sure if this is a nova or glance issue so I'm opening a task on both for now.

Steps to reproduce
------------------------
(done on a recent devstack)

1. Create a new image with e.g. min_disk 2GB
$ glance image-create --name mindisk2gb --disk-format qcow2 --container-format bare --location https://launchpad.net/cirros/trunk/0.3.0/+download/cirros-0.3.0-i386-disk.img --min-disk 2
+------------------+--------------------------------------+
| Property | Value |
+------------------+--------------------------------------+
| checksum | None |
| container_format | bare |
| created_at | 2014-09-16T12:35:33 |
| deleted | False |
| deleted_at | None |
| disk_format | qcow2 |
| id | 9bbed3a5-00bf-4901-855e-556ca02e7fb7 |
| is_public | False |
| min_disk | 2 | <-- min_disk set as expected
| min_ram | 0 |
| name | mindisk2gb |
| owner | eb6acc49df4b4390a99c722ded526284 |
| protected | False |
| size | 9159168 | <-- size looks ok
| status | active |
| updated_at | 2014-09-16T12:35:37 |
| virtual_size | None |
+------------------+--------------------------------------+

2. Boot an instance from this image, backed by a volume (I believe this matches what happens when launching with "Image (creates a new volume)" in Horizon)
$ nova boot --flavor 4115a835-04f0-4457-b93c-1817bc44812c --block-device device='/dev/vda',source='image',dest='volume',id='9bbed3a5-00bf-4901-855e-556ca02e7fb7',size=2,bootindex=0 my_instance
+--------------------------------------+--------------------------------------------------+
| Property | Value |
+--------------------------------------+--------------------------------------------------+
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-AZ:availability_zone | nova |
| OS-EXT-STS:power_state | 0 |
| OS-EXT-STS:task_state | - |
| OS-EXT-STS:vm_state | building |
| OS-SRV-USG:launched_at | - |
| OS-SRV-USG:terminated_at | - |
| accessIPv4 | |
| accessIPv6 | |
| adminPass | Uo2DL64GaY74 |
| config_drive | |
| created | 2014-09-16T12:55:30Z |
| flavor | m1.lowmem (4115a835-04f0-4457-b93c-1817bc44812c) |
| hostId | |
| id | 3e70fd2e-1dc6-4001-941e-9496a9514882 |
| image | Attempt to boot from volume - no image supplied |
| key_name | - |
| metadata | {} |
| name | my_instance |
| os-extended-volumes:volumes_attached | [] |
| progress | 0 |
| security_groups | default |
| status | BUILD |
| tenant_id | eb6acc49df4b4390a99c722ded526284 |
| updated | 2014-09-16T12:55:31Z |
| user_id | 437279436240498faca4f7bfd0fdc78a |
+--------------------------------------+--------------------------------------------------+

3. Create a snapshot
$ nova image-create 3e70fd2e-1dc6-4001-941e-9496a9514882 my_instance_snap

4. Find the snapshot in glance image-list and look at the details:
$ glance image-show d44f7368-5b91-4291-b1f4-e9386fbbbe93
+---------------------------------+----------------------------------------------------------------------------------+
| Property | Value |
+---------------------------------+----------------------------------------------------------------------------------+
| Property 'bdm_v2' | True |
| Property 'block_device_mapping' | [{"guest_format": null, "boot_index": 0, "no_device": null, "snapshot_id": |
| | "bce8f300-e21f-47c9-a015-3dfee2f35745", "delete_on_termination": null, |
| | "disk_bus": "virtio", "image_id": null, "source_type": "snapshot", |
| | "device_type": "disk", "volume_id": null, "destination_type": "volume", |
| | "volume_size": null}] |
| Property 'container_format' | bare |
| Property 'disk_format' | qcow2 |
| Property 'image_id' | 9bbed3a5-00bf-4901-855e-556ca02e7fb7 |
| Property 'image_name' | mindisk2gb |
| Property 'min_disk' | 2 | <-- min_disk is set as a property
| Property 'min_ram' | 0 |
| Property 'root_device_name' | /dev/vda |
| Property 'size' | 9159168 | <-- the size appears correct in the properties
| created_at | 2014-09-16T12:57:25 |
| deleted | False |
| id | d44f7368-5b91-4291-b1f4-e9386fbbbe93 |
| is_public | False |
| min_disk | 0 | <-- min_disk is 0
| min_ram | 0 |
| name | my_instance_snap |
| owner | eb6acc49df4b4390a99c722ded526284 |
| protected | False |
| size | 0 | <-- size is set to 0 too
| status | active |
| updated_at | 2014-09-16T12:57:25 |
+---------------------------------+----------------------------------------------------------------------------------+

Chatting with someone on the Glance team this doesn't seem to be the expected behaviour? I would expect the size and min_disk attribute to be correct and similar to the properties, in this case.

Revision history for this message
Sean Dague (sdague) wrote :

I think the real question is why the data is coming up in the Property namespace, and not going back into the main namespace. It almost seems like the metadata update in glanceclient is going through the wrong path.

Any idea which glance API was being used in your setup?

Changed in nova:
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
Julie Pichon (jpichon) wrote :
Download full text (7.8 KiB)

I don't recall changing anything from the devstack configuration defaults. Here are some logs extracts:

n-api:

2014-09-16 16:52:41.397 DEBUG nova.api.openstack.wsgi [req-8a9287ed-c1d8-47cc-bc45-d54dcc4effd8 demo demo] Action: 'action', body: {"createImage": {"name": "my_instance_snap2", "metadata": {}}} from (pid=31342) _process_stack /opt/stack/nova/nova/api/openstack/wsgi.py:931
2014-09-16 16:52:41.398 DEBUG nova.api.openstack.wsgi [req-8a9287ed-c1d8-47cc-bc45-d54dcc4effd8 demo demo] Calling method '<bound method Controller._action_create_image of <nova.api.openstack.compute.contrib.keypairs.Controller object at 0x351e310>>' (Content-type='application/json', Accept='application/json') from (pid=31342) _process_stack /opt/stack/nova/nova/api/openstack/wsgi.py:936
2014-09-16 16:52:41.868 DEBUG nova.volume.cinder [req-8a9287ed-c1d8-47cc-bc45-d54dcc4effd8 demo demo] Cinderclient connection created using URL: http://192.168.100.189:8776/v1/eb6acc49df4b4390a99c722ded526284 from (pid=31342) get_cinder_client_version /opt/stack/nova/nova/volume/cinder.py:255
2014-09-16 16:52:42.362 DEBUG nova.volume.cinder [req-8a9287ed-c1d8-47cc-bc45-d54dcc4effd8 demo demo] Cinderclient connection created using URL: http://192.168.100.189:8776/v1/eb6acc49df4b4390a99c722ded526284 from (pid=31342) get_cinder_client_version /opt/stack/nova/nova/volume/cinder.py:255
2014-09-16 16:52:42.647 DEBUG nova.volume.cinder [req-8a9287ed-c1d8-47cc-bc45-d54dcc4effd8 demo demo] Cinderclient connection created using URL: http://192.168.100.189:8776/v1/eb6acc49df4b4390a99c722ded526284 from (pid=31342) get_cinder_client_version /opt/stack/nova/nova/volume/cinder.py:255
2014-09-16 16:52:42.943 DEBUG stevedore.extension [req-8a9287ed-c1d8-47cc-bc45-d54dcc4effd8 demo demo] found extension EntryPoint.parse('file = nova.image.download.file') from (pid=31342) _load_plugins /usr/lib/python2.7/site-packages/stevedore/extension.py:156
2014-09-16 16:52:42.944 DEBUG stevedore.extension [req-8a9287ed-c1d8-47cc-bc45-d54dcc4effd8 demo demo] found extension EntryPoint.parse('file = nova.image.download.file') from (pid=31342) _load_plugins /usr/lib/python2.7/site-packages/stevedore/extension.py:156
2014-09-16 16:52:42.946 DEBUG glanceclient.common.http [req-8a9287ed-c1d8-47cc-bc45-d54dcc4effd8 demo demo] curl -i -X POST -H 'x-image-meta-property-image_name: mindisk2gb' -H 'Accept-Encoding: gzip, deflate' -H 'x-image-meta-property-bdm_v2: True' -H 'Content-Type: application/octet-stream' -H 'x-image-meta-property-min_disk: 2' -H 'x-image-meta-property-root_device_name: /dev/vda' -H 'Accept: */*' -H 'x-image-meta-property-min_ram: 0' -H 'x-image-meta-size: 0' -H 'x-image-meta-property-container_format: bare' -H 'x-image-meta-is_public: False' -H 'x-image-meta-property-block_device_mapping: [{"guest_format": null, "boot_index": 0, "no_device": null, "snapshot_id": "4c3e85a8-1656-4395-aaec-d81172a8897a", "delete_on_termination": null, "disk_bus": "virtio", "image_id": null, "source_type": "snapshot", "device_type": "disk", "volume_id": null, "destination_type": "volume", "volume_size": null}]' -H 'x-image-meta-property-disk_format: qcow2' -H 'User-Agent: python-glanceclient' -H 'X-Auth-Token: ***' -H...

Read more...

Changed in glance:
status: New → Confirmed
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/170243

Changed in nova:
assignee: nobody → Feodor Tersin (ftersin)
status: Confirmed → In Progress
Revision history for this message
Feodor Tersin (ftersin) wrote :

min_disk and size should be 0 for volume-backed instances since they does not consume host disks. See bug 1469179.

But min_ram must be copied. The proposed patch fixes it.

Changed in nova:
assignee: Feodor Tersin (ftersin) → Michael Still (mikalstill)
wangxiyuan (wangxiyuan)
Changed in glance:
assignee: nobody → wangxiyuan (wangxiyuan)
Changed in nova:
assignee: Michael Still (mikalstill) → Feodor Tersin (ftersin)
Revision history for this message
Feodor Tersin (ftersin) wrote :

Now https://review.openstack.org/170243 copies min_disk too.

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

Reviewed: https://review.openstack.org/170243
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=8cf2d41344785a0752fbfe8745032aed2ec11e27
Submitter: Jenkins
Branch: master

commit 8cf2d41344785a0752fbfe8745032aed2ec11e27
Author: Feodor Tersin <email address hidden>
Date: Mon Jul 6 21:42:14 2015 +0300

    Fix collection of metadata for a snapshot of a volume-backed instance

    Currently the snapshot derives its properties from the instance source:
    an other snapshot or a bootable volume. But that sources could be
    changed since the instance was booted.

    To make instance snapshots independent of source changes this patch
    collects metadata from instance system metadata rather than the sources.

    Since it brings the only way to initialize image metadata, it fixes:
    a) min_ram attribute is not inherited from a bootable volume
    (LP #1369854).
    b) empty container_format and disk_format attribute are inherited from a
    source instance snapshot (LP #1439819).

    Closes-Bug: #1369854
    Closes-Bug: #1439819
    Related-Bug: #1469179
    Change-Id: I067f66356a5ebd738add1591a0069d8049f35c24

Changed in nova:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in nova:
milestone: none → liberty-3
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: liberty-3 → 12.0.0
wangxiyuan (wangxiyuan)
Changed in glance:
assignee: wangxiyuan (wangxiyuan) → nobody
status: Confirmed → Invalid
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.