From d93a4109436af6517b9f9276b27c517a30bcd86e Mon Sep 17 00:00:00 2001 From: Lingxian Kong Date: Mon, 9 Dec 2019 12:04:47 +1300 Subject: [PATCH] Fix delete instance Deal with the situation when Trove fails to look for the Nova server when waiting for the db instance ACTIVE Change-Id: I484d45f24176c89d999864d3eb1c48860b3038bd --- devstack/plugin.sh | 2 +- trove/taskmanager/models.py | 20 +++++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/devstack/plugin.sh b/devstack/plugin.sh index 18b0118a8e..8f4b3d9e43 100644 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -559,7 +559,7 @@ function config_trove_network { sudo ip route # Now make sure the conf settings are right - iniset $TROVE_CONF DEFAULT network_label_regex ${PRIVATE_NETWORK_NAME} + iniset $TROVE_CONF DEFAULT network_label_regex "" iniset $TROVE_CONF DEFAULT ip_regex "" iniset $TROVE_CONF DEFAULT black_list_regex "" iniset $TROVE_CONF DEFAULT management_networks ${mgmt_net_id} diff --git a/trove/taskmanager/models.py b/trove/taskmanager/models.py index e7a0b40095..311e4639af 100755 --- a/trove/taskmanager/models.py +++ b/trove/taskmanager/models.py @@ -433,20 +433,22 @@ class FreshInstanceTasks(FreshInstance, NotifyMixin, ConfigurationMixin): TroveInstanceCreate(instance=self, instance_size=flavor['ram']).notify() except (TroveError, PollTimeOut) as ex: - LOG.exception("Failed to create instance %s.", self.id) + LOG.error("Failed to create instance %s, error: %s.", + self.id, str(ex)) self.update_statuses_on_time_out() error_message = "%s" % ex error_details = traceback.format_exc() except Exception as ex: - LOG.exception("Failed to send usage create-event for " - "instance %s.", self.id) + LOG.error("Failed to send usage create-event for instance %s, " + "error: %s", self.id, str(ex)) error_message = "%s" % ex error_details = traceback.format_exc() finally: if error_message: inst_models.save_instance_fault( self.id, error_message, error_details, - skip_delta=CONF.usage_sleep_time + 1) + skip_delta=CONF.usage_sleep_time + 1 + ) def _create_port(self, network, security_groups, is_mgmt=False, is_public=False): @@ -772,7 +774,15 @@ class FreshInstanceTasks(FreshInstance, NotifyMixin, ConfigurationMixin): raise TroveError(_("Service not active, status: %s") % status) c_id = self.db_info.compute_instance_id - server = self.nova_client.servers.get(c_id) + try: + server = self.nova_client.servers.get(c_id) + except Exception as e: + raise TroveError( + _("Failed to get server %(server)s for instance %(instance)s, " + "error: %(error)s"), + server=c_id, instance=self.id, error=str(e) + ) + server_status = server.status if server_status in [InstanceStatus.ERROR, InstanceStatus.FAILED]: