2
0
mirror of https://github.com/xcat2/confluent.git synced 2025-01-28 03:48:35 +00:00

Move hashing before collective

This results in consistent hash
using the initial random, rather
than equivalent, but odd looking
crypted hashes across collective.
This commit is contained in:
Jarrod Johnson 2020-04-16 20:51:14 -04:00
parent 4fb7924015
commit 198b26245b

View File

@ -1675,6 +1675,17 @@ class ConfigManager(object):
self.set_group_attributes(attribmap, autocreate=True)
def set_group_attributes(self, attribmap, autocreate=False):
for group in attribmap:
curr = attribmap[group]
for attrib in curr:
if attrib.startswith('crypted.'):
if not isinstance(curr[attrib], dict):
curr[attrib] = {'value': curr[attrib]}
if 'hashvalue' not in curr[attrib]:
curr[attrib]['hashvalue'] = hashcrypt_value(
curr[attrib]['value'])
if 'value' in curr[attrib]:
del curr[attrib]['value']
if cfgleader: # currently config slave to another
return exec_on_leader('_rpc_master_set_group_attributes',
self.tenant, attribmap, autocreate)
@ -2083,6 +2094,17 @@ class ConfigManager(object):
def set_node_attributes(self, attribmap, autocreate=False):
for node in attribmap:
curr = attribmap[node]
for attrib in curr:
if attrib.startswith('crypted.'):
if not isinstance(curr[attrib], dict):
curr[attrib] = {'value': curr[attrib]}
if 'hashvalue' not in curr[attrib]:
curr[attrib]['hashvalue'] = hashcrypt_value(
curr[attrib]['value'])
if 'value' in curr[attrib]:
del curr[attrib]['value']
if cfgleader: # currently config slave to another
return exec_on_leader('_rpc_master_set_node_attributes',
self.tenant, attribmap, autocreate)