Merge "Avoid doing `raise ex` when only logging"

This commit is contained in:
Zuul 2019-01-28 11:30:46 +00:00 committed by Gerrit Code Review
commit 79b615f98c
11 changed files with 64 additions and 65 deletions

View File

@ -405,9 +405,9 @@ class LBaaSv2Driver(base.LBaaSDriver):
fixed_ips = ['subnet_id=%s' % str(loadbalancer.subnet_id), fixed_ips = ['subnet_id=%s' % str(loadbalancer.subnet_id),
'ip_address=%s' % str(loadbalancer.ip)] 'ip_address=%s' % str(loadbalancer.ip)]
ports = neutron.list_ports(fixed_ips=fixed_ips) ports = neutron.list_ports(fixed_ips=fixed_ips)
except n_exc.NeutronClientException as ex: except n_exc.NeutronClientException:
LOG.error("Port with fixed ips %s not found!", fixed_ips) LOG.error("Port with fixed ips %s not found!", fixed_ips)
raise ex raise
if ports['ports']: if ports['ports']:
return ports['ports'][0] return ports['ports'][0]
@ -802,10 +802,9 @@ class LBaaSv2Driver(base.LBaaSDriver):
l7_rule.id, l7_rule.l7policy_id, l7_rule.id, l7_rule.l7policy_id,
{'rule': {'value': new_value}}) {'rule': {'value': new_value}})
except n_exc.NeutronClientException as ex: except n_exc.NeutronClientException:
LOG.error("Failed to update l7_rule- id=%s ", LOG.exception("Failed to update l7_rule- id=%s ", l7_rule.id)
l7_rule.id) raise
raise ex
def is_pool_used_by_other_l7policies(self, l7policy, pool): def is_pool_used_by_other_l7policies(self, l7policy, pool):
lbaas = clients.get_loadbalancer_client() lbaas = clients.get_loadbalancer_client()

View File

@ -115,10 +115,10 @@ class NamespacePodSecurityGroupsDriver(base.PodSecurityGroupsDriver):
"security_group_id": sg['id'] "security_group_id": sg['id']
} }
}) })
except n_exc.NeutronClientException as ex: except n_exc.NeutronClientException:
LOG.error("Error creating security group for the namespace " LOG.exception("Error creating security group for the namespace "
"%s: %s", namespace, ex) "%s", namespace)
raise ex raise
return {'sgId': sg['id']} return {'sgId': sg['id']}
def delete_sg(self, sg_id): def delete_sg(self, sg_id):

View File

@ -138,10 +138,10 @@ class NamespacePodSubnetDriver(default_subnet.DefaultPodSubnetDriver):
# connect the subnet to the router # connect the subnet to the router
neutron.add_interface_router(router_id, neutron.add_interface_router(router_id,
{"subnet_id": neutron_subnet['id']}) {"subnet_id": neutron_subnet['id']})
except n_exc.NeutronClientException as ex: except n_exc.NeutronClientException:
LOG.error("Error creating neutron resources for the namespace " LOG.exception("Error creating neutron resources for the namespace "
"%s: %s", namespace, ex) "%s", namespace)
raise ex raise
return {'netId': neutron_net['id'], return {'netId': neutron_net['id'],
'routerId': router_id, 'routerId': router_id,
'subnetId': neutron_subnet['id'], 'subnetId': neutron_subnet['id'],

View File

@ -142,7 +142,7 @@ class NestedMacvlanPodVIFDriver(nested_vif.NestedPodVIFDriver):
port_id, port_id,
{'port': {'allowed_address_pairs': address_pairs}} {'port': {'allowed_address_pairs': address_pairs}}
) )
except n_exc.NeutronClientException as ex: except n_exc.NeutronClientException:
LOG.error("Error happened during updating Neutron " LOG.exception("Error happened during updating Neutron port %s",
"port %s: %s", port_id, ex) port_id)
raise ex raise

View File

@ -40,10 +40,10 @@ class NestedPodVIFDriver(neutron_vif.NeutronPodVIFDriver):
fixed_ips = ['subnet_id=%s' % str(node_subnet_id), fixed_ips = ['subnet_id=%s' % str(node_subnet_id),
'ip_address=%s' % str(node_fixed_ip)] 'ip_address=%s' % str(node_fixed_ip)]
ports = neutron.list_ports(fixed_ips=fixed_ips) ports = neutron.list_ports(fixed_ips=fixed_ips)
except n_exc.NeutronClientException as ex: except n_exc.NeutronClientException:
LOG.error("Parent vm port with fixed ips %s not found!", LOG.error("Parent vm port with fixed ips %s not found!",
fixed_ips) fixed_ips)
raise ex raise
if ports['ports']: if ports['ports']:
return ports['ports'][0] return ports['ports'][0]

View File

