Don't populate resources for not-yet-migrated inst
Per the referenced bug, it is possible for update_available_resource to race with a migration such that the migration record exists, but the instance's migration context doesn't. In such cases we shouldn't try to track the instance's assigned resources on this host (because there aren't any yet). Change-Id: I69f99adfa8c91b50086052ca1b15c55e86ed614d Closes-Bug: #1849165
This commit is contained in:
parent
761be5d0cb
commit
80385a22ee
|
@ -477,6 +477,10 @@ class ResourceTracker(object):
|
||||||
# Get resources assigned to migrations
|
# Get resources assigned to migrations
|
||||||
for mig in self.tracked_migrations.values():
|
for mig in self.tracked_migrations.values():
|
||||||
mig_ctx = mig.instance.migration_context
|
mig_ctx = mig.instance.migration_context
|
||||||
|
# We might have a migration whose instance hasn't arrived here yet.
|
||||||
|
# Ignore it.
|
||||||
|
if not mig_ctx:
|
||||||
|
continue
|
||||||
if mig.source_compute == self.host and 'old_resources' in mig_ctx:
|
if mig.source_compute == self.host and 'old_resources' in mig_ctx:
|
||||||
resources.extend(mig_ctx.old_resources or [])
|
resources.extend(mig_ctx.old_resources or [])
|
||||||
if mig.dest_compute == self.host and 'new_resources' in mig_ctx:
|
if mig.dest_compute == self.host and 'new_resources' in mig_ctx:
|
||||||
|
|
|
@ -58,9 +58,9 @@ class UpdateResourceMigrationRaceTest(
|
||||||
'OS-EXT-STS:task_state': None,
|
'OS-EXT-STS:task_state': None,
|
||||||
'status': 'ACTIVE'})
|
'status': 'ACTIVE'})
|
||||||
|
|
||||||
# FIXME(efried): This is bug 1849165 where
|
# NOTE(efried): This was bug 1849165 where
|
||||||
# _populate_assigned_resources raises a TypeError because it tries
|
# _populate_assigned_resources raised a TypeError because it tried
|
||||||
# to access the instance's migration_context before that exists.
|
# to access the instance's migration_context before that existed.
|
||||||
self.assertIn(
|
self.assertNotIn(
|
||||||
"TypeError: argument of type 'NoneType' is not iterable",
|
"TypeError: argument of type 'NoneType' is not iterable",
|
||||||
self.stdlog.logger.output)
|
self.stdlog.logger.output)
|
||||||
|
|
Loading…
Reference in New Issue