diff --git a/nova/cmd/status.py b/nova/cmd/status.py index 2cde619bcdf9..896d18c559ca 100644 --- a/nova/cmd/status.py +++ b/nova/cmd/status.py @@ -128,7 +128,8 @@ class UpgradeCommands(object): # released. meta = MetaData(bind=db_session.get_engine(context=context)) compute_nodes = Table('compute_nodes', meta, autoload=True) - return select([sqlfunc.count()]).select_from(compute_nodes).scalar() + return select([sqlfunc.count()]).select_from(compute_nodes).where( + compute_nodes.c.deleted == 0).scalar() def _check_cellsv2(self): """Checks to see if cells v2 has been setup. diff --git a/nova/tests/unit/cmd/test_status.py b/nova/tests/unit/cmd/test_status.py index c1923ee40f87..7522df649932 100644 --- a/nova/tests/unit/cmd/test_status.py +++ b/nova/tests/unit/cmd/test_status.py @@ -650,6 +650,22 @@ class TestUpgradeCheckResourceProviders(test.NoDBTestCase): cpu_info='{"arch": "x86_64"}') cn.create() + # create a deleted compute node record (shouldn't count) + cn2 = objects.ComputeNode( + context=ctxt, + deleted=1, + host='fakehost', + vcpus=4, + memory_mb=8 * 1024, + local_gb=40, + vcpus_used=2, + memory_mb_used=2 * 1024, + local_gb_used=10, + hypervisor_type='fake', + hypervisor_version=1, + cpu_info='{"arch": "x86_64"}') + cn2.create() + # create a single resource provider with some VCPU inventory self._create_resource_provider(FAKE_VCPU_INVENTORY) # create an externally shared IP allocation pool resource provider