@ -81,9 +81,9 @@ class NestedVlanPodVIFDriver(nested_vif.NestedPodVIFDriver):
bulk_port_rq = {'ports': [port_rq for _ in range(len(subports_info))]} bulk_port_rq = {'ports': [port_rq for _ in range(len(subports_info))]}
try: try:
ports = neutron.create_port(bulk_port_rq).get('ports') ports = neutron.create_port(bulk_port_rq).get('ports')
except n_exc.NeutronClientException as ex: except n_exc.NeutronClientException:
LOG.error("Error creating bulk ports: %s", bulk_port_rq) LOG.exception("Error creating bulk ports: %s", bulk_port_rq)
raise ex raise
for index, port in enumerate(ports): for index, port in enumerate(ports):
subports_info[index]['port_id'] = port['id'] subports_info[index]['port_id'] = port['id']
@ -91,14 +91,14 @@ class NestedVlanPodVIFDriver(nested_vif.NestedPodVIFDriver):
try: try:
neutron.trunk_add_subports(trunk_id, neutron.trunk_add_subports(trunk_id,
{'sub_ports': subports_info}) {'sub_ports': subports_info})
except n_exc.Conflict as ex: except n_exc.Conflict:
LOG.error("vlan ids already in use on trunk") LOG.error("vlan ids already in use on trunk")
for port in ports: for port in ports:
neutron.delete_port(port['id']) neutron.delete_port(port['id'])
raise ex raise
except n_exc.NeutronClientException as ex: except n_exc.NeutronClientException:
LOG.error("Error happened during subport addition to trunk") LOG.exception("Error happened during subport addition to trunk")
raise ex raise
vifs = [] vifs = []
for index, port in enumerate(ports): for index, port in enumerate(ports):
@ -185,17 +185,17 @@ class NestedVlanPodVIFDriver(nested_vif.NestedPodVIFDriver):
while True: while True:
try: try:
vlan_id = self._get_vlan_id(trunk_id) vlan_id = self._get_vlan_id(trunk_id)
except n_exc.NeutronClientException as ex: except n_exc.NeutronClientException:
LOG.error("Getting VlanID for subport on " LOG.error("Getting VlanID for subport on "
"trunk %s failed!!", trunk_id) "trunk %s failed!!", trunk_id)
raise ex raise
subport = [{'segmentation_id': vlan_id, subport = [{'segmentation_id': vlan_id,
'port_id': subport, 'port_id': subport,
'segmentation_type': 'vlan'}] 'segmentation_type': 'vlan'}]
try: try:
neutron.trunk_add_subports(trunk_id, neutron.trunk_add_subports(trunk_id,
{'sub_ports': subport}) {'sub_ports': subport})
except n_exc.Conflict as ex: except n_exc.Conflict:
if retry_count < DEFAULT_MAX_RETRY_COUNT: if retry_count < DEFAULT_MAX_RETRY_COUNT:
LOG.error("vlanid already in use on trunk, " LOG.error("vlanid already in use on trunk, "
"%s. Retrying...", trunk_id) "%s. Retrying...", trunk_id)
@ -205,12 +205,12 @@ class NestedVlanPodVIFDriver(nested_vif.NestedPodVIFDriver):
else: else:
LOG.error( LOG.error(
"MAX retry count reached. Failed to add subport") "MAX retry count reached. Failed to add subport")
raise ex raise
except n_exc.NeutronClientException as ex: except n_exc.NeutronClientException:
LOG.error("Error happened during subport " LOG.exception("Error happened during subport "
"addition to trunk, %s", trunk_id) "addition to trunk %s", trunk_id)
raise ex raise
return vlan_id return vlan_id
def _remove_subports(self, neutron, trunk_id, subports_id): def _remove_subports(self, neutron, trunk_id, subports_id):
@ -220,11 +220,10 @@ class NestedVlanPodVIFDriver(nested_vif.NestedPodVIFDriver):
try: try:
neutron.trunk_remove_subports(trunk_id, neutron.trunk_remove_subports(trunk_id,
{'sub_ports': subports_body}) {'sub_ports': subports_body})
except n_exc.NeutronClientException as ex: except n_exc.NeutronClientException:
LOG.error( LOG.exception("Error happened during subport removal from "
"Error happened during subport removal from " "trunk %s", trunk_id)
"trunk, %s", trunk_id) raise
raise ex
def _remove_subport(self, neutron, trunk_id, subport_id): def _remove_subport(self, neutron, trunk_id, subport_id):
self._remove_subports(neutron, trunk_id, [subport_id]) self._remove_subports(neutron, trunk_id, [subport_id])

View File

@ -51,9 +51,9 @@ class NeutronPodVIFDriver(base.PodVIFDriver):
bulk_port_rq = {'ports': [rq for _ in range(num_ports)]} bulk_port_rq = {'ports': [rq for _ in range(num_ports)]}
try: try:
ports = neutron.create_port(bulk_port_rq).get('ports') ports = neutron.create_port(bulk_port_rq).get('ports')
except n_exc.NeutronClientException as ex: except n_exc.NeutronClientException:
LOG.error("Error creating bulk ports: %s", bulk_port_rq) LOG.exception("Error creating bulk ports: %s", bulk_port_rq)
raise ex raise
vif_plugin = self._get_vif_plugin(ports[0]) vif_plugin = self._get_vif_plugin(ports[0])

View File

