Fix adding router interface job failed
Since all rest calls have changed from sync to async, it is possible that the interface network has been deleted before running adding this network on router. In this case, the job would hung and finally failed with all its following async rest calls. The fix patch just is a workaround for the bug, it would ensure the network would not be deleted before running adding router interface job. Change-Id: I6c1f9ce87a8cb133cea79adba7cb8a6e2bb2426e Closes-bug: 1389358
This commit is contained in:
parent
5e9508a758
commit
7a67704dec
@ -627,6 +627,7 @@ class NsxVPluginV2(agents_db.AgentDbMixin,
|
||||
if mappings:
|
||||
if sg_policy_id:
|
||||
self.nsx_v.vcns.delete_spoofguard_policy(sg_policy_id)
|
||||
edge_utils.check_network_in_use_at_backend(context, id)
|
||||
self._delete_backend_network(mappings[0])
|
||||
|
||||
def get_network(self, context, id, fields=None):
|
||||
|
@ -297,6 +297,8 @@ class EdgeApplianceDriver(object):
|
||||
LOG.exception(_LE("Failed to delete vdr interface on edge: "
|
||||
"%s"),
|
||||
edge_id)
|
||||
# avoid bug 1389358
|
||||
self.check_edge_jobs(edge_id)
|
||||
|
||||
def _delete_interface(self, task):
|
||||
edge_id = task.userdata['edge_id']
|
||||
@ -328,6 +330,8 @@ class EdgeApplianceDriver(object):
|
||||
userdata=userdata)
|
||||
task.add_result_monitor(self.callbacks.interface_delete_result)
|
||||
self.task_manager.add(task)
|
||||
# avoid bug 1389358
|
||||
self.check_edge_jobs(edge_id)
|
||||
return task
|
||||
|
||||
def _deploy_edge(self, task):
|
||||
|
@ -13,6 +13,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import time
|
||||
|
||||
from oslo.config import cfg
|
||||
from oslo.utils import excutils
|
||||
from sqlalchemy.orm import exc as sa_exc
|
||||
@ -1209,6 +1211,21 @@ def update_firewall(nsxv_manager, context, router_id, firewall,
|
||||
task.wait(task_const.TaskState.RESULT)
|
||||
|
||||
|
||||
def check_network_in_use_at_backend(context, network_id):
|
||||
retries = max(cfg.CONF.nsxv.retries, 1)
|
||||
delay = 0.5
|
||||
for attempt in range(1, retries + 1):
|
||||
if attempt != 1:
|
||||
time.sleep(delay)
|
||||
delay = min(2 * delay, 60)
|
||||
edge_vnic_bindings = nsxv_db.get_edge_vnic_bindings_by_int_lswitch(
|
||||
context.session, network_id)
|
||||
if not edge_vnic_bindings:
|
||||
return
|
||||
LOG.warning(_('NSXv: network is still in use at the backend'))
|
||||
LOG.error(_('NSXv: network is still in use at the backend'))
|
||||
|
||||
|
||||
class NsxVCallbacks(object):
|
||||
"""Edge callback implementation Callback functions for
|
||||
asynchronous tasks.
|
||||
|
@ -76,6 +76,15 @@ class FakeVcns(object):
|
||||
return False
|
||||
return True
|
||||
|
||||
def get_edge_jobs(self, edge_id):
|
||||
if edge_id not in self._edges:
|
||||
raise Exception(_("Edge %s does not exist") % edge_id)
|
||||
header = {
|
||||
'status': 200
|
||||
}
|
||||
response = {"edgeJob": []}
|
||||
return (header, response)
|
||||
|
||||
def deploy_edge(self, request):
|
||||
if (self._unique_router_name and
|
||||
not self._validate_edge_name(request['name'])):
|
||||
|
Loading…
Reference in New Issue
Block a user