Merge "Don't delete compute node, when deleting service other than nova-compute"

This commit is contained in:
Zuul 2019-11-20 10:39:57 +00:00 committed by Gerrit Code Review
commit 1cd5563f2d
2 changed files with 16 additions and 6 deletions

View File

@ -397,12 +397,13 @@ def service_destroy(context, service_id):
filter_by(id=service_id).\ filter_by(id=service_id).\
soft_delete(synchronize_session=False) soft_delete(synchronize_session=False)
# TODO(sbauza): Remove the service_id filter in a later release if service.binary == 'nova-compute':
# once we are sure that all compute nodes report the host field # TODO(sbauza): Remove the service_id filter in a later release
model_query(context, models.ComputeNode).\ # once we are sure that all compute nodes report the host field
filter(or_(models.ComputeNode.service_id == service_id, model_query(context, models.ComputeNode).\
models.ComputeNode.host == service['host'])).\ filter(or_(models.ComputeNode.service_id == service_id,
soft_delete(synchronize_session=False) models.ComputeNode.host == service['host'])).\
soft_delete(synchronize_session=False)
@pick_context_manager_reader @pick_context_manager_reader

View File

@ -3471,6 +3471,15 @@ class ServiceTestCase(test.TestCase, ModelsObjectComparatorMixin):
self._assertEqualObjects(db.service_get(self.ctxt, service2['id']), self._assertEqualObjects(db.service_get(self.ctxt, service2['id']),
service2, ignored_keys=['compute_node']) service2, ignored_keys=['compute_node'])
def test_service_destroy_not_nova_compute(self):
service = self._create_service({'binary': 'nova-consoleauth',
'host': 'host1'})
compute_node_dict = _make_compute_node('host1', 'node1', 'kvm', None)
compute_node = db.compute_node_create(self.ctxt, compute_node_dict)
db.service_destroy(self.ctxt, service['id'])
# make sure ComputeHostNotFound is not raised
db.compute_node_get(self.ctxt, compute_node['id'])
def test_service_update(self): def test_service_update(self):
service = self._create_service({}) service = self._create_service({})
new_values = { new_values = {