live migration failed when using shared instance path with QCOW2

Bug #1346816 reported by Guangya Liu (Jay Lau)
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
In Progress
Undecided
Guangya Liu (Jay Lau)

Bug Description

Currently, live migration will be failed when using shared instance path with QCOW2 because of 'instance_dir' was not defined.

File "/usr/lib/python2.6/site-packages/oslo/messaging/rpc/dispatcher.py", line 123, in _do_dispatch
    result = getattr(endpoint, method)(ctxt, **new_args)

  File "/usr/lib/python2.6/site-packages/nova/compute/manager.py", line 410, in decorated_function
    return function(self, context, *args, **kwargs)

  File "/usr/lib/python2.6/site-packages/nova/exception.py", line 88, in wrapped
    payload)

  File "/usr/lib/python2.6/site-packages/nova/openstack/common/excutils.py", line 82, in __exit__
    six.reraise(self.type_, self.value, self.tb)

  File "/usr/lib/python2.6/site-packages/nova/exception.py", line 71, in wrapped
    return f(self, context, *args, **kw)

  File "/usr/lib/python2.6/site-packages/nova/compute/manager.py", line 323, in decorated_function
    kwargs['instance'], e, sys.exc_info())

  File "/usr/lib/python2.6/site-packages/nova/openstack/common/excutils.py", line 82, in __exit__
    six.reraise(self.type_, self.value, self.tb)

  File "/usr/lib/python2.6/site-packages/nova/compute/manager.py", line 311, in decorated_function
    return function(self, context, *args, **kwargs)

  File "/usr/lib/python2.6/site-packages/nova/compute/manager.py", line 4661, in pre_live_migration
    migrate_data)

  File "/usr/lib/python2.6/site-packages/nova/virt/libvirt/driver.py", line 4739, in pre_live_migration
    instance_dir, disk_info)

UnboundLocalError: local variable 'instance_dir' referenced before assignment
 to caller

Revision history for this message
Guangya Liu (Jay Lau) (jay-lau-513) wrote :

def pre_live_migration(self, context, instance, block_device_info,
                           network_info, disk_info, migrate_data=None):
        """Preparation live migration."""
        # Steps for volume backed instance live migration w/o shared storage.
        is_shared_block_storage = True
        is_shared_instance_path = True
        is_block_migration = True
        instance_relative_path = None
        if migrate_data:
            is_shared_block_storage = migrate_data.get(
                    'is_shared_block_storage', True)
            is_shared_instance_path = migrate_data.get(
                    'is_shared_instance_path', True)
            is_block_migration = migrate_data.get('block_migration', True)
            instance_relative_path = migrate_data.get('instance_relative_path')

        if not (is_shared_instance_path and is_shared_block_storage):
            # NOTE(mikal): live migration of instances using config drive is
            # not supported because of a bug in libvirt (read only devices
            # are not copied by libvirt). See bug/1246201
            if configdrive.required_by(instance):
                raise exception.NoLiveMigrationForConfigDriveInLibVirt()

        if not is_shared_instance_path:
            # NOTE(mikal): this doesn't use libvirt_utils.get_instance_path
            # because we are ensuring that the same instance directory name
            # is used as was at the source
            if instance_relative_path:
                instance_dir = os.path.join(CONF.instances_path,
                                            instance_relative_path) <<<<<<<<<<<<<<< instance_dir define here
            else:
                instance_dir = libvirt_utils.get_instance_path(instance) <<<<<<<<<<<<<<< instance_dir define here

            if os.path.exists(instance_dir):
                raise exception.DestinationDiskExists(path=instance_dir)
            os.mkdir(instance_dir)

        if not is_shared_block_storage:
            # Ensure images and backing files are present.
            self._create_images_and_backing(context, instance,
                                            instance_dir, disk_info) <<<<<<<<<<<<<<< using instance_dir here, but if I was using shared instance path, then instance_dir will be a undefined variable

Changed in nova:
assignee: nobody → Jay Lau (jay-lau-513)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

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

Changed in nova:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on nova (master)

Change abandoned by Jay Lau (<email address hidden>) on branch: master
Review: https://review.openstack.org/108618

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.