From 5dddae0ebf4dedc91e1452420005b1ecae418ba9 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 17 May 2018 14:40:19 -0400 Subject: [PATCH] Cleaner handling of invalid names in restore attempt Detect problems ahead af time and more cleanly print a message. --- confluent_server/bin/confluentdbutil | 6 +++++- confluent_server/confluent/config/configmanager.py | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/confluent_server/bin/confluentdbutil b/confluent_server/bin/confluentdbutil index e5acb419..cce5a371 100755 --- a/confluent_server/bin/confluentdbutil +++ b/confluent_server/bin/confluentdbutil @@ -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 " diff --git a/confluent_server/confluent/config/configmanager.py b/confluent_server/confluent/config/configmanager.py index 9d2087af..deac7284 100644 --- a/confluent_server/confluent/config/configmanager.py +++ b/confluent_server/confluent/config/configmanager.py @@ -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(