Fix up some bugs in kv handling
This commit is contained in:
parent
2fda346f9b
commit
b6eeb5c264
|
@ -41,7 +41,11 @@ def writedata(zk_conn, kv):
|
||||||
zk_transaction = zk_conn.transaction()
|
zk_transaction = zk_conn.transaction()
|
||||||
|
|
||||||
# Proceed one KV pair at a time
|
# Proceed one KV pair at a time
|
||||||
for key, data in kv.items():
|
for key in sorted(kv):
|
||||||
|
data = kv[key]
|
||||||
|
if not data:
|
||||||
|
data = ''
|
||||||
|
|
||||||
# Check if this key already exists or not
|
# Check if this key already exists or not
|
||||||
if not zk_conn.exists(key):
|
if not zk_conn.exists(key):
|
||||||
# We're creating a new key
|
# We're creating a new key
|
||||||
|
@ -61,7 +65,7 @@ def writedata(zk_conn, kv):
|
||||||
try:
|
try:
|
||||||
zk_transaction.check(key, new_version)
|
zk_transaction.check(key, new_version)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
print('Zookeeper key "{}" does not match expected version'.format(first_key))
|
print('Zookeeper key "{}" does not match expected version'.format(key))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Commit the transaction
|
# Commit the transaction
|
||||||
|
|
Loading…
Reference in New Issue