Merge "Continue waiting to avoid temporary connection error with target VIM"

This commit is contained in:
Jenkins 2017-04-19 10:59:57 +00:00 committed by Gerrit Code Review
commit 53fefab4c4
3 changed files with 59 additions and 20 deletions

View File

@ -67,8 +67,8 @@ class VNFScaleWaitFailed(exceptions.TackerException):
message = _('%(reason)s')
class VNFDeleteFailed(exceptions.TackerException):
message = _('deleting VNF %(vnf_id)s failed')
class VNFDeleteWaitFailed(exceptions.TackerException):
message = _('%(reason)s')
class VNFDNotFound(exceptions.NotFound):

View File

@ -0,0 +1,41 @@
# Copyright 2017 99cloud, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import mock
from tacker.extensions import vnfm
from tacker.tests.unit import base
from tacker.vnfm.infra_drivers.openstack import openstack
class TestOpenStack(base.TestCase):
@mock.patch("tacker.vnfm.infra_drivers.openstack.heat_client.HeatClient")
def test_create_wait_with_heat_connection_exception(self, mocked_hc):
stack = {"stack_status", "CREATE_IN_PROGRESS"}
mocked_hc.get.side_effect = [stack, Exception("any stuff")]
openstack_driver = openstack.OpenStack()
self.assertRaises(vnfm.VNFCreateWaitFailed,
openstack_driver.create_wait,
None, None, {}, 'vnf_id', None)
@mock.patch("tacker.vnfm.infra_drivers.openstack.heat_client.HeatClient")
def test_delete_wait_with_heat_connection_exception(self, mocked_hc):
stack = {"stack_status", "DELETE_IN_PROGRESS"}
mocked_hc.get.side_effect = [stack, Exception("any stuff")]
openstack_driver = openstack.OpenStack()
self.assertRaises(vnfm.VNFDeleteWaitFailed,
openstack_driver.delete_wait,
None, None, 'vnf_id', None, None)

View File

@ -136,11 +136,12 @@ class OpenStack(abstract_driver.DeviceAbstractDriver,
try:
stack = heatclient.get(vnf_id)
except Exception:
LOG.exception(_("VNF Instance cleanup may not have "
"happened because Heat API request failed "
"while waiting for the stack %(stack)s to be "
"deleted"), {'stack': vnf_id})
break
LOG.warning(_("VNF Instance setup may not have "
"happened because Heat API request failed "
"while waiting for the stack %(stack)s to be "
"created"), {'stack': vnf_id})
# continue to avoid temporary connection error to target
# VIM
status = stack.stack_status
LOG.debug(_('status: %s'), status)
stack_retries = stack_retries - 1
@ -156,13 +157,11 @@ class OpenStack(abstract_driver.DeviceAbstractDriver,
stack=vnf_id)
LOG.warning(_("VNF Creation failed: %(reason)s"),
{'reason': error_reason})
raise vnfm.VNFCreateWaitFailed(vnf_id=vnf_id,
reason=error_reason)
raise vnfm.VNFCreateWaitFailed(reason=error_reason)
elif stack_retries != 0 and status != 'CREATE_COMPLETE':
error_reason = stack.stack_status_reason
raise vnfm.VNFCreateWaitFailed(vnf_id=vnf_id,
reason=error_reason)
raise vnfm.VNFCreateWaitFailed(reason=error_reason)
def _find_mgmt_ips(outputs):
LOG.debug(_('outputs %s'), outputs)
@ -256,11 +255,12 @@ class OpenStack(abstract_driver.DeviceAbstractDriver,
except heatException.HTTPNotFound:
return
except Exception:
LOG.exception(_("VNF Instance cleanup may not have "
"happened because Heat API request failed "
"while waiting for the stack %(stack)s to be "
"deleted"), {'stack': vnf_id})
break
LOG.warning(_("VNF Instance cleanup may not have "
"happened because Heat API request failed "
"while waiting for the stack %(stack)s to be "
"deleted"), {'stack': vnf_id})
# Just like create wait, ignore the exception to
# avoid temporary connection error.
status = stack.stack_status
stack_retries = stack_retries - 1
@ -271,16 +271,14 @@ class OpenStack(abstract_driver.DeviceAbstractDriver,
"not completed").format(stack=vnf_id,
wait=(self.STACK_RETRIES * self.STACK_RETRY_WAIT))
LOG.warning(error_reason)
raise vnfm.VNFCreateWaitFailed(vnf_id=vnf_id,
reason=error_reason)
raise vnfm.VNFDeleteWaitFailed(reason=error_reason)
if stack_retries != 0 and status != 'DELETE_COMPLETE':
error_reason = _("vnf {vnf_id} deletion is not completed. "
"{stack_status}").format(vnf_id=vnf_id,
stack_status=status)
LOG.warning(error_reason)
raise vnfm.VNFCreateWaitFailed(vnf_id=vnf_id,
reason=error_reason)
raise vnfm.VNFDeleteWaitFailed(reason=error_reason)
@classmethod
def _find_mgmt_ips_from_groups(cls, heat_client, instance_id, group_names):