)]}'
{"neutron/db/l3_hamode_db.py":[{"author":{"_account_id":8873,"name":"Assaf Muller","email":"amuller@redhat.com","username":"amuller"},"change_message_id":"b3129d3d8797f42e971115fc05a6d13b5b4248c5","unresolved":false,"context_lines":[{"line_number":242,"context_line":"                 \u0027admin_state_up\u0027: True,"},{"line_number":243,"context_line":"                 \u0027status\u0027: constants.NET_STATUS_ACTIVE}}"},{"line_number":244,"context_line":""},{"line_number":245,"context_line":"        for count in range(MAX_HA_NETWORK_TRIES):"},{"line_number":246,"context_line":"            try:"},{"line_number":247,"context_line":"                with context.session.begin(subtransactions\u003dTrue):"},{"line_number":248,"context_line":"                    network \u003d self._core_plugin.create_network(admin_ctx, args)"}],"source_content_type":"text/x-python","patch_set":3,"id":"fa1b9901_f673d9e5","line":245,"updated":"2015-08-23 22:45:40.000000000","message":"I have to admit I don\u0027t understand what\u0027s this change has got to do with the patch.","commit_id":"626ea1c0c275cafacbf1de0574d50090ae8b42a8"},{"author":{"_account_id":7249,"name":"Ann Taraday","email":"akamyshnikova@mirantis.com","username":"AKamyshnikova"},"change_message_id":"4f2c6cf32e53a09f72fe18ee420b38c7e2be1e6e","unresolved":false,"context_lines":[{"line_number":242,"context_line":"                 \u0027admin_state_up\u0027: True,"},{"line_number":243,"context_line":"                 \u0027status\u0027: constants.NET_STATUS_ACTIVE}}"},{"line_number":244,"context_line":""},{"line_number":245,"context_line":"        for count in range(MAX_HA_NETWORK_TRIES):"},{"line_number":246,"context_line":"            try:"},{"line_number":247,"context_line":"                with context.session.begin(subtransactions\u003dTrue):"},{"line_number":248,"context_line":"                    network \u003d self._core_plugin.create_network(admin_ctx, args)"}],"source_content_type":"text/x-python","patch_set":3,"id":"ba8a016a_23150e48","line":245,"in_reply_to":"fa1b9901_f673d9e5","updated":"2015-11-19 10:34:58.000000000","message":"I also think that this should be a separate change, so remove this from here.","commit_id":"626ea1c0c275cafacbf1de0574d50090ae8b42a8"},{"author":{"_account_id":8873,"name":"Assaf Muller","email":"amuller@redhat.com","username":"amuller"},"change_message_id":"b3129d3d8797f42e971115fc05a6d13b5b4248c5","unresolved":false,"context_lines":[{"line_number":443,"context_line":"        self._core_plugin.delete_network(admin_ctx, net.network_id)"},{"line_number":444,"context_line":""},{"line_number":445,"context_line":"    def _ha_routers_present(self, context):"},{"line_number":446,"context_line":"        ha_routers \u003d self.get_routers(context)"},{"line_number":447,"context_line":"        for router in ha_routers:"},{"line_number":448,"context_line":"            if router[\u0027ha\u0027]:"},{"line_number":449,"context_line":"                return True"}],"source_content_type":"text/x-python","patch_set":3,"id":"fa1b9901_f65af94f","line":446,"updated":"2015-08-23 22:45:40.000000000","message":"Should you filter by the tenant_id of the context here? Otherwise if the admin deletes an HA router from the admin project, get_routers will return all routers and not just that tenant\u0027s routers? Haven\u0027t verified this.","commit_id":"626ea1c0c275cafacbf1de0574d50090ae8b42a8"},{"author":{"_account_id":7249,"name":"Ann Taraday","email":"akamyshnikova@mirantis.com","username":"AKamyshnikova"},"change_message_id":"4f2c6cf32e53a09f72fe18ee420b38c7e2be1e6e","unresolved":false,"context_lines":[{"line_number":443,"context_line":"        self._core_plugin.delete_network(admin_ctx, net.network_id)"},{"line_number":444,"context_line":""},{"line_number":445,"context_line":"    def _ha_routers_present(self, context):"},{"line_number":446,"context_line":"        ha_routers \u003d self.get_routers(context)"},{"line_number":447,"context_line":"        for router in ha_routers:"},{"line_number":448,"context_line":"            if router[\u0027ha\u0027]:"},{"line_number":449,"context_line":"                return True"}],"source_content_type":"text/x-python","patch_set":3,"id":"ba8a016a_8304fa17","line":446,"in_reply_to":"fa1b9901_f65af94f","updated":"2015-11-19 10:34:58.000000000","message":"Yes, we need to filter by tenant_id here.\nDone","commit_id":"626ea1c0c275cafacbf1de0574d50090ae8b42a8"},{"author":{"_account_id":8873,"name":"Assaf Muller","email":"amuller@redhat.com","username":"amuller"},"change_message_id":"b3129d3d8797f42e971115fc05a6d13b5b4248c5","unresolved":false,"context_lines":[{"line_number":460,"context_line":"                self._delete_vr_id_allocation("},{"line_number":461,"context_line":"                    context, ha_network, router_db.extra_attributes.ha_vr_id)"},{"line_number":462,"context_line":"                self._delete_ha_interfaces(context, router_db.id)"},{"line_number":463,"context_line":"            if not self._ha_routers_present(context):"},{"line_number":464,"context_line":"                self._delete_ha_network(context, ha_network)"},{"line_number":465,"context_line":""},{"line_number":466,"context_line":"    def get_ha_router_port_bindings(self, context, router_ids, host\u003dNone):"}],"source_content_type":"text/x-python","patch_set":3,"id":"fa1b9901_d65d7549","line":463,"updated":"2015-08-23 22:45:40.000000000","message":"It\u0027s clear this is raceful... Two threads or processes check line 463 and get the same response. Both can get False, then both try to delete, one will raise an exception. You can catch a NotFound type error and ignore it since that means someone else deleted the network, and that\u0027s fine. The other error is harder to deal with: What if you execute line 463, then someone else comes and creates an HA router, then you delete the network? I don\u0027t know if there\u0027s a way not to use \u0027select for update\u0027 here (On the HA networks table, to make lines 463 and 464 atomic), but I\u0027m not a DB concurrency expert.","commit_id":"626ea1c0c275cafacbf1de0574d50090ae8b42a8"},{"author":{"_account_id":7249,"name":"Ann Taraday","email":"akamyshnikova@mirantis.com","username":"AKamyshnikova"},"change_message_id":"4f2c6cf32e53a09f72fe18ee420b38c7e2be1e6e","unresolved":false,"context_lines":[{"line_number":460,"context_line":"                self._delete_vr_id_allocation("},{"line_number":461,"context_line":"                    context, ha_network, router_db.extra_attributes.ha_vr_id)"},{"line_number":462,"context_line":"                self._delete_ha_interfaces(context, router_db.id)"},{"line_number":463,"context_line":"            if not self._ha_routers_present(context):"},{"line_number":464,"context_line":"                self._delete_ha_network(context, ha_network)"},{"line_number":465,"context_line":""},{"line_number":466,"context_line":"    def get_ha_router_port_bindings(self, context, router_ids, host\u003dNone):"}],"source_content_type":"text/x-python","patch_set":3,"id":"ba8a016a_2bbe4465","line":463,"in_reply_to":"fa1b9901_d65d7549","updated":"2015-11-19 10:34:58.000000000","message":"I\u0027ll add transaction to make this deletion more atomic and think what else could be done.","commit_id":"626ea1c0c275cafacbf1de0574d50090ae8b42a8"},{"author":{"_account_id":8873,"name":"Assaf Muller","email":"amuller@redhat.com","username":"amuller"},"change_message_id":"a4f0e19b8b1ec967693026b8fe0ae4ada894a407","unresolved":false,"context_lines":[{"line_number":487,"context_line":"                with context.session.begin(subtransactions\u003dTrue):"},{"line_number":488,"context_line":"                    if not self._ha_routers_present(context,"},{"line_number":489,"context_line":"                                                    router_db.tenant_id):"},{"line_number":490,"context_line":"                        self._delete_ha_network(context, ha_network)"},{"line_number":491,"context_line":"                        LOG.info(_LI(\"HA network %(network)s was deleted as \""},{"line_number":492,"context_line":"                                     \"no HA routers are present in tenant \""},{"line_number":493,"context_line":"                                     \"%(tenant)s.\"),"}],"source_content_type":"text/x-python","patch_set":4,"id":"ba8a016a_9bd71323","line":490,"updated":"2015-11-20 23:18:53.000000000","message":"An HA router could be created in the tenant between lines 488 and 490, but I know that you know this :)","commit_id":"0b1bc64f536f46bcea975a7ad1dfc7f9c8fd728e"},{"author":{"_account_id":7249,"name":"Ann Taraday","email":"akamyshnikova@mirantis.com","username":"AKamyshnikova"},"change_message_id":"85b4eb601fa80e5d655d3800a35ea0e0ff9a6ea1","unresolved":false,"context_lines":[{"line_number":487,"context_line":"                with context.session.begin(subtransactions\u003dTrue):"},{"line_number":488,"context_line":"                    if not self._ha_routers_present(context,"},{"line_number":489,"context_line":"                                                    router_db.tenant_id):"},{"line_number":490,"context_line":"                        self._delete_ha_network(context, ha_network)"},{"line_number":491,"context_line":"                        LOG.info(_LI(\"HA network %(network)s was deleted as \""},{"line_number":492,"context_line":"                                     \"no HA routers are present in tenant \""},{"line_number":493,"context_line":"                                     \"%(tenant)s.\"),"}],"source_content_type":"text/x-python","patch_set":4,"id":"ba8a016a_1eebea79","line":490,"in_reply_to":"ba8a016a_5efd046d","updated":"2015-11-23 12:06:39.000000000","message":"I\u0027ve done some tests executing concurrently create and delete router and with some sleeps, so what I see: if router was created between lines 488 and 490, I\u0027ve got an error  http://paste.openstack.org/show/479711/ HA network was not deleted and I had a message \"Request Failed: internal server error while processing your request.\" after router deletion that do not related to router deletion, as router was deleted, but HA network wasn\u0027t. I think that the possible solution is to catch InvalidRequestError here and give a message that HA network was nor deleted. I will update patch with such solution.","commit_id":"0b1bc64f536f46bcea975a7ad1dfc7f9c8fd728e"},{"author":{"_account_id":8873,"name":"Assaf Muller","email":"amuller@redhat.com","username":"amuller"},"change_message_id":"956fdb1f5121b4419a412e0a038ce8947a3db8c0","unresolved":false,"context_lines":[{"line_number":487,"context_line":"                with context.session.begin(subtransactions\u003dTrue):"},{"line_number":488,"context_line":"                    if not self._ha_routers_present(context,"},{"line_number":489,"context_line":"                                                    router_db.tenant_id):"},{"line_number":490,"context_line":"                        self._delete_ha_network(context, ha_network)"},{"line_number":491,"context_line":"                        LOG.info(_LI(\"HA network %(network)s was deleted as \""},{"line_number":492,"context_line":"                                     \"no HA routers are present in tenant \""},{"line_number":493,"context_line":"                                     \"%(tenant)s.\"),"}],"source_content_type":"text/x-python","patch_set":4,"id":"ba8a016a_5efd046d","line":490,"in_reply_to":"ba8a016a_9bd71323","updated":"2015-11-22 23:15:48.000000000","message":"I wonder if we can make the DB throw an integrity exception somehow if an HA network is deleted when there\u0027s still something \u0027using it\u0027, that certainly wouldn\u0027t be raceful.","commit_id":"0b1bc64f536f46bcea975a7ad1dfc7f9c8fd728e"},{"author":{"_account_id":11159,"name":"Hong Hui Xiao","email":"honghui_xiao@yeah.net","username":"HongHuiXiao"},"change_message_id":"0351ffc9554654c335049c2d17a250224f30bdbb","unresolved":false,"context_lines":[{"line_number":466,"context_line":""},{"line_number":467,"context_line":"    def _ha_routers_present(self, context, tenant_id):"},{"line_number":468,"context_line":"        routers \u003d self.get_routers(context, filters\u003d{\u0027tenant_id\u0027: [tenant_id]})"},{"line_number":469,"context_line":"        for router in routers:"},{"line_number":470,"context_line":"            if router[\u0027ha\u0027]:"},{"line_number":471,"context_line":"                return True"},{"line_number":472,"context_line":"        return False"}],"source_content_type":"text/x-python","patch_set":5,"id":"ba8a016a_8b77739e","line":469,"updated":"2015-11-24 01:43:43.000000000","message":"nit comment: line 469~472 is very the same as \n\nreturn any(router[\u0027ha\u0027] for router in routers)","commit_id":"8c1cd5619d3308805244e3a4bc2ab14e2edbb897"},{"author":{"_account_id":7249,"name":"Ann Taraday","email":"akamyshnikova@mirantis.com","username":"AKamyshnikova"},"change_message_id":"23b98d3a4e043fdf6b928ebc2d0687888ad74b76","unresolved":false,"context_lines":[{"line_number":466,"context_line":""},{"line_number":467,"context_line":"    def _ha_routers_present(self, context, tenant_id):"},{"line_number":468,"context_line":"        routers \u003d self.get_routers(context, filters\u003d{\u0027tenant_id\u0027: [tenant_id]})"},{"line_number":469,"context_line":"        for router in routers:"},{"line_number":470,"context_line":"            if router[\u0027ha\u0027]:"},{"line_number":471,"context_line":"                return True"},{"line_number":472,"context_line":"        return False"}],"source_content_type":"text/x-python","patch_set":5,"id":"9a8ffd7b_c972d5ad","line":469,"in_reply_to":"ba8a016a_8b77739e","updated":"2015-11-24 12:48:55.000000000","message":"Done","commit_id":"8c1cd5619d3308805244e3a4bc2ab14e2edbb897"},{"author":{"_account_id":8873,"name":"Assaf Muller","email":"amuller@redhat.com","username":"amuller"},"change_message_id":"5db2c26dfbb0a5c33c56692ecbc61f4ba18903b9","unresolved":false,"context_lines":[{"line_number":494,"context_line":"            except n_exc.NetworkNotFound:"},{"line_number":495,"context_line":"                LOG.debug(\"HA network %s was already deleted.\","},{"line_number":496,"context_line":"                          ha_network.network_id)"},{"line_number":497,"context_line":"            except sa.exc.InvalidRequestError:"},{"line_number":498,"context_line":"                LOG.info(_LI(\"HA network %s can not be deleted.\"),"},{"line_number":499,"context_line":"                         ha_network.network_id)"},{"line_number":500,"context_line":""}],"source_content_type":"text/x-python","patch_set":5,"id":"ba8a016a_50fe2faf","line":497,"updated":"2015-11-23 15:51:56.000000000","message":"As discussed in IRC, rebasing this patch on https://review.openstack.org/#/c/230481/ might result in a different exception here. Ann will retest.","commit_id":"8c1cd5619d3308805244e3a4bc2ab14e2edbb897"},{"author":{"_account_id":8873,"name":"Assaf Muller","email":"amuller@redhat.com","username":"amuller"},"change_message_id":"56f9445fcd5731e5a86eb5816eb4f390723bb5a9","unresolved":false,"context_lines":[{"line_number":494,"context_line":"            except n_exc.NetworkNotFound:"},{"line_number":495,"context_line":"                LOG.debug(\"HA network %s was already deleted.\","},{"line_number":496,"context_line":"                          ha_network.network_id)"},{"line_number":497,"context_line":"            except sa.exc.InvalidRequestError:"},{"line_number":498,"context_line":"                LOG.info(_LI(\"HA network %s can not be deleted.\"),"},{"line_number":499,"context_line":"                         ha_network.network_id)"},{"line_number":500,"context_line":""}],"source_content_type":"text/x-python","patch_set":5,"id":"9a8ffd7b_5d7515c9","line":497,"in_reply_to":"9a8ffd7b_294b615b","updated":"2015-11-25 03:11:38.000000000","message":"Roger that. Good work Ann!","commit_id":"8c1cd5619d3308805244e3a4bc2ab14e2edbb897"},{"author":{"_account_id":7249,"name":"Ann Taraday","email":"akamyshnikova@mirantis.com","username":"AKamyshnikova"},"change_message_id":"23b98d3a4e043fdf6b928ebc2d0687888ad74b76","unresolved":false,"context_lines":[{"line_number":494,"context_line":"            except n_exc.NetworkNotFound:"},{"line_number":495,"context_line":"                LOG.debug(\"HA network %s was already deleted.\","},{"line_number":496,"context_line":"                          ha_network.network_id)"},{"line_number":497,"context_line":"            except sa.exc.InvalidRequestError:"},{"line_number":498,"context_line":"                LOG.info(_LI(\"HA network %s can not be deleted.\"),"},{"line_number":499,"context_line":"                         ha_network.network_id)"},{"line_number":500,"context_line":""}],"source_content_type":"text/x-python","patch_set":5,"id":"9a8ffd7b_294b615b","line":497,"in_reply_to":"ba8a016a_50fe2faf","updated":"2015-11-24 12:48:55.000000000","message":"I tested on my env after applying  https://review.openstack.org/#/c/230481/. I\u0027ve got the same error. So, I don\u0027t think it is need to rebase on it.\n\nThe scenario I used for testing http://paste.openstack.org/show/479848/","commit_id":"8c1cd5619d3308805244e3a4bc2ab14e2edbb897"},{"author":{"_account_id":13667,"name":"ZongKai LI","email":"onionpiece@163.com","username":"lzklibj"},"change_message_id":"df9b3a500a8c8c3cdbad216e1e14c47d64de2679","unresolved":false,"context_lines":[{"line_number":466,"context_line":""},{"line_number":467,"context_line":"    def _ha_routers_present(self, context, tenant_id):"},{"line_number":468,"context_line":"        routers \u003d self.get_routers(context, filters\u003d{\u0027tenant_id\u0027: [tenant_id]})"},{"line_number":469,"context_line":"        return any(router[\u0027ha\u0027] for router in routers)"},{"line_number":470,"context_line":""},{"line_number":471,"context_line":"    def delete_router(self, context, id):"},{"line_number":472,"context_line":"        router_db \u003d self._get_router(context, id)"}],"source_content_type":"text/x-python","patch_set":6,"id":"9a8ffd7b_269122f1","line":469,"updated":"2015-11-25 05:46:19.000000000","message":"why not directly query RouterExtraAttributes with RouterExtraAttributes.ha \u003d\u003d sql.true() ? That will be simpler and better. To me, get_routers seems misused here.","commit_id":"16be019c8266644136457cfe874c11d961582beb"},{"author":{"_account_id":7249,"name":"Ann Taraday","email":"akamyshnikova@mirantis.com","username":"AKamyshnikova"},"change_message_id":"849171d018f262fbe25dc26b5d4be875b9becabf","unresolved":false,"context_lines":[{"line_number":466,"context_line":""},{"line_number":467,"context_line":"    def _ha_routers_present(self, context, tenant_id):"},{"line_number":468,"context_line":"        routers \u003d self.get_routers(context, filters\u003d{\u0027tenant_id\u0027: [tenant_id]})"},{"line_number":469,"context_line":"        return any(router[\u0027ha\u0027] for router in routers)"},{"line_number":470,"context_line":""},{"line_number":471,"context_line":"    def delete_router(self, context, id):"},{"line_number":472,"context_line":"        router_db \u003d self._get_router(context, id)"}],"source_content_type":"text/x-python","patch_set":6,"id":"9a8ffd7b_ac74119c","line":469,"in_reply_to":"9a8ffd7b_269122f1","updated":"2015-11-25 06:30:40.000000000","message":"RouterExtraAttributes does not have tenant_id, so I will need to check Routers for tenant_id and RouterExtraAttributes for ha, so I don\u0027t see much benefits from that.","commit_id":"16be019c8266644136457cfe874c11d961582beb"},{"author":{"_account_id":7249,"name":"Ann Taraday","email":"akamyshnikova@mirantis.com","username":"AKamyshnikova"},"change_message_id":"7582551867df5ccf722f7a4060ac4d041d498c22","unresolved":false,"context_lines":[{"line_number":466,"context_line":""},{"line_number":467,"context_line":"    def _ha_routers_present(self, context, tenant_id):"},{"line_number":468,"context_line":"        routers \u003d self.get_routers(context, filters\u003d{\u0027tenant_id\u0027: [tenant_id]})"},{"line_number":469,"context_line":"        return any(router[\u0027ha\u0027] for router in routers)"},{"line_number":470,"context_line":""},{"line_number":471,"context_line":"    def delete_router(self, context, id):"},{"line_number":472,"context_line":"        router_db \u003d self._get_router(context, id)"}],"source_content_type":"text/x-python","patch_set":6,"id":"9a8ffd7b_55e721e4","line":469,"in_reply_to":"9a8ffd7b_97ecb6c8","updated":"2015-11-25 09:56:17.000000000","message":"Done","commit_id":"16be019c8266644136457cfe874c11d961582beb"},{"author":{"_account_id":12444,"name":"John Schwarz","email":"jschwarz@redhat.com","username":"jschwarz"},"change_message_id":"adc4871779d187bf9196de2553f1d877f36e6921","unresolved":false,"context_lines":[{"line_number":466,"context_line":""},{"line_number":467,"context_line":"    def _ha_routers_present(self, context, tenant_id):"},{"line_number":468,"context_line":"        routers \u003d self.get_routers(context, filters\u003d{\u0027tenant_id\u0027: [tenant_id]})"},{"line_number":469,"context_line":"        return any(router[\u0027ha\u0027] for router in routers)"},{"line_number":470,"context_line":""},{"line_number":471,"context_line":"    def delete_router(self, context, id):"},{"line_number":472,"context_line":"        router_db \u003d self._get_router(context, id)"}],"source_content_type":"text/x-python","patch_set":6,"id":"9a8ffd7b_57116e51","line":469,"in_reply_to":"9a8ffd7b_ac74119c","updated":"2015-11-25 07:04:13.000000000","message":"I think that ZongKai\u0027s suggestion implicates that the search will be done fully in SQL (C code) and not partially. Right now, it looks like that in the worst case we might iterate over the entire  list of routers when it might not be necessary at all. In a deployment with thousands of routers... this is an unneeded overhead we can easily avoid.\n\nChanging the code appropriately will change the last line to be \u0027return routers.first() !\u003d None\u0027, which is a lot faster when comparing Python\u0027s runtime to C\u0027s.","commit_id":"16be019c8266644136457cfe874c11d961582beb"},{"author":{"_account_id":13667,"name":"ZongKai LI","email":"onionpiece@163.com","username":"lzklibj"},"change_message_id":"5f0c5597311f1b0981f2c31a8c2dd248a6091683","unresolved":false,"context_lines":[{"line_number":466,"context_line":""},{"line_number":467,"context_line":"    def _ha_routers_present(self, context, tenant_id):"},{"line_number":468,"context_line":"        routers \u003d self.get_routers(context, filters\u003d{\u0027tenant_id\u0027: [tenant_id]})"},{"line_number":469,"context_line":"        return any(router[\u0027ha\u0027] for router in routers)"},{"line_number":470,"context_line":""},{"line_number":471,"context_line":"    def delete_router(self, context, id):"},{"line_number":472,"context_line":"        router_db \u003d self._get_router(context, id)"}],"source_content_type":"text/x-python","patch_set":6,"id":"9a8ffd7b_97ecb6c8","line":469,"in_reply_to":"9a8ffd7b_ac74119c","updated":"2015-11-25 07:25:32.000000000","message":"Thanks John, your explanation comes better.\n\nWe don\u0027t need get any router object here, that\u0027s why I think get_routers is misused here.\n\nConsider again, I think we can only query Routers and RouterExtraAttributes, a joint query maybe. And just take a look at whether at least one id/or something else exists in this query, yes, just like \u0027return routers.first() !\u003d None\u0027.","commit_id":"16be019c8266644136457cfe874c11d961582beb"},{"author":{"_account_id":12444,"name":"John Schwarz","email":"jschwarz@redhat.com","username":"jschwarz"},"change_message_id":"d0312ffa24b33acce67e24588646817e060491a8","unresolved":false,"context_lines":[{"line_number":465,"context_line":"    def _delete_ha_network(self, context, net):"},{"line_number":466,"context_line":"        admin_ctx \u003d context.elevated()"},{"line_number":467,"context_line":"        self._core_plugin.delete_network(admin_ctx, net.network_id)"},{"line_number":468,"context_line":""},{"line_number":469,"context_line":"    def _ha_routers_present(self, context, tenant_id):"},{"line_number":470,"context_line":"        ha \u003d True"},{"line_number":471,"context_line":"        routers \u003d context.session.query(l3_db.Router).filter("}],"source_content_type":"text/x-python","patch_set":7,"id":"9a8ffd7b_f052e3dc","line":468,"updated":"2015-11-25 10:08:58.000000000","message":"Function name suggest it returns a True/False, but in fact it returns None/a router.","commit_id":"15bb64e0010065ee1c7eba77ed594118779209d0"},{"author":{"_account_id":7249,"name":"Ann Taraday","email":"akamyshnikova@mirantis.com","username":"AKamyshnikova"},"change_message_id":"70cb24a3d45bed85e2d7a82ae34f7aa61c5b5370","unresolved":false,"context_lines":[{"line_number":465,"context_line":"    def _delete_ha_network(self, context, net):"},{"line_number":466,"context_line":"        admin_ctx \u003d context.elevated()"},{"line_number":467,"context_line":"        self._core_plugin.delete_network(admin_ctx, net.network_id)"},{"line_number":468,"context_line":""},{"line_number":469,"context_line":"    def _ha_routers_present(self, context, tenant_id):"},{"line_number":470,"context_line":"        ha \u003d True"},{"line_number":471,"context_line":"        routers \u003d context.session.query(l3_db.Router).filter("}],"source_content_type":"text/x-python","patch_set":7,"id":"9a8ffd7b_0b03ba43","line":468,"in_reply_to":"9a8ffd7b_f052e3dc","updated":"2015-11-25 10:36:31.000000000","message":"Done","commit_id":"15bb64e0010065ee1c7eba77ed594118779209d0"},{"author":{"_account_id":12444,"name":"John Schwarz","email":"jschwarz@redhat.com","username":"jschwarz"},"change_message_id":"d0312ffa24b33acce67e24588646817e060491a8","unresolved":false,"context_lines":[{"line_number":466,"context_line":"        admin_ctx \u003d context.elevated()"},{"line_number":467,"context_line":"        self._core_plugin.delete_network(admin_ctx, net.network_id)"},{"line_number":468,"context_line":""},{"line_number":469,"context_line":"    def _ha_routers_present(self, context, tenant_id):"},{"line_number":470,"context_line":"        ha \u003d True"},{"line_number":471,"context_line":"        routers \u003d context.session.query(l3_db.Router).filter("},{"line_number":472,"context_line":"            l3_db.Router.tenant_id \u003d\u003d tenant_id).subquery()"}],"source_content_type":"text/x-python","patch_set":7,"id":"9a8ffd7b_30114b53","line":469,"updated":"2015-11-25 10:08:58.000000000","message":"nit: the \u0027ha\u0027 variable isn\u0027t really needed.","commit_id":"15bb64e0010065ee1c7eba77ed594118779209d0"},{"author":{"_account_id":12444,"name":"John Schwarz","email":"jschwarz@redhat.com","username":"jschwarz"},"change_message_id":"d0312ffa24b33acce67e24588646817e060491a8","unresolved":false,"context_lines":[{"line_number":468,"context_line":""},{"line_number":469,"context_line":"    def _ha_routers_present(self, context, tenant_id):"},{"line_number":470,"context_line":"        ha \u003d True"},{"line_number":471,"context_line":"        routers \u003d context.session.query(l3_db.Router).filter("},{"line_number":472,"context_line":"            l3_db.Router.tenant_id \u003d\u003d tenant_id).subquery()"},{"line_number":473,"context_line":"        ha_routers \u003d context.session.query("},{"line_number":474,"context_line":"            l3_attrs_db.RouterExtraAttributes).join("}],"source_content_type":"text/x-python","patch_set":7,"id":"9a8ffd7b_10c5278d","line":471,"updated":"2015-11-25 10:08:58.000000000","message":"I\u0027m wondering whether context.session.query(l3_db.Router) already returns only routers in the context\u0027s tenant_id. If so, we can save one step and simplify the query.","commit_id":"15bb64e0010065ee1c7eba77ed594118779209d0"},{"author":{"_account_id":7249,"name":"Ann Taraday","email":"akamyshnikova@mirantis.com","username":"AKamyshnikova"},"change_message_id":"70cb24a3d45bed85e2d7a82ae34f7aa61c5b5370","unresolved":false,"context_lines":[{"line_number":468,"context_line":""},{"line_number":469,"context_line":"    def _ha_routers_present(self, context, tenant_id):"},{"line_number":470,"context_line":"        ha \u003d True"},{"line_number":471,"context_line":"        routers \u003d context.session.query(l3_db.Router).filter("},{"line_number":472,"context_line":"            l3_db.Router.tenant_id \u003d\u003d tenant_id).subquery()"},{"line_number":473,"context_line":"        ha_routers \u003d context.session.query("},{"line_number":474,"context_line":"            l3_attrs_db.RouterExtraAttributes).join("}],"source_content_type":"text/x-python","patch_set":7,"id":"9a8ffd7b_ab094e97","line":471,"in_reply_to":"9a8ffd7b_10c5278d","updated":"2015-11-25 10:36:31.000000000","message":"context.session.query(l3_db.Router) return all routers for all tenants.","commit_id":"15bb64e0010065ee1c7eba77ed594118779209d0"},{"author":{"_account_id":12444,"name":"John Schwarz","email":"jschwarz@redhat.com","username":"jschwarz"},"change_message_id":"d0312ffa24b33acce67e24588646817e060491a8","unresolved":false,"context_lines":[{"line_number":470,"context_line":"        ha \u003d True"},{"line_number":471,"context_line":"        routers \u003d context.session.query(l3_db.Router).filter("},{"line_number":472,"context_line":"            l3_db.Router.tenant_id \u003d\u003d tenant_id).subquery()"},{"line_number":473,"context_line":"        ha_routers \u003d context.session.query("},{"line_number":474,"context_line":"            l3_attrs_db.RouterExtraAttributes).join("},{"line_number":475,"context_line":"            routers,"},{"line_number":476,"context_line":"            l3_attrs_db.RouterExtraAttributes.router_id \u003d\u003d routers.c.id"}],"source_content_type":"text/x-python","patch_set":7,"id":"9a8ffd7b_30706b72","line":473,"updated":"2015-11-25 10:08:58.000000000","message":"Can simply return the result of first() - no need to assign to a variable.","commit_id":"15bb64e0010065ee1c7eba77ed594118779209d0"},{"author":{"_account_id":12444,"name":"John Schwarz","email":"jschwarz@redhat.com","username":"jschwarz"},"change_message_id":"f7b19e42977786e0bd20b9b9db6264d40d68327c","unresolved":false,"context_lines":[{"line_number":475,"context_line":"            routers,"},{"line_number":476,"context_line":"            l3_attrs_db.RouterExtraAttributes.router_id \u003d\u003d routers.c.id"},{"line_number":477,"context_line":"        ).filter(l3_attrs_db.RouterExtraAttributes.ha \u003d\u003d ha).first()"},{"line_number":478,"context_line":"        return False if ha_routers is None else True"},{"line_number":479,"context_line":""},{"line_number":480,"context_line":"    def delete_router(self, context, id):"},{"line_number":481,"context_line":"        router_db \u003d self._get_router(context, id)"}],"source_content_type":"text/x-python","patch_set":8,"id":"9a8ffd7b_c426f7cd","line":478,"updated":"2015-11-25 13:58:02.000000000","message":"nit:\n\n return ha_routers is not None","commit_id":"44926744747addd5ac6245660a3a3c856786fa6b"},{"author":{"_account_id":7249,"name":"Ann Taraday","email":"akamyshnikova@mirantis.com","username":"AKamyshnikova"},"change_message_id":"77e4f7d773833eb389002d38ce93ab0a8398cb42","unresolved":false,"context_lines":[{"line_number":475,"context_line":"            routers,"},{"line_number":476,"context_line":"            l3_attrs_db.RouterExtraAttributes.router_id \u003d\u003d routers.c.id"},{"line_number":477,"context_line":"        ).filter(l3_attrs_db.RouterExtraAttributes.ha \u003d\u003d ha).first()"},{"line_number":478,"context_line":"        return False if ha_routers is None else True"},{"line_number":479,"context_line":""},{"line_number":480,"context_line":"    def delete_router(self, context, id):"},{"line_number":481,"context_line":"        router_db \u003d self._get_router(context, id)"}],"source_content_type":"text/x-python","patch_set":8,"id":"9a8ffd7b_ff41420c","line":478,"in_reply_to":"9a8ffd7b_c426f7cd","updated":"2015-11-25 14:00:53.000000000","message":"Done","commit_id":"44926744747addd5ac6245660a3a3c856786fa6b"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"0faa93e1c67c92072f0837fe113a156073fb2cbe","unresolved":false,"context_lines":[{"line_number":489,"context_line":"                    context, ha_network, router_db.extra_attributes.ha_vr_id)"},{"line_number":490,"context_line":"                self._delete_ha_interfaces(context, router_db.id)"},{"line_number":491,"context_line":"            try:"},{"line_number":492,"context_line":"                with context.session.begin(subtransactions\u003dTrue):"},{"line_number":493,"context_line":"                    if not self._ha_routers_present(context,"},{"line_number":494,"context_line":"                                                    router_db.tenant_id):"},{"line_number":495,"context_line":"                        self._delete_ha_network(context, ha_network)"}],"source_content_type":"text/x-python","patch_set":9,"id":"9a8ffd7b_6eab5dd7","line":492,"updated":"2015-11-25 15:59:15.000000000","message":"I don\u0027t think we should be starting a transaction here before making a call into the core plugin. The post commit operations in ML2 that will happen in the delete network call are expecting everything to be committed to the database. If a transaction is started here, that assumption will be broken and it could have weird side effects depending on the loaded mechanism drivers.","commit_id":"c54cc07280196eb356f1e93371cdc115f9b49bc5"}]}
