Fix incorrect handling of deletions in init

This commit is contained in:
Joshua Boniface 2021-06-29 18:41:02 -04:00
parent b05c93e260
commit 6adaf1f669
1 changed files with 8 additions and 4 deletions

View File

@ -267,11 +267,15 @@ def cluster_initialize(zkhandler, overwrite=False):
return False, 'ERROR: Cluster contains data and overwrite not set.' return False, 'ERROR: Cluster contains data and overwrite not set.'
if overwrite: if overwrite:
# Delete the existing keys; ignore any errors # Delete the existing keys
status = zkhandler.delete(zkhandler.schema.keys('base'), recursive=True) for key in zkhandler.schema.keys('base'):
if key == 'root':
# Don't delete the root key
continue
if not status: status = zkhandler.delete('base.{}'.format(key), recursive=True)
return False, 'ERROR: Failed to delete data in cluster; running nodes perhaps?' if not status:
return False, 'ERROR: Failed to delete data in cluster; running nodes perhaps?'
# Create the root keys # Create the root keys
zkhandler.schema.apply(zkhandler) zkhandler.schema.apply(zkhandler)