Handle binding_failed error when creating neutron port
Due to errors on the neutron side we might get a port on create_port request, with the binding_failed error and hence the port will not become active, leaving the pod in ContainerCreating state. We should instead delete the port and raise an error. Change-Id: I6e736b5c39f46fab78a538bab66089168fb69b54 Signed-off-by: Nayan Deshmukh <n.deshmukh@samsung.com>
This commit is contained in:
parent
50b5933730
commit
0e82d8005f
|
@ -46,6 +46,7 @@ class NestedMacvlanPodVIFDriver(nested_vif.NestedPodVIFDriver):
|
|||
|
||||
if not container_port:
|
||||
container_port = os_net.create_port(**req)
|
||||
self._check_port_binding([container_port])
|
||||
utils.tag_neutron_resources([container_port])
|
||||
|
||||
container_mac = container_port.mac_address
|
||||
|
|
|
@ -44,6 +44,7 @@ class NestedVlanPodVIFDriver(nested_vif.NestedPodVIFDriver):
|
|||
|
||||
rq = self._get_port_request(pod, project_id, subnets, security_groups)
|
||||
port = os_net.create_port(**rq)
|
||||
self._check_port_binding([port])
|
||||
utils.tag_neutron_resources([port])
|
||||
vlan_id = self._add_subport(trunk_id, port.id)
|
||||
|
||||
|
@ -85,6 +86,7 @@ class NestedVlanPodVIFDriver(nested_vif.NestedPodVIFDriver):
|
|||
except os_exc.SDKException:
|
||||
LOG.exception("Error creating bulk ports: %s", bulk_port_rq)
|
||||
raise
|
||||
self._check_port_binding(ports)
|
||||
utils.tag_neutron_resources(ports)
|
||||
|
||||
for index, port in enumerate(ports):
|
||||
|
|
|
@ -37,8 +37,9 @@ class NeutronPodVIFDriver(base.PodVIFDriver):
|
|||
|
||||
rq = self._get_port_request(pod, project_id, subnets, security_groups)
|
||||
port = os_net.create_port(**rq)
|
||||
utils.tag_neutron_resources([port])
|
||||
|
||||
self._check_port_binding([port])
|
||||
utils.tag_neutron_resources([port])
|
||||
return ovu.neutron_to_osvif_vif(port.binding_vif_type, port, subnets)
|
||||
|
||||
def request_vifs(self, pod, project_id, subnets, security_groups,
|
||||
|
@ -54,7 +55,6 @@ class NeutronPodVIFDriver(base.PodVIFDriver):
|
|||
except os_exc.SDKException:
|
||||
LOG.exception("Error creating bulk ports: %s", bulk_port_rq)
|
||||
raise
|
||||
utils.tag_neutron_resources(ports)
|
||||
|
||||
vif_plugin = ports[0].binding_vif_type
|
||||
|
||||
|
@ -66,6 +66,8 @@ class NeutronPodVIFDriver(base.PodVIFDriver):
|
|||
port_info = os_net.get_port(ports[0].id)
|
||||
vif_plugin = port_info.binding_vif_type
|
||||
|
||||
self._check_port_binding(ports)
|
||||
utils.tag_neutron_resources(ports)
|
||||
vifs = []
|
||||
for port in ports:
|
||||
vif = ovu.neutron_to_osvif_vif(vif_plugin, port, subnets)
|
||||
|
@ -124,3 +126,11 @@ class NeutronPodVIFDriver(base.PodVIFDriver):
|
|||
port_req_body['security_groups'] = security_groups
|
||||
|
||||
return port_req_body
|
||||
|
||||
def _check_port_binding(self, ports):
|
||||
if ports[0].binding_vif_type == "binding_failed":
|
||||
for port in ports:
|
||||
clients.get_network_client().delete_port(port.id)
|
||||
LOG.error("Binding failed error for ports: %s."
|
||||
" Please check Neutron for errors.", ports)
|
||||
raise k_exc.ResourceNotReady(ports)
|
||||
|
|
|
@ -56,6 +56,7 @@ class SriovVIFDriver(neutron_vif.NeutronPodVIFDriver):
|
|||
subnets, security_groups)
|
||||
|
||||
port = os_net.create_port(**rq)
|
||||
self._check_port_binding([port])
|
||||
c_utils.tag_neutron_resources([port])
|
||||
vif = ovu.neutron_to_osvif_vif(vif_plugin, port, subnets)
|
||||
vif.physnet = physnet
|
||||
|
|
Loading…
Reference in New Issue