Updated tooz lock name

This changes the scope tooz lock name in order to also take into account the
scope_key, the fetcher and the collector.

Story: 2005699
Task: 31021
Change-Id: Id4a8e327a91d9f653f9d53e29817bbce9816be3b
This commit is contained in:
Luka Peschke 2019-05-16 14:49:46 +02:00
parent b42c3a1798
commit a9f9be84dc

View File

@ -282,8 +282,12 @@ class Orchestrator(cotyledon.Service):
self.coord.start(start_heart=True)
def _lock(self, tenant_id):
lock_name = b"cloudkitty-" + str(tenant_id).encode('ascii')
return self.coord.get_lock(lock_name)
name = b"cloudkitty-" \
+ str(tenant_id + '-').encode('ascii') \
+ str(CONF.collect.collector + '-').encode('ascii') \
+ str(CONF.fetcher.backend + '-').encode('ascii') \
+ str(CONF.collect.scope_key).encode('ascii')
return name, self.coord.get_lock(name)
def _init_messaging(self):
target = oslo_messaging.Target(topic='cloudkitty',
@ -318,8 +322,17 @@ class Orchestrator(cotyledon.Service):
for tenant_id in self.tenants:
lock = self._lock(tenant_id)
lock_name, lock = self._lock(tenant_id)
LOG.debug(
'[Worker: {w}] Trying to acquire lock "{l}" ...'.format(
w=self._worker_id, l=lock_name)
)
if lock.acquire(blocking=False):
LOG.debug(
'[Worker: {w}] Acquired lock "{l}" ...'.format(
w=self._worker_id, l=lock_name)
)
LOG.debug('Acquired lock "{}".'.format(lock_name))
state = self._check_state(tenant_id)
if state:
worker = Worker(