2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-26 03:19:48 +00:00

Cleaner handling of invalid names in restore attempt

Detect problems ahead af time and more cleanly print a message.
This commit is contained in:
Jarrod Johnson 2018-05-17 14:40:19 -04:00
parent d6b7c536d5
commit 5dddae0ebf
2 changed files with 12 additions and 1 deletions

View File

@ -51,7 +51,11 @@ if args[0] == 'restore':
if pid is not None:
print("Confluent is running, must shut down to restore db")
sys.exit(1)
cfm.restore_db_from_directory(dumpdir, options.password)
try:
cfm.restore_db_from_directory(dumpdir, options.password)
except Exception as e:
print(str(e))
sys.exit(1)
elif args[0] == 'dump':
if options.password is None and not (options.unprotected or options.redact):
print("Must indicate a password to protect or -u to opt opt of "

View File

@ -1415,6 +1415,13 @@ class ConfigManager(object):
tmpconfig[confarea] = {}
for element in dumpdata[confarea]:
newelement = copy.deepcopy(dumpdata[confarea][element])
try:
noderange._parser.parseString(
'({0})'.format(element)).asList()
except noderange.pp.ParseException as pe:
raise ValueError(
'"{0}" is not a supported name, it must be renamed or '
'removed from backup to restore'.format(element))
for attribute in dumpdata[confarea][element]:
if newelement[attribute] == '*REDACTED*':
raise Exception(