From 819a4f93644b41650e3262f9eb5f7459334d5f23 Mon Sep 17 00:00:00 2001 From: Salvatore Orlando Date: Mon, 25 Oct 2021 23:58:54 -0700 Subject: [PATCH] [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 --- vmware_nsx/api_replay/cli.py | 10 ++++++++-- vmware_nsx/api_replay/client.py | 8 ++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/vmware_nsx/api_replay/cli.py b/vmware_nsx/api_replay/cli.py index 2a0e993741..a5ea23d881 100644 --- a/vmware_nsx/api_replay/cli.py +++ b/vmware_nsx/api_replay/cli.py @@ -64,7 +64,8 @@ class ApiReplayCli(object): vif_ids_map=args.vif_ids_map, logfile=args.logfile, max_retry=args.max_retry, - cert_file=args.cert_file) + cert_file=args.cert_file, + ignore_errors=args.ignore_errors) def _setup_argparse(self): parser = argparse.ArgumentParser() @@ -206,7 +207,12 @@ class ApiReplayCli(object): "--enable-barbican", default=False, 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 # require options are missing. diff --git a/vmware_nsx/api_replay/client.py b/vmware_nsx/api_replay/client.py index c447b625b7..5bd22c1014 100644 --- a/vmware_nsx/api_replay/client.py +++ b/vmware_nsx/api_replay/client.py @@ -60,7 +60,7 @@ class ApiReplayClient(utils.PrepareObjectForMigration): octavia_os_tenant_name, octavia_os_tenant_domain_id, octavia_os_password, octavia_os_auth_url, 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 if neutron_conf: @@ -170,6 +170,7 @@ class ApiReplayClient(utils.PrepareObjectForMigration): self.n_errors = 0 self.errors = [] + self.ignore_errors = ignore_errors LOG.info("Starting NSX migration to %s.", self.dest_plugin) # Migrate all the objects @@ -279,8 +280,11 @@ class ApiReplayClient(utils.PrepareObjectForMigration): return False def add_error(self, msg): - self.n_errors = self.n_errors + 1 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) def migrate_quotas(self):