create volume with group_id , volume status will always "creating" if there is driver exception

Bug #1729215 reported by yixuan zhang
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Cinder
Fix Released
Undecided
yixuan zhang

Bug Description

Test step:
1.Since creating a volume with a replication group id may cause some problem in our cinder driver.
We tried to disable this function in our cinder driver.

2.After we added and exception in cinder driver,
We Tried to create a volume with group id
cinder create --group_id *** --volume_type *** 1

3.There is an exception in our cinder driver as expected.

4.Check the volume status, it is always "creating", the volume status can't update to "error".

5.There is an exception below:

      File "cinder/objects/volume.py", line 354, in save
        action='save', reason=_('consistencygroup changed'))
    ObjectActionError: Object action save failed because: consistency group changed

Analyse:
1. cinder/volume/flows/manager/create_volume.py
The group was assigned to the consistency group before create_raw_volume:

        if volume.group_id:
            volume.consistencygroup_id = volume.group_id
            cg = consistencygroup.ConsistencyGroup()
            cg.from_group(volume.group)
            volume.consistencygroup = cg

2.The _clean_cg_in_volume was not invoked if there is an exception in cinder driver:

    def _create_raw_volume(self, volume, **kwargs):
        ret = self.driver.create_volume(volume)
        self._cleanup_cg_in_volume(volume)
        return ret

3. Then it will do revert. when check updates, it found consistency group was in the updates.
cinder/objects/volume.py

    def save(self):
        updates = self.cinder_obj_get_changes()
        if updates:
            # NOTE(xyang): Allow this to pass if 'consistencygroup' is
            # set to None. This is to support backward compatibility.
            # Also remove 'consistencygroup' from updates because
            # consistencygroup is the name of a relationship in the ORM
            # Volume model, so SQLA tries to do some kind of update of
            # the foreign key based on the provided updates if
            # 'consistencygroup' is in updates.
            if updates.pop('consistencygroup', None):
                raise exception.ObjectActionError(
                    action='save', reason=_('consistencygroup changed'))

Fix proposal:
invoke _clean_cg_in_volume even when there is an exception in cinder driver:

   def _create_raw_volume(self, volume, **kwargs):
        try:
            ret = self.driver.create_volume(volume)
        except exception.CinderException:
            with excutils.save_and_reraise_exception():
                self._cleanup_cg_in_volume(volume)
        self._cleanup_cg_in_volume(volume)
        return ret

create_from_snapshot and create_volume_from_source_volume have the same issue.

yixuan zhang (yixuan-z)
Changed in cinder:
assignee: nobody → yixuan zhang (yixuan-z)
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/516882

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

Reviewed: https://review.openstack.org/516882
Committed: https://git.openstack.org/cgit/openstack/cinder/commit/?id=90184b7a1df436dcb4517cc677b22fa9bb0d40a9
Submitter: Zuul
Branch: master

commit 90184b7a1df436dcb4517cc677b22fa9bb0d40a9
Author: yixuanzhang <email address hidden>
Date: Wed Nov 1 15:09:23 2017 +0800

    create_volume: cleanup consistencygroup when driver exception

    Creating a volume with group_id, if driver raises an exception,
    the volume status will always be “creating”.The status doesn’t
    update to “error” because “ObjectActionError: consistency group
    changed”
    This patch fixes the issue by invoking _cleanup_cg_in_volume
    when driver raises an exception.

    Change-Id: Ibbb077f66b41c359b50fff053aa183382c2cde14
    Closes-Bug: #1729215

Changed in cinder:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/cinder 12.0.0.0b2

This issue was fixed in the openstack/cinder 12.0.0.0b2 development milestone.

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.