Cinder did not update '_name_id' and 'provider_location' for drivers if driver implements update_migrated_volume

Bug #1487952 reported by Peter Wang
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Cinder
Fix Released
Undecided
Peter Wang

Bug Description

Currently, Cinder will update '_name_id' and 'provider_location' when drivers don't implement update_migrated_volume
when host-assisted migration has done.

when drivers implemented 'update_migated_volume' but do not return {'_name_id': 'xxxx', 'provider_location': 'xxxxx'},
Cinder will not copy '_name_id' and 'provider_location' to the migrated volume, fields of _name_id and provider_location in migrated volume are left empty.

Above behavior seems break previous host-assisted migration behavior.

since '_name_id' and 'provider_location' are critical for drivers to locate the underlying LUNs in the back-ends, and for keeping back-port compatiblity, we need to copy theses values anyway, and in this way.

here is the code snippets from cinder/volume/manager.py

    def update_migrated_volume(self, ctxt, volume, new_volume,
                               volume_status):
        """Finalize migration process on backend device."""
        model_update = None
        try:
            model_update = self.driver.update_migrated_volume(ctxt,
                                                              volume,
                                                              new_volume,
                                                              volume_status)
        except NotImplementedError:
            # If update_migrated_volume is not implemented for the driver,
            # _name_id and provider_location will be set with the values
            # from new_volume.
            model_update = {'_name_id': new_volume['_name_id'] or
                            new_volume['id'],
                            'provider_location':
                            new_volume['provider_location']}
        if model_update:
            self.db.volume_update(ctxt.elevated(), volume['id'],
                                  model_update)
            # Swap keys that were changed in the source so we keep their values
            # in the temporary volume's DB record.
            model_update_new = {key: volume[key]
                                for key in model_update.iterkeys()}
            self.db.volume_update(ctxt.elevated(), new_volume['id'],
                                  model_update_new)

this behavior is introduced by :

https://review.openstack.org/#/c/180873/

Another problems of above code snippet is
if driver return 'metadata' or 'admin_metadata' to update meta table

            model_update_new = {key: volume[key]
                                for key in model_update.iterkeys()}
will throw exception in attached log since volume does not have 'metadata' or 'admin_metadata'

I am going to provide a fix for this soon.

Peter Wang (peter.wang)
Changed in cinder:
assignee: nobody → Peter Wang (peter.wang)
Peter Wang (peter.wang)
summary: - Cinder did not update '_name_id' and 'provider_location' for drivers
+ Cinder did not update '_name_id' and 'provider_location' for drivers if
+ driver implements update_migrated_volume
Revision history for this message
Peter Wang (peter.wang) wrote :
description: updated
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/217522
Committed: https://git.openstack.org/cgit/openstack/cinder/commit/?id=20ac9cac7284f009929cfd6e5ce79f34bccffce8
Submitter: Jenkins
Branch: master

commit 20ac9cac7284f009929cfd6e5ce79f34bccffce8
Author: peter_wang <email address hidden>
Date: Fri Aug 21 01:33:44 2015 -0400

    Fix issue of volume after host-assisted migration

    In host-assisted migration, Cinder framework currently doesn't
    update name_id and provider_location when the driver doesn't provide
    name_id or provider_location in update_migrated_volume

    This changes previous Cinder behavior which will update name_id and
    provider_location anyway. Any operation against this volume will not
    be successful; for example, volume deletion cannot delete it's
    underlying LUN.

    This fix will update name_id and provider_location if driver doesn't
    return them.

    Closes-Bug: #1487952
    Change-Id: Ice72fc792f0ea8909c027e6df99cff9bbeef5e48

Changed in cinder:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in cinder:
milestone: none → liberty-rc1
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in cinder:
milestone: liberty-rc1 → 7.0.0
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/259937

Revision history for this message
Peter Wang (peter.wang) wrote :

Please ignore #3, Thanks

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.