@ -133,9 +133,10 @@ class FipPubIpDriver(BasePubIpDriver):
try: try:
response = neutron.create_floatingip(request) response = neutron.create_floatingip(request)
except n_exc.NeutronClientException as ex: except n_exc.NeutronClientException:
LOG.error("Failed to create floating IP - netid=%s ", pub_net_id) LOG.exception("Failed to create floating IP - netid=%s ",
raise ex pub_net_id)
raise
return response['floatingip']['id'], response[ return response['floatingip']['id'], response[
'floatingip']['floating_ip_address'] 'floatingip']['floating_ip_address']

View File

@ -74,10 +74,10 @@ class SriovVIFDriver(neutron_vif.NeutronPodVIFDriver):
"""Returns an appropriate physnet for exact subnet_id from mapping""" """Returns an appropriate physnet for exact subnet_id from mapping"""
try: try:
physnet = self._physnet_mapping[subnet_id] physnet = self._physnet_mapping[subnet_id]
except KeyError as ex: except KeyError:
LOG.error("No mapping for subnet {} in {}".format( LOG.error("No mapping for subnet {} in {}".format(
subnet_id, self._physnet_mapping)) subnet_id, self._physnet_mapping))
raise ex raise
return physnet return physnet
def _get_remaining_sriov_vfs(self, pod): def _get_remaining_sriov_vfs(self, pod):

View File

@ -184,10 +184,10 @@ class BaseVIFPool(base.VIFPoolDriver):
try: try:
return self._get_port_from_pool(pool_key, pod, subnets) return self._get_port_from_pool(pool_key, pod, subnets)
except exceptions.ResourceNotReady as ex: except exceptions.ResourceNotReady:
LOG.warning("Ports pool does not have available ports!") LOG.warning("Ports pool does not have available ports!")
eventlet.spawn(self._populate_pool, pool_key, pod, subnets) eventlet.spawn(self._populate_pool, pool_key, pod, subnets)
raise ex raise
def _get_port_from_pool(self, pool_key, pod, subnets): def _get_port_from_pool(self, pool_key, pod, subnets):
raise NotImplementedError() raise NotImplementedError()

View File

@ -157,22 +157,22 @@ class RequestHandler(BaseHTTPRequestHandler):
project_id = drv_project.get_project({}) project_id = drv_project.get_project({})
security_groups = drv_sg.get_security_groups({}, project_id) security_groups = drv_sg.get_security_groups({}, project_id)
subnets = drv_subnets.get_subnets([], project_id) subnets = drv_subnets.get_subnets([], project_id)
except TypeError as ex: except TypeError:
LOG.error("Invalid driver type") LOG.error("Invalid driver type")
raise ex raise
for trunk_ip in trunk_ips: for trunk_ip in trunk_ips:
try: try:
drv_vif_pool.force_populate_pool( drv_vif_pool.force_populate_pool(
trunk_ip, project_id, subnets, security_groups, num_ports) trunk_ip, project_id, subnets, security_groups, num_ports)
except n_exc.Conflict as ex: except n_exc.Conflict:
LOG.error("VLAN Id conflict (already in use) at trunk %s", LOG.error("VLAN Id conflict (already in use) at trunk %s",
trunk_ip) trunk_ip)
raise ex raise
except n_exc.NeutronClientException as ex: except n_exc.NeutronClientException:
LOG.error("Error happened during subports addition at trunk: " LOG.exception("Error happened during subports addition at "
" %s", trunk_ip) "trunk: %s", trunk_ip)
raise ex raise
def _delete_subports(self, trunk_ips): def _delete_subports(self, trunk_ips):
try: try:
@ -181,9 +181,9 @@ class RequestHandler(BaseHTTPRequestHandler):
drv_vif_pool.set_vif_driver(drv_vif) drv_vif_pool.set_vif_driver(drv_vif)
drv_vif_pool.free_pool(trunk_ips) drv_vif_pool.free_pool(trunk_ips)
except TypeError as ex: except TypeError:
LOG.error("Invalid driver type") LOG.error("Invalid driver type")
raise ex raise
def _list_pools(self): def _list_pools(self):
try: try:
@ -192,9 +192,9 @@ class RequestHandler(BaseHTTPRequestHandler):
drv_vif_pool.set_vif_driver(drv_vif) drv_vif_pool.set_vif_driver(drv_vif)
available_pools = drv_vif_pool.list_pools() available_pools = drv_vif_pool.list_pools()
except TypeError as ex: except TypeError:
LOG.error("Invalid driver type") LOG.error("Invalid driver type")
raise ex raise
pools_info = "" pools_info = ""
for pool_key, pool_items in available_pools.items(): for pool_key, pool_items in available_pools.items():
@ -211,9 +211,9 @@ class RequestHandler(BaseHTTPRequestHandler):
drv_vif_pool.set_vif_driver(drv_vif) drv_vif_pool.set_vif_driver(drv_vif)
pool = drv_vif_pool.show_pool(pool_key) pool = drv_vif_pool.show_pool(pool_key)
except TypeError as ex: except TypeError:
LOG.error("Invalid driver type") LOG.error("Invalid driver type")
raise ex raise
if pool: if pool:
pool_info = "" pool_info = ""