@@ -82,9 +82,6 @@ def test_node_rebalance_deleted_compute_node_race(self):
8282 # Now run the update_available_resource periodic to register fake-node
8383 # and have it managed by host_b. This will also detect the "host_b"
8484 # node as orphaned and delete it along with its resource provider.
85- cn_host_b_node = objects .ComputeNode .get_by_host_and_nodename (
86- self .ctxt , 'host_b' , 'host_b' ,
87- )
8885
8986 # host_b[1]: Finds no compute record in RT. Tries to create one
9087 # (_init_compute_node).
@@ -93,10 +90,6 @@ def test_node_rebalance_deleted_compute_node_race(self):
9390 # update for this node. See
9491 # https://bugs.launchpad.net/nova/+bug/1853159.
9592 host_b .manager .update_available_resource (self .ctxt )
96- self .assertIn (
97- 'Deleting orphan compute node %s hypervisor host '
98- 'is host_b, nodes are' % cn_host_b_node .id ,
99- self .stdlog .logger .output )
10093 self ._assert_hypervisor_api (self .nodename , expected_host = 'host_b' )
10194 # There should only be one resource provider (fake-node).
10295 original_rps = self ._get_all_providers ()
@@ -160,21 +153,17 @@ def test_node_rebalance_deleted_compute_node_race(self):
160153 self .assertEqual (0 , len (rps ), rps )
161154
162155 # host_b[3]: Should recreate compute node and resource provider.
163- # FIXME(mgoddard): Compute node not recreated here, because it is
164- # already in RT.compute_nodes. See
165- # https://bugs.launchpad.net/nova/+bug/1853009.
166156 # FIXME(mgoddard): Resource provider not recreated here, because it
167157 # exists in the provider tree. See
168158 # https://bugs.launchpad.net/nova/+bug/1841481.
169159 host_b .manager .update_available_resource (self .ctxt )
170160
171- # Verify that the node was not recreated.
172- hypervisors = self .api .api_get (
173- '/os-hypervisors/detail' ).body ['hypervisors' ]
174- self .assertEqual (0 , len (hypervisors ), hypervisors )
161+ # Verify that the node was recreated.
162+ self ._assert_hypervisor_api (self .nodename , 'host_b' )
175163
176- # But the compute node exists in the RT.
177- self .assertIn (self .nodename , host_b .manager .rt .compute_nodes )
164+ # But due to https://bugs.launchpad.net/nova/+bug/1853159 the compute
165+ # node is not cached in the RT.
166+ self .assertNotIn (self .nodename , host_b .manager .rt .compute_nodes )
178167
179168 # There is no RP.
180169 rps = self ._get_all_providers ()
@@ -184,6 +173,27 @@ def test_node_rebalance_deleted_compute_node_race(self):
184173 self .assertTrue (host_b .manager .rt .reportclient ._provider_tree .exists (
185174 self .nodename ))
186175
176+ # host_b[1]: Should add compute node to RT cache and recreate resource
177+ # provider.
178+ # FIXME(mgoddard): Resource provider not recreated here, because it
179+ # exists in the provider tree. See
180+ # https://bugs.launchpad.net/nova/+bug/1841481.
181+ host_b .manager .update_available_resource (self .ctxt )
182+
183+ # Verify that the node still exists.
184+ self ._assert_hypervisor_api (self .nodename , 'host_b' )
185+
186+ # And it is now in the RT cache.
187+ self .assertIn (self .nodename , host_b .manager .rt .compute_nodes )
188+
189+ # There is still no RP.
190+ rps = self ._get_all_providers ()
191+ self .assertEqual (0 , len (rps ), rps )
192+
193+ # But the RP it exists in the provider tree.
194+ self .assertTrue (host_b .manager .rt .reportclient ._provider_tree .exists (
195+ self .nodename ))
196+
187197 # This fails due to the lack of a resource provider.
188198 self .assertIn (
189199 'Skipping removal of allocations for deleted instances' ,
0 commit comments