Unexpected behavior when upload a snapshot-volume to vol-backed image

Bug #1795098 reported by Yikun Jiang
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Cinder
Fix Released
Medium
Yikun Jiang

Bug Description

Unexpected behavior when upload a snapshot-volume to vol-backed image

0. Configure the volume-backed image, according [1]
1. Create a volume from snapshot.
# cinder create --snapshot 2609e615-323f-4927-923f-028848d45940 1
# cinder list --fields snapshot_id
+--------------------------------------+--------------------------------------+
| ID | Snapshot_Id |
+--------------------------------------+--------------------------------------+
| ae4ce4dc-23b6-49a8-aeae-90c34b7e5db9 | 2609e615-323f-4927-923f-028848d45940 |
+--------------------------------------+--------------------------------------+
2. Delete snapshot
# cinder snapshot-delete 2609e615-323f-4927-923f-028848d45940
3. Failed to upload volume to image.
# cinder upload-to-image ae4ce4dc-23b6-49a8-aeae-90c34b7e5db9 test_image

Because:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/taskflow/engines/action_engine/executor.py", line 53, in _execute_task
    result = task.execute(**arguments)
  File "/opt/stack/cinder/cinder/volume/flows/manager/create_volume.py", line 1034, in execute
    **volume_spec)
  File "/opt/stack/cinder/cinder/volume/flows/manager/create_volume.py", line 448, in _create_from_snapshot
    snapshot = objects.Snapshot.get_by_id(context, snapshot_id)
  File "/opt/stack/cinder/cinder/objects/base.py", line 346, in get_by_id
    orm_obj = db.get_by_id(context, cls.model, id, *args, **kwargs)
  File "/opt/stack/cinder/cinder/db/api.py", line 1789, in get_by_id
    return IMPL.get_by_id(context, model, id, *args, **kwargs)
  File "/opt/stack/cinder/cinder/db/sqlalchemy/api.py", line 183, in wrapper
    return f(*args, **kwargs)
  File "/opt/stack/cinder/cinder/db/sqlalchemy/api.py", line 7074, in get_by_id
    return _GET_METHODS[model](context, id, *args, **kwargs)
  File "/opt/stack/cinder/cinder/db/sqlalchemy/api.py", line 183, in wrapper
    return f(*args, **kwargs)
  File "/opt/stack/cinder/cinder/db/sqlalchemy/api.py", line 3073, in snapshot_get
    return _snapshot_get(context, snapshot_id)
  File "/opt/stack/cinder/cinder/db/sqlalchemy/api.py", line 183, in wrapper
    return f(*args, **kwargs)
  File "/opt/stack/cinder/cinder/db/sqlalchemy/api.py", line 3066, in _snapshot_get
    raise exception.SnapshotNotFound(snapshot_id=snapshot_id)
SnapshotNotFound: Snapshot 2609e615-323f-4927-923f-028848d45940 could not be found.

The root reason of this failure is that the clone image is based on **snapshot** but not **snapshot-volume**.

Another impact of this bug is:
If we already make some data change on a snapshot-volume, then we export this snapshot-volume to image,
this image will lose all change data, beacause this image is based on **snapshot** but not **snapshot-volume**.

[1] https://docs.openstack.org/cinder/latest/admin/blockstorage-volume-backed-image.html

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

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

Changed in cinder:
assignee: nobody → Yikun Jiang (yikunkero)
status: New → In Progress
Jay Bryant (jsbryant)
Changed in cinder:
importance: Undecided → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to cinder (master)

Reviewed: https://review.openstack.org/606235
Committed: https://git.openstack.org/cgit/openstack/cinder/commit/?id=9d43d22bf3c887542e475a212f662e73ad44e65e
Submitter: Zuul
Branch: master

commit 9d43d22bf3c887542e475a212f662e73ad44e65e
Author: Yikun Jiang <email address hidden>
Date: Sat Sep 29 09:44:22 2018 +0800

    Fix unexpected behavior in _clone_image_volume

    Current, if we upload a snapshot-volume to image, then create
    a new volume from this image, this new volume is created from
    original snapshot rather than snapshot-volume.

    That means if we already make some data change on a
    snapshot-volume, then we export this snapshot-volume to image,
    this image will lose all change data.

    This patch try to fix this, we skip the "snapshot_id" and
    "source_volid" when we create tmp image volume.

    Closes-bug: 1795098

    Change-Id: Icf0dadc1ce4d008ff437ca5dcde1817d2e560e44

Changed in cinder:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to cinder (stable/rocky)

Fix proposed to branch: stable/rocky
Review: https://review.openstack.org/639755

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/cinder 14.0.0.0rc1

This issue was fixed in the openstack/cinder 14.0.0.0rc1 release candidate.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to cinder (stable/rocky)

Reviewed: https://review.openstack.org/639755
Committed: https://git.openstack.org/cgit/openstack/cinder/commit/?id=1a8021a281c9ac2bd7e3acd25ba14ed3c70d8029
Submitter: Zuul
Branch: stable/rocky

commit 1a8021a281c9ac2bd7e3acd25ba14ed3c70d8029
Author: Yikun Jiang <email address hidden>
Date: Sat Sep 29 09:44:22 2018 +0800

    Fix unexpected behavior in _clone_image_volume

    Current, if we upload a snapshot-volume to image, then create
    a new volume from this image, this new volume is created from
    original snapshot rather than snapshot-volume.

    That means if we already make some data change on a
    snapshot-volume, then we export this snapshot-volume to image,
    this image will lose all change data.

    This patch try to fix this, we skip the "snapshot_id" and
    "source_volid" when we create tmp image volume.

    Closes-bug: 1795098

    Change-Id: Icf0dadc1ce4d008ff437ca5dcde1817d2e560e44
    (cherry picked from commit 9d43d22bf3c887542e475a212f662e73ad44e65e)

tags: added: in-stable-rocky
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/cinder 13.0.5

This issue was fixed in the openstack/cinder 13.0.5 release.

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.