Browse Source

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

changes/91/642591/46
Zuul 2 weeks ago
parent
commit
1cd5563f2d
2 changed files with 16 additions and 6 deletions
  1. +7
    -6
      nova/db/sqlalchemy/api.py
  2. +9
    -0
      nova/tests/unit/db/test_db_api.py

+ 7
- 6
nova/db/sqlalchemy/api.py View File

@@ -397,12 +397,13 @@ def service_destroy(context, service_id):
filter_by(id=service_id).\
soft_delete(synchronize_session=False)

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


@pick_context_manager_reader

+ 9
- 0
nova/tests/unit/db/test_db_api.py View File

@@ -3471,6 +3471,15 @@ class ServiceTestCase(test.TestCase, ModelsObjectComparatorMixin):
self._assertEqualObjects(db.service_get(self.ctxt, service2['id']),
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):
service = self._create_service({})
new_values = {

Loading…
Cancel
Save