From e5b8060c08bb972a1960575749f240d7160bc114 Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Thu, 19 May 2016 11:00:17 -0700 Subject: [PATCH] Completed migrations are not "in progress" This fixes an issue where we consider migrations that have been completed as "in progress" by not filtering them out of the result set from migration_get_in_progress_by_host_and_node(). This adds that state to the list and adds a migration in that state to the test case. If it is not filtered, the counts won't line up and the test will fail. Change-Id: I7aafab9abdbfafe9479846f06068ba8a963d290a Closes-Bug: #1583720 --- nova/db/sqlalchemy/api.py | 2 +- nova/tests/unit/db/test_db_api.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index 416fad8b10..eea445977b 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -4857,7 +4857,7 @@ def migration_get_in_progress_by_host_and_node(context, host, node): models.Migration.dest_node == node))).\ filter(~models.Migration.status.in_(['accepted', 'confirmed', 'reverted', 'error', - 'failed'])).\ + 'failed', 'completed'])).\ options(joinedload_all('instance.system_metadata')).\ all() diff --git a/nova/tests/unit/db/test_db_api.py b/nova/tests/unit/db/test_db_api.py index bb7a2c9c4e..fe91740b4b 100644 --- a/nova/tests/unit/db/test_db_api.py +++ b/nova/tests/unit/db/test_db_api.py @@ -1334,6 +1334,7 @@ class MigrationTestCase(test.TestCase): self._create(status='error') self._create(status='failed') self._create(status='accepted') + self._create(status='completed') self._create(source_compute='host2', source_node='b', dest_compute='host1', dest_node='a') self._create(source_compute='host2', dest_compute='host3')