Fix: Including resources in None cluster

Cinder is incorrectly trying to add resources to a cluster even we are
not clustered, so we can see messages like:

  Including all resources from host host1@lvmdriver-1 in cluster None.

This happens when there is no service entry in the DB.

This patch fixes this an ensures we only try to include resources when
we are running a clustered service.

Closes-Bug: #1758022
Change-Id: Ief102a8eafd5175ff653ce29bd59b8f638ded112
This commit is contained in:
Gorka Eguileor 2018-03-21 17:47:32 +01:00
parent 1dbe0dcc03
commit 007c42ea54
2 changed files with 5 additions and 7 deletions

View File

@ -193,12 +193,11 @@ class Service(service.Service):
service_ref.save()
Service.service_id = service_ref.id
except exception.NotFound:
# We don't want to include cluster information on the service or
# create the cluster entry if we are upgrading.
self._create_service_ref(ctxt, manager_class.RPC_API_VERSION)
# We don't want to include resources in the cluster during the
# start while we are still doing the rolling upgrade.
self.added_to_cluster = True
# Service entry Entry didn't exist because it was manually removed
# or it's the first time running, to be on the safe side we say we
# were added if we are clustered.
self.added_to_cluster = bool(cluster)
self.report_interval = report_interval
self.periodic_interval = periodic_interval
@ -348,7 +347,6 @@ class Service(service.Service):
'rpc_current_version': rpc_version or self.manager.RPC_API_VERSION,
'object_current_version': objects_base.OBJ_VERSIONS.get_current(),
}
# If we are upgrading we have to ignore the cluster value
kwargs['cluster_name'] = self.cluster
service_ref = objects.Service(context=context, **kwargs)
service_ref.create()

View File

@ -389,7 +389,7 @@ class ServiceTestCase(test.TestCase):
app = service.Service.create(host=self.host,
binary=constants.VOLUME_BINARY,
cluster=None, topic=self.topic)
self._check_rpc_servers_and_init_host(app, True, None)
self._check_rpc_servers_and_init_host(app, False, None)
@mock.patch('cinder.objects.Service.get_minimum_obj_version')
def test_start_rpc_and_init_host_cluster(self, get_min_obj_mock):