From 5a9835ccb7d408e7c9b80578e83c9dbb9dd3898d Mon Sep 17 00:00:00 2001 From: Michael Johnson Date: Thu, 19 Nov 2015 00:50:28 +0000 Subject: [PATCH] Stop nova driver delete failure on already deleted The nova compute driver currently raises an exception if the instance has already been deleted. This patch logs a warning, but does not raise an exception when the instance being deleted is not found. Change-Id: I72e54297b925c5c6ce0dd711a33e19afc74ba37d Partial-Bug: #1509706 --- octavia/compute/drivers/nova_driver.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/octavia/compute/drivers/nova_driver.py b/octavia/compute/drivers/nova_driver.py index 55fdf2c0a7..335610fc8a 100644 --- a/octavia/compute/drivers/nova_driver.py +++ b/octavia/compute/drivers/nova_driver.py @@ -12,6 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. +from novaclient import exceptions as nova_exceptions from oslo_config import cfg from oslo_log import log as logging @@ -20,7 +21,7 @@ from octavia.common import constants from octavia.common import data_models as models from octavia.common import exceptions from octavia.compute import compute_base -from octavia.i18n import _LE +from octavia.i18n import _LE, _LW LOG = logging.getLogger(__name__) @@ -93,6 +94,9 @@ class VirtualMachineManager(compute_base.ComputeBase): ''' try: self.manager.delete(server=compute_id) + except nova_exceptions.NotFound: + LOG.warn(_LW("Nova instance with id: %s not found. " + "Assuming already deleted."), compute_id) except Exception: LOG.exception(_LE("Error deleting nova virtual machine.")) raise exceptions.ComputeDeleteException()