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,9 +267,13 @@ 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
status = zkhandler.delete('base.{}'.format(key), recursive=True)
if not status: if not status:
return False, 'ERROR: Failed to delete data in cluster; running nodes perhaps?' return False, 'ERROR: Failed to delete data in cluster; running nodes perhaps?'