There are many instances of "except Exception in the agent code base. While this pattern has reasonable use-cases, and can be part of a safe pattern where the caught exception is subsequently re-raised after some processing, it can cause the process to enter difficult to debug error states because of its generality.
We should, either incrementally or specifically, ensure that all "non-specific" exceptions re-raise. Any exception that does not re-raise should be specific. e.g. "except NeutronException".
A possible safe-and-sane way forward might be to audit each of the non-specific except statements, in any case where the exception is not reraised add the reraise behavior, UNLESS we understand the specific case the except statement is handling, in which case we use the correct specificException with the except statement.
Below is a (snapshot) summary of instances of the pattern.
Wed Oct 25 08:49:28 MDT 2017 || stack stack ocata-dev[ ]
id_rsa id_rsa_testlab
/home/stack/f5-openstack-agent: 0 $
grep -n -r -e"except Exception" ./*
./f5_openstack_agent/lbaasv2/drivers/bigip/ssl_profile.py:77: except Exception as err:
./f5_openstack_agent/lbaasv2/drivers/bigip/l7policy_service.py:74: except Exception:
./f5_openstack_agent/lbaasv2/drivers/bigip/vs_builder.py:72: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/barbican_cert.py:118: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/agent_manager.py:401: except Exception as e:
./f5_openstack_agent/lbaasv2/drivers/bigip/agent_manager.py:462: except Exception as e:
./f5_openstack_agent/lbaasv2/drivers/bigip/agent_manager.py:508: except Exception as e:
./f5_openstack_agent/lbaasv2/drivers/bigip/agent_manager.py:599: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/agent_manager.py:651: except Exception as e:
./f5_openstack_agent/lbaasv2/drivers/bigip/agent_manager.py:667: except Exception as e:
./f5_openstack_agent/lbaasv2/drivers/bigip/agent_manager.py:687: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/agent_manager.py:795: except Exception as e:
./f5_openstack_agent/lbaasv2/drivers/bigip/agent_manager.py:814: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/agent_manager.py:830: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/agent_manager.py:844: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/agent_manager.py:855: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/agent_manager.py:869: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/agent_manager.py:883: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/agent_manager.py:897: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/agent_manager.py:910: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/agent_manager.py:924: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/agent_manager.py:937: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/agent_manager.py:951: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/agent_manager.py:965: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/agent_manager.py:978: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/agent_manager.py:993: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/agent_manager.py:1011: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/agent_manager.py:1025: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/agent_manager.py:1050: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/agent_manager.py:1062: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/agent_manager.py:1074: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/agent_manager.py:1092: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/agent_manager.py:1103: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/agent_manager.py:1114: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/agent_manager.py:1125: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/agent_manager.py:1136: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/agent_manager.py:1147: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/agent_manager.py:1158: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/cluster_manager.py:107: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/tenants.py:65: except Exception as err:
./f5_openstack_agent/lbaasv2/drivers/bigip/tenants.py:83: except Exception as err:
./f5_openstack_agent/lbaasv2/drivers/bigip/tenants.py:114: except Exception as err:
./f5_openstack_agent/lbaasv2/drivers/bigip/tenants.py:121: except Exception as err:
./f5_openstack_agent/lbaasv2/drivers/bigip/icontrol_driver.py:436: except Exception:
./f5_openstack_agent/lbaasv2/drivers/bigip/icontrol_driver.py:487: except Exception as err:
./f5_openstack_agent/lbaasv2/drivers/bigip/icontrol_driver.py:570: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/icontrol_driver.py:827: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/icontrol_driver.py:904: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/icontrol_driver.py:924: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/icontrol_driver.py:963: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/icontrol_driver.py:1102: except Exception as e:
./f5_openstack_agent/lbaasv2/drivers/bigip/icontrol_driver.py:1379: except Exception as e:
./f5_openstack_agent/lbaasv2/drivers/bigip/icontrol_driver.py:1405: except Exception as error:
./f5_openstack_agent/lbaasv2/drivers/bigip/icontrol_driver.py:1441: except Exception as error:
./f5_openstack_agent/lbaasv2/drivers/bigip/icontrol_driver.py:1456: except Exception as err:
./f5_openstack_agent/lbaasv2/drivers/bigip/pool_service.py:262: except Exception as e:
./f5_openstack_agent/lbaasv2/drivers/bigip/fdb_connector_ml2.py:61: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/lbaas_builder.py:153: except Exception as err:
./f5_openstack_agent/lbaasv2/drivers/bigip/lbaas_builder.py:165: except Exception as err:
./f5_openstack_agent/lbaasv2/drivers/bigip/lbaas_builder.py:200: except Exception as err:
./f5_openstack_agent/lbaasv2/drivers/bigip/lbaas_builder.py:237: except Exception as err:
./f5_openstack_agent/lbaasv2/drivers/bigip/lbaas_builder.py:267: except Exception as err:
./f5_openstack_agent/lbaasv2/drivers/bigip/lbaas_builder.py:287: except Exception as err:
./f5_openstack_agent/lbaasv2/drivers/bigip/lbaas_builder.py:303: except Exception as err:
./f5_openstack_agent/lbaasv2/drivers/bigip/lbaas_builder.py:339: except Exception as err:
./f5_openstack_agent/lbaasv2/drivers/bigip/lbaas_builder.py:359: except Exception as err:
./f5_openstack_agent/lbaasv2/drivers/bigip/lbaas_builder.py:362: except Exception as err:
./f5_openstack_agent/lbaasv2/drivers/bigip/lbaas_builder.py:425: except Exception as err:
./f5_openstack_agent/lbaasv2/drivers/bigip/lbaas_builder.py:443: except Exception as err:
./f5_openstack_agent/lbaasv2/drivers/bigip/lbaas_builder.py:532: except Exception as err:
./f5_openstack_agent/lbaasv2/drivers/bigip/lbaas_builder.py:568: except Exception as err:
./f5_openstack_agent/lbaasv2/drivers/bigip/lbaas_builder.py:595: except Exception as err:
./f5_openstack_agent/lbaasv2/drivers/bigip/lbaas_builder.py:619: except Exception as err:
./f5_openstack_agent/lbaasv2/drivers/bigip/utils.py:102: except Exception:
./f5_openstack_agent/lbaasv2/drivers/bigip/selfips.py:77: except Exception as err:
./f5_openstack_agent/lbaasv2/drivers/bigip/selfips.py:231: except Exception as err:
./f5_openstack_agent/lbaasv2/drivers/bigip/selfips.py:244: except Exception as err:
./f5_openstack_agent/lbaasv2/drivers/bigip/selfips.py:298: except Exception as err:
./f5_openstack_agent/lbaasv2/drivers/bigip/selfips.py:326: except Exception as err:
./f5_openstack_agent/lbaasv2/drivers/bigip/selfips.py:375: except Exception as err:
./f5_openstack_agent/lbaasv2/drivers/bigip/listener_service.py:394: except Exception as err:
./f5_openstack_agent/lbaasv2/drivers/bigip/listener_service.py:422: except Exception as err:
./f5_openstack_agent/lbaasv2/drivers/bigip/listener_service.py:479: except Exception as e:
./f5_openstack_agent/lbaasv2/drivers/bigip/listener_service.py:506: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/listener_service.py:559: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/listener_service.py:700: except Exception as err:
./f5_openstack_agent/lbaasv2/drivers/bigip/snats.py:162: except Exception as err:
./f5_openstack_agent/lbaasv2/drivers/bigip/snats.py:192: except Exception as err:
./f5_openstack_agent/lbaasv2/drivers/bigip/snats.py:260: except Exception:
./f5_openstack_agent/lbaasv2/drivers/bigip/virtual_address.py:111: except Exception as Error:
./f5_openstack_agent/lbaasv2/drivers/bigip/network_helper.py:614: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/network_helper.py:626: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/network_helper.py:765: except Exception as e:
./f5_openstack_agent/lbaasv2/drivers/bigip/network_helper.py:917: except Exception as err:
./f5_openstack_agent/lbaasv2/drivers/bigip/service_adapter.py:281: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/network_service.py:186: except Exception as err:
./f5_openstack_agent/lbaasv2/drivers/bigip/network_service.py:623: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/network_service.py:743: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/network_service.py:819: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/l2_service.py:269: except Exception as err:
./f5_openstack_agent/lbaasv2/drivers/bigip/l2_service.py:321: except Exception as err:
./f5_openstack_agent/lbaasv2/drivers/bigip/l2_service.py:358: except Exception as err:
./f5_openstack_agent/lbaasv2/drivers/bigip/l2_service.py:390: except Exception as err:
./f5_openstack_agent/lbaasv2/drivers/bigip/l2_service.py:420: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/l2_service.py:466: except Exception as err:
./f5_openstack_agent/lbaasv2/drivers/bigip/l2_service.py:510: except Exception as err:
./f5_openstack_agent/lbaasv2/drivers/bigip/l2_service.py:531: except Exception as err:
./f5_openstack_agent/lbaasv2/drivers/bigip/l2_service.py:555: except Exception as err:
./f5_openstack_agent/lbaasv2/drivers/bigip/vcmp.py:98: except Exception as ex:
./f5_openstack_agent/lbaasv2/drivers/bigip/vcmp.py:184: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/vcmp.py:213: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/vcmp.py:242: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/vcmp.py:254: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/vcmp.py:279: except Exception as exc:
./f5_openstack_agent/lbaasv2/drivers/bigip/vcmp.py:297: except Exception as exc:
./f5_openstack_agent/utils/clean_partition.py:79: except Exception as err:
./f5-openstack-agent-dist/scripts/universal_truth.py:64: except Exception as Error:
./f5-openstack-agent-dist/scripts/construct_setups.py:208: except Exception as Error:
./f5-openstack-agent-dist/scripts/construct_setups.py:277: except Exception as Error:
./f5-openstack-agent-dist/scripts/construct_setups.py:327: except Exception as Error:
./test/functional/bin/convert_service.py:30: except Exception as err:
./test/functional/neutronless/conftest.py:130: except Exception as Error:
Agent Version
ocata-dev
There are many instances of "
except Exception
in the agent code base. While this pattern has reasonable use-cases, and can be part of a safe pattern where the caught exception is subsequently re-raised after some processing, it can cause the process to enter difficult to debug error states because of its generality.We should, either incrementally or specifically, ensure that all "non-specific" exceptions re-raise. Any exception that does not re-raise should be specific. e.g. "
except NeutronException
".A possible safe-and-sane way forward might be to audit each of the non-specific
except
statements, in any case where the exception is not reraised add the reraise behavior, UNLESS we understand the specific case theexcept
statement is handling, in which case we use the correct specificException
with theexcept
statement.Below is a (snapshot) summary of instances of the pattern.