Image "container_format" incorrectly modified when editing image

Bug #1539722 reported by Alex Oughton
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Dashboard (Horizon)
Fix Released
Medium
Ziyu Bai

Bug Description

Hello,

When editing a Glance image in Horizon (for example, changing its name), Horizon is incorrectly changing the container_format to "bare", losing whatever the value previously was. This is affecting images which have been taken from XenServer, as the container_format is changed from "ovf" to "bare". The end-result of this, is that Cinder does not run through the proper image conversion procedures (coalesce, etc.) when creating a Volume from that Image. Instead it will just dump the .gz file onto the volume, which is obviously unbootable.

We have traced the problem down to the file /usr/share/openstack-dashboard/openstack_dashboard/dashboards/project/images/images/forms.py. In the function "create_image_metadata", there is a section which states:

if disk_format in ('ami', 'aki', 'ari',):
    container_format = disk_format
elif disk_format == 'docker':
    # To support docker containers we allow the user to specify
    # 'docker' as the format. In that case we really want to use
    # 'raw' as the disk format and 'docker' as the container format.
    disk_format = 'raw'
    container_format = 'docker'
else:
    container_format = 'bare'

It's clear to see here how this is overriding the container_format from its proper value. I believe an appropriate patch would be to add an an "elif disk_format=='vhd' " section. For example, we have done the following which is working for us:

if disk_format in ('ami', 'aki', 'ari',):
    container_format = disk_format
elif disk_format == 'docker':
    # To support docker containers we allow the user to specify
    # 'docker' as the format. In that case we really want to use
    # 'raw' as the disk format and 'docker' as the container format.
    disk_format = 'raw'
    container_format = 'docker'
elif disk_format == 'vhd':
    container_format = 'ovf'
else:
    container_format = 'bare'

I'm not enough of a developer to know if this is truly the correct patch, or if this will break some other functionality for someone else. Could a real developer please take a look at this, and patch as appropriate?

Thanks in advance,

Alex Oughton

Revision history for this message
Renjie Sun (sunrenjie6) wrote :

I took a cirros qcow2 image, convert to vhd (using qemu-img command given in [1]), upload with container_format=ovf to a devstack+kvm installation to give it a run.

The part of modifying container_format to bare while editing the image is verified, as expected. However, the vhd image with bare container_format can be used to boot vm (maybe some kvm vs. Xen thing?). Therefore, there is no strong reason to give a disk=vhd => container=ovf deduction (correct me if possible). Anyway, the inline comments and docs [2] do not say much about that.

That said, the idea I come up is that, we could take the existing container value into account in create_image_metadata(). If the image format does not change during the image update, we could re-use the old container_format. Otherwise, we shall fall back to the existing deduction logic. Such modest approach may fit horizon better, being a client as thin as possible.

I created a quick-and-dirty patch for it. Please take a look at it. :)

[1] http://docs.openstack.org/image-guide/convert-images.html
[2] http://docs.openstack.org/image-guide/image-formats.html

Revision history for this message
Alex Oughton (alex-oughton) wrote :

Hello Renjie,

Thank you for taking a look at this. The loss of the container_format value is an issue when using Boot from Volume with XenServer. This is because Cinder only performs the proper image conversion processes for a XenServer image when the container_format is set to OVF.

Correct procedure when container_format set to "OVF": Cinder will extract the tgz image file, use vhd-util to coalesce the VHD files together, and then use qemu-img to dump the coalesced VHD to a volume. This is then bootable.

Incorrect procedure when container_format set to "Bare": Cinder will dump the tgz file directly onto the volume. This is obviously not bootable.

I hope this helps explain the issue a little better. Thanks again for looking into this already.

Alex Oughton

Renjie Sun (sunrenjie6)
Changed in horizon:
status: New → Confirmed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to horizon (master)

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

Changed in horizon:
assignee: nobody → Renjie Sun (sunrenjie6)
status: Confirmed → In Progress
Revision history for this message
Renjie Sun (sunrenjie6) wrote :

Hello, Alex,

Thanks for the clarification.
The patch is proposed as the Infra robot already posted. Feel free to comment on that.
The fix is really ad-hoc. Hopefully there will be a better approach, or even a solution in glance's part.

Revision history for this message
Alex Oughton (alex-oughton) wrote :

Hello Renjie,

I applied your patch to my system (rolling-back the other changes I had made), and found it to work. The "OVF" value was retained as desired.

Thanks,

Alex Oughton

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on horizon (master)

Change abandoned by Rob Cresswell (<email address hidden>) on branch: master
Review: https://review.openstack.org/275482
Reason: Abandoned due to inactivity

Changed in horizon:
status: In Progress → New
assignee: Renjie Sun (sunrenjie6) → nobody
Changed in horizon:
status: New → Confirmed
importance: Undecided → Medium
milestone: none → next
Changed in horizon:
status: Confirmed → In Progress
assignee: nobody → Ziyu Bai (baiziyu-inspur)
Changed in horizon:
status: In Progress → Fix Committed
Changed in horizon:
status: Fix Committed → In Progress
Changed in horizon:
status: In Progress → Fix Committed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to horizon (master)

Reviewed: https://review.opendev.org/664132
Committed: https://git.openstack.org/cgit/openstack/horizon/commit/?id=ba75bafc69c03f04b3c7d4f50e1cc9e3123743a3
Submitter: Zuul
Branch: master

commit ba75bafc69c03f04b3c7d4f50e1cc9e3123743a3
Author: 白子玉 <email address hidden>
Date: Sat Jun 8 15:14:51 2019 +0800

    Specify proper container_format for 'vhd' disk_format

    When editing an image, if the disk_fomrat is 'vhd',
    the container_format was wrongly set to 'bare' before.
    'ovf' is the correct container_format for 'vhd' disk images.

    Closes-Bug: #1539722
    Change-Id: Ic6b0c66af0d5c8db2d802d6eea2b97721d92b7eb

Changed in horizon:
status: Fix Committed → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/horizon 16.0.0.0rc1

This issue was fixed in the openstack/horizon 16.0.0.0rc1 release candidate.

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.