[API Replay] Fail fast by default

Add a --ignore-errors CLI options to preserve the current behaviour
where API replays completes all operations and then reports errors.

When --ignore-errors is not set, API replay will fail and quit
at the first error.

Also fixes help string for enable_barbican option.

Change-Id: Ic2f6f89060f26292b017b2b3defb488452ec1cb7
This commit is contained in:
Salvatore Orlando 2021-10-25 23:58:54 -07:00 committed by Salvatore Orlando
parent 2cb24bf2c6
commit 819a4f9364
2 changed files with 14 additions and 4 deletions

View File

@ -64,7 +64,8 @@ class ApiReplayCli(object):
vif_ids_map=args.vif_ids_map, vif_ids_map=args.vif_ids_map,
logfile=args.logfile, logfile=args.logfile,
max_retry=args.max_retry, max_retry=args.max_retry,
cert_file=args.cert_file) cert_file=args.cert_file,
ignore_errors=args.ignore_errors)
def _setup_argparse(self): def _setup_argparse(self):
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
@ -206,7 +207,12 @@ class ApiReplayCli(object):
"--enable-barbican", "--enable-barbican",
default=False, default=False,
action='store_true', action='store_true',
help="Meh") help="Enable barbican connection for Octavia certificates")
parser.add_argument(
"--ignore-errors",
action='store_true',
default=False,
help="Continuing executing API replay even upon errors")
# NOTE: this will return an error message if any of the # NOTE: this will return an error message if any of the
# require options are missing. # require options are missing.

View File

@ -60,7 +60,7 @@ class ApiReplayClient(utils.PrepareObjectForMigration):
octavia_os_tenant_name, octavia_os_tenant_domain_id, octavia_os_tenant_name, octavia_os_tenant_domain_id,
octavia_os_password, octavia_os_auth_url, octavia_os_password, octavia_os_auth_url,
neutron_conf, ext_net_map, net_vni_map, int_vni_map, neutron_conf, ext_net_map, net_vni_map, int_vni_map,
vif_ids_map, logfile, max_retry, cert_file): vif_ids_map, logfile, max_retry, cert_file, ignore_errors):
# Init config and logging # Init config and logging
if neutron_conf: if neutron_conf:
@ -170,6 +170,7 @@ class ApiReplayClient(utils.PrepareObjectForMigration):
self.n_errors = 0 self.n_errors = 0
self.errors = [] self.errors = []
self.ignore_errors = ignore_errors
LOG.info("Starting NSX migration to %s.", self.dest_plugin) LOG.info("Starting NSX migration to %s.", self.dest_plugin)
# Migrate all the objects # Migrate all the objects
@ -279,8 +280,11 @@ class ApiReplayClient(utils.PrepareObjectForMigration):
return False return False
def add_error(self, msg): def add_error(self, msg):
self.n_errors = self.n_errors + 1
LOG.error(msg) LOG.error(msg)
if not self.ignore_errors:
LOG.error("Error occurred during API replay: exiting")
sys.exit(1)
self.n_errors = self.n_errors + 1
self.errors.append(msg) self.errors.append(msg)
def migrate_quotas(self): def migrate_quotas(self):