Original volume size is lost when uploading a volume to a qcow2 image
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Cinder |
In Progress
|
High
|
Takashi Kajinami |
Bug Description
This issue was initially reported in https:/
Currently when uploading a cinder volume to a glance image in qcow2 format, size of the newly created glance image is computed as size of the actual qcow2 file instead of original volume size.
For example if we create an empty 1GiB volume
~~~
(overcloud) [stack@undercloud-0 ~]$ openstack volume create sourcevolume --size 2
...
(overcloud) [stack@undercloud-0 ~]$ openstack volume show sourcevolume
+------
| Field | Value |
+------
| attachments | [] |
| availability_zone | nova |
| bootable | false |
| consistencygroup_id | None |
| created_at | 2021-07-
| description | None |
| encrypted | False |
| id | cb2113ce-
| migration_status | None |
| multiattach | False |
| name | sourcevolume |
| os-vol-
| os-vol-
| os-vol-
| os-vol-
| properties | |
| replication_status | None |
| size | 2 |
| snapshot_id | None |
| source_volid | None |
| status | available |
| type | tripleo |
| updated_at | 2021-07-
| user_id | 06b547a0af8f49f
+------
~~~
... and then create a qcow2 image from the volume
~~~
(overcloud) [stack@undercloud-0 ~]$ openstack image create --volume sourcevolume --disk-format qcow2 testimage
...
~~~
... then the image gets 197120 Bi which is the actual size of qcow2 file.
~~~
(overcloud) [stack@undercloud-0 ~]$ openstack image show testimage
+------
| Field | Value |
+------
| checksum | dc9ef2e7cf57a42
| container_format | bare |
| created_at | 2021-07-
| disk_format | qcow2 |
| file | /v2/images/
| id | e1272ef7-
| min_disk | 0 |
| min_ram | 0 |
| name | testimage |
| owner | 942783ae248c4e9
| properties | direct_
| protected | False |
| schema | /v2/schemas/image |
| size | 197120 |
| status | active |
| tags | |
| updated_at | 2021-07-
| virtual_size | None |
| visibility | shared |
+------
~~~
If we try to create a 1GB volume form that image, the request is accpeted but the volume eventually becomes error status.
~~~
(overcloud) [stack@undercloud-0 ~]$ openstack volume create smallervolume --image testimage --size 1
...
(overcloud) [stack@undercloud-0 ~]$ openstack volume show smallervolume
+------
| Field | Value |
+------
| attachments | [] |
| availability_zone | nova |
| bootable | false |
| consistencygroup_id | None |
| created_at | 2021-07-
| description | None |
| encrypted | False |
| id | a72f04f5-
| migration_status | None |
| multiattach | False |
| name | smallervolume |
| os-vol-
| os-vol-
| os-vol-
| os-vol-
| properties | |
| replication_status | None |
| size | 1 |
| snapshot_id | None |
| source_volid | None |
| status | error |
| type | tripleo |
| updated_at | 2021-07-
| user_id | 06b547a0af8f49f
| volume_
+------
~~~
It is because that virtual size of the image(2GB) doesn't fit in a volume size(1GB), but this error is not exposed to users.
This makes it difficult to let users know actual cause of the error.
~~~
2021-07-21 07:52:39.678 74 ERROR oslo_messaging.
ImageUnacceptable: Image e1272ef7-
2021-07-21 07:52:39.678 74 ERROR oslo_messaging.
2021-07-21 07:52:39.678 74 ERROR oslo_messaging.
2021-07-21 07:52:39.678 74 ERROR oslo_messaging.
...
2021-07-21 07:52:39.678 74 ERROR oslo_messaging.
2021-07-21 07:52:39.678 74 ERROR oslo_messaging.
2021-07-21 07:52:39.678 74 ERROR oslo_messaging.
2021-07-21 07:52:39.678 74 ERROR oslo_messaging.
2021-07-21 07:52:39.678 74 ERROR oslo_messaging.
2021-07-21 07:52:39.678 74 ERROR oslo_messaging.
2021-07-21 07:52:39.678 74 ERROR oslo_messaging.
2021-07-21 07:52:39.678 74 ERROR oslo_messaging.
~~~
Because cinder is aware of the original volume size, it should be able to recognize original volume size and reject creating a new volume smaller than the original volume.
description: | updated |
Changed in cinder: | |
assignee: | nobody → Takashi Kajinami (kajinamit) |
Fix proposed to branch: master /review. opendev. org/c/openstack /cinder/ +/804584
Review: https:/