@@ -133,24 +133,35 @@ def test_node_rebalance_deleted_compute_node_race(self):
133
133
# Mock out the compute node query to simulate a race condition where
134
134
# the list includes an orphan compute node that is newly owned by
135
135
# host_b by the time host_a attempts to delete it.
136
- # FIXME(mgoddard): Ideally host_a would not delete a node that does not
137
- # belong to it. See https://bugs.launchpad.net/nova/+bug/1853009.
138
136
with mock .patch (
139
137
'nova.compute.manager.ComputeManager._get_compute_nodes_in_db'
140
138
) as mock_get :
141
139
mock_get .return_value = [cn ]
142
140
host_a .manager .update_available_resource (self .ctxt )
143
141
144
- # Verify that the node was deleted.
142
+ # Verify that the node was almost deleted, but was saved by the host
143
+ # check
145
144
self .assertIn (
146
145
'Deleting orphan compute node %s hypervisor host '
147
146
'is fake-node, nodes are' % cn .id ,
148
147
self .stdlog .logger .output )
149
- hypervisors = self .api .api_get (
150
- '/os-hypervisors/detail' ).body ['hypervisors' ]
151
- self .assertEqual (0 , len (hypervisors ), hypervisors )
148
+ self .assertIn (
149
+ 'Ignoring failure to delete orphan compute node %s on '
150
+ 'hypervisor host fake-node' % cn .id ,
151
+ self .stdlog .logger .output )
152
+ self ._assert_hypervisor_api (self .nodename , 'host_b' )
152
153
rps = self ._get_all_providers ()
153
- self .assertEqual (0 , len (rps ), rps )
154
+ self .assertEqual (1 , len (rps ), rps )
155
+ self .assertEqual (self .nodename , rps [0 ]['name' ])
156
+
157
+ # Simulate deletion of an orphan by host_a. It shouldn't happen
158
+ # anymore, but let's assume it already did.
159
+ cn = objects .ComputeNode .get_by_host_and_nodename (
160
+ self .ctxt , 'host_b' , self .nodename )
161
+ cn .destroy ()
162
+ host_a .manager .rt .remove_node (cn .hypervisor_hostname )
163
+ host_a .manager .reportclient .delete_resource_provider (
164
+ self .ctxt , cn , cascade = True )
154
165
155
166
# host_b[3]: Should recreate compute node and resource provider.
156
167
# FIXME(mgoddard): Resource provider not recreated here, due to
0 commit comments