Ensure validate writes a valid schema version

This commit is contained in:
Joshua Boniface 2021-06-14 21:23:16 -04:00
parent 5f11b3198b
commit 23318524b9
1 changed files with 6 additions and 3 deletions

View File

@ -751,7 +751,12 @@ class ZKSchema(object):
for key in self.keys(elem): for key in self.keys(elem):
kpath = f'{elem}.{key}' kpath = f'{elem}.{key}'
if not zkhandler.zk_conn.exists(self.path(kpath)): if not zkhandler.zk_conn.exists(self.path(kpath)):
zkhandler.zk_conn.create(self.path(kpath), ''.encode(zkhandler.encoding)) # Ensure that we create base.schema.version with the current valid version value
if kpath == 'base.schema.version':
data = str(self.version)
else:
data = ''
zkhandler.zk_conn.create(self.path(kpath), data.encode(zkhandler.encoding))
for elem in ['node', 'domain', 'network', 'osd', 'pool']: for elem in ['node', 'domain', 'network', 'osd', 'pool']:
# First read all the subelements of the key class # First read all the subelements of the key class
@ -806,8 +811,6 @@ class ZKSchema(object):
if not zkhandler.zk_conn.exists(self.path(kpath, child)): if not zkhandler.zk_conn.exists(self.path(kpath, child)):
zkhandler.zk_conn.create(self.path(kpath, child), ''.encode(zkhandler.encoding)) zkhandler.zk_conn.create(self.path(kpath, child), ''.encode(zkhandler.encoding))
zkhandler.zk_conn.create(self.path('base.schema.version'), self.version)
# Migrate key diffs # Migrate key diffs
def run_migrate(self, zkhandler, changes): def run_migrate(self, zkhandler, changes):
diff_add = changes['add'] diff_add = changes['add']