Comment 1 for bug 1896463

Revision history for this message
Wonil Choi (wonil22) wrote :

Before saving instance with new host(destination host) in rebuild_instance(),

2931 def rebuild_instance(self, context, instance, orig_image_ref, image_ref,
2932 +--136 lines: injected_files, new_pass, orig_sys_metadata,-------------------------------------------------------------------
3068 instance.apply_migration_context()
3069 # NOTE (ndipanov): This save will now update the host and node
3070 # attributes making sure that next RT pass is consistent since
3071 # it will be based on the instance and not the migration DB
3072 # entry.
3073 instance.host = self.host
3074 instance.node = scheduled_node
3075 instance.save()
3076 instance.drop_migration_context()
3077
3078 # NOTE (ndipanov): Mark the migration as done only after we
3079 # mark the instance as belonging to this host.
3080 self._set_migration_status(migration, 'done')

resource tracker(RT) may get instances by get_by_host_and_node()

 743 def _update_available_resource(self, context, resources):
 744 +-- 12 lines: # initialize the compute node object, creating it--------------------------------------------------------------
 756 # Grab all instances assigned to this node:
 757 instances = objects.InstanceList.get_by_host_and_node(

and after saving instance host(destination host) and set the migration status to 'done', RT get the migrations.

 767 # Grab all in-progress migrations:
 768 migrations = objects.MigrationList.get_in_progress_by_host_and_node(
 769 context, self.host, nodename)
 770

After these situation, pci devices are free by clean_usage()

 789 self.pci_tracker.clean_usage(instances, migrations, orphans)