mirror of
https://github.com/xcat2/confluent.git
synced 2024-11-29 13:00:03 +00:00
Give a friendlier message on restore of redact DB
A redacted dump will not have a keys.json file, which is natural. Replace 'file not found' with a message indicating the possibility of a redacted dump.
This commit is contained in:
parent
a288136a80
commit
c381fefc49
@ -1466,10 +1466,15 @@ def _dump_keys(password):
|
||||
|
||||
|
||||
def restore_db_from_directory(location, password):
|
||||
with open(os.path.join(location, 'keys.json'), 'r') as cfgfile:
|
||||
keydata = cfgfile.read()
|
||||
json.loads(keydata)
|
||||
_restore_keys(keydata, password)
|
||||
try:
|
||||
with open(os.path.join(location, 'keys.json'), 'r') as cfgfile:
|
||||
keydata = cfgfile.read()
|
||||
json.loads(keydata)
|
||||
_restore_keys(keydata, password)
|
||||
except IOError as e:
|
||||
if e.errno == 2:
|
||||
raise Exception("Cannot restore without keys, this may be a "
|
||||
"redacted dump")
|
||||
with open(os.path.join(location, 'main.json'), 'r') as cfgfile:
|
||||
cfgdata = cfgfile.read()
|
||||
ConfigManager(tenant=None)._load_from_json(cfgdata)
|
||||
|
Loading…
Reference in New Issue
Block a user