From ce23f27bfeccf21c058b806f5c7a54dc1b82ffc3 Mon Sep 17 00:00:00 2001 From: Lingxian Kong Date: Tue, 17 Mar 2020 14:20:52 +1300 Subject: [PATCH] Delete error volumes when deleting instance Backport candidate. Change-Id: I799f7b30e1af396a8ae540cff2ba8b548a23f82c Story: 2007436 Task: 39083 (cherry picked from commit 513e0dd3cd27790718b31c6d0d4b556bd6de0793) --- devstack/plugin.sh | 2 +- trove/instance/models.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/devstack/plugin.sh b/devstack/plugin.sh index 840760ca5f..5d313d77df 100644 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -387,7 +387,7 @@ function setup_mgmt_network() { if [[ "$IP_VERSION" =~ 4.* ]]; then NEW_SUBNET_ID=$(create_mgmt_subnet_v4 ${PROJECT_ID} ${network_id} ${SUBNET_NAME} ${SUBNET_RANGE}) - openstack router add subnet $ROUTER_ID $NEW_SUBNET_ID + # openstack router add subnet $ROUTER_ID $NEW_SUBNET_ID fi # Trove doesn't support IPv6 for now. # if [[ "$IP_VERSION" =~ .*6 ]]; then diff --git a/trove/instance/models.py b/trove/instance/models.py index 7a13af2ea6..a4c959e989 100644 --- a/trove/instance/models.py +++ b/trove/instance/models.py @@ -783,7 +783,9 @@ class BaseInstance(SimpleInstance): try: if self.volume_id: volume = self.volume_client.volumes.get(self.volume_id) - if volume.status == "available": + if volume.status in ["available", "error"]: + LOG.info("Deleting volume %s for instance %s", + self.volume_id, self.id) volume.delete() except Exception as e: LOG.warning("Failed to delete volume for instance %s, error: %s",