<div dir="ltr">Yes, this is a race.<div><br></div><div>However, it's my understanding that this is 'ok'. The resource tracker doesn't claim to be 100% accurate at all times, right? Otherwise why would it update itself in a period task in the first place. It's my understanding that the resource tracker is basically a best effort cache, and that scheduling decisions can still fail at the host. The resource tracker will fix itself next time it runs via its periodic task.</div><div><br></div><div>Matt (not a scheduler person)</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jun 9, 2016 at 10:41 PM, Chris Friesen <span dir="ltr"><<a href="mailto:chris.friesen@windriver.com" target="_blank">chris.friesen@windriver.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I'm wondering if we might have a race between live migration and the resource audit.  I've included a few people on the receiver list that have worked directly with this code in the past.<br>
<br>
In _update_available_resource() we have code that looks like this:<br>
<br>
instances = objects.InstanceList.get_by_host_and_node()<br>
self._update_usage_from_instances()<br>
migrations = objects.MigrationList.get_in_progress_by_host_and_node()<br>
self._update_usage_from_migrations()<br>
<br>
<br>
In post_live_migration_at_destination() we do this (updating the host and node as well as the task state):<br>
            instance.host = self.host<br>
            instance.task_state = None<br>
            instance.node = node_name<br>
            instance.save(expected_task_state=task_states.MIGRATING)<br>
<br>
<br>
And in _post_live_migration() we update the migration status to "completed":<br>
        if migrate_data and migrate_data.get('migration'):<br>
            migrate_data['migration'].status = 'completed'<br>
            migrate_data['migration'].save()<br>
<br>
<br>
Both of the latter routines are not serialized by the COMPUTE_RESOURCE_SEMAPHORE, so they can race relative to the code in _update_available_resource().<br>
<br>
<br>
I'm wondering if we can have a situation like this:<br>
<br>
1) migration in progress<br>
2) We start running _update_available_resource() on destination, and we call instances = objects.InstanceList.get_by_host_and_node().  This will not return the migration, because it is not yet on the destination host.<br>
3) The migration completes and we call post_live_migration_at_destination(), which sets the host/node/task_state on the instance.<br>
4) In _update_available_resource() on destination, we call migrations = objects.MigrationList.get_in_progress_by_host_and_node().  This will return the migration for the instance in question, but when we run self._update_usage_from_migrations() the uuid will not be in "instances" and so we will use the instance from the newly-queried migration.  We will then ignore the instance because it is not in a "migrating" state.<br>
<br>
Am I imagining things, or is there a race here?  If so, the negative effects would be that the resources of the migrating instance would be "lost", allowing a newly-scheduled instance to claim the same resources (PCI devices, pinned CPUs, etc.)<br>
<br>
Chris<br>
<br>
__________________________________________________________________________<br>
OpenStack Development Mailing List (not for usage questions)<br>
Unsubscribe: <a href="http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe" rel="noreferrer" target="_blank">OpenStack-dev-request@lists.openstack.org?subject:unsubscribe</a><br>
<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" rel="noreferrer" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><span style="font-size:12.8px">Matthew Booth</span><br></div><div>Red Hat Engineering, Virtualisation Team</div><div><br></div><div>Phone: +442070094448 (UK)</div><div><br></div></div></div></div></div>
</div>