Use a hash for lock names
Some tooz drivers do not support long lock names. For example, mysql locks must be 64 characters at most. This hashes the lock name in order to fix the lock name length. Change-Id: I5f058ea1197f5c2ba062a9bc0b67c509c8252852
This commit is contained in:
parent
cb540872e8
commit
90174720d9
|
@ -16,6 +16,7 @@
|
|||
# @author: Stéphane Albert
|
||||
#
|
||||
import decimal
|
||||
import hashlib
|
||||
import multiprocessing
|
||||
import random
|
||||
import sys
|
||||
|
@ -282,11 +283,12 @@ class Orchestrator(cotyledon.Service):
|
|||
self.coord.start(start_heart=True)
|
||||
|
||||
def _lock(self, tenant_id):
|
||||
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')
|
||||
name = hashlib.sha256(
|
||||
("cloudkitty-"
|
||||
+ str(tenant_id + '-')
|
||||
+ str(CONF.collect.collector + '-')
|
||||
+ str(CONF.fetcher.backend + '-')
|
||||
+ str(CONF.collect.scope_key)).encode('ascii')).hexdigest()
|
||||
return name, self.coord.get_lock(name)
|
||||
|
||||
def _init_messaging(self):
|
||||
|
@ -332,7 +334,6 @@ class Orchestrator(cotyledon.Service):
|
|||
'[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(
|
||||
|
|
Loading…
Reference in New Issue