)]}'
{"/COMMIT_MSG":[{"author":{"_account_id":8873,"name":"Assaf Muller","email":"amuller@redhat.com","username":"amuller"},"change_message_id":"913dd7d78f0994f1fa424ce50c3a653f12544d08","unresolved":false,"context_lines":[{"line_number":11,"context_line":"HA network not existing or an existing one being  deleted"},{"line_number":12,"context_line":"by another worker before the interfaces could be created."},{"line_number":13,"context_line":""},{"line_number":14,"context_line":"It also adjusts the cleanup logic to just always attempt"},{"line_number":15,"context_line":"to delete the HA network since the core plugin will check"},{"line_number":16,"context_line":"if it\u0027s in use for us."},{"line_number":17,"context_line":""}],"source_content_type":"text/x-gerrit-commit-message","patch_set":17,"id":"7af24918_b58f84cb","line":14,"updated":"2016-03-05 01:17:30.000000000","message":"No it doesn\u0027t :) (Also: Please don\u0027t make this change in this patch)","commit_id":"1784a9314097bcb6098121189675c5f19e03ef4a"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"e55b41d11196d0de2153882ee646bc54026c08d0","unresolved":false,"context_lines":[{"line_number":11,"context_line":"HA network not existing or an existing one being  deleted"},{"line_number":12,"context_line":"by another worker before the interfaces could be created."},{"line_number":13,"context_line":""},{"line_number":14,"context_line":"It also adjusts the cleanup logic to just always attempt"},{"line_number":15,"context_line":"to delete the HA network since the core plugin will check"},{"line_number":16,"context_line":"if it\u0027s in use for us."},{"line_number":17,"context_line":""}],"source_content_type":"text/x-gerrit-commit-message","patch_set":17,"id":"7af24918_3bb5257e","line":14,"updated":"2016-03-05 02:19:23.000000000","message":"Whoops. It did, now it doesn\u0027t. :)","commit_id":"1784a9314097bcb6098121189675c5f19e03ef4a"}],"neutron/common/utils.py":[{"author":{"_account_id":12444,"name":"John Schwarz","email":"jschwarz@redhat.com","username":"jschwarz"},"change_message_id":"ca9f85984d55f49ed16cc8a1e1e06971150dd0a8","unresolved":false,"context_lines":[{"line_number":650,"context_line":"    return rules"},{"line_number":651,"context_line":""},{"line_number":652,"context_line":""},{"line_number":653,"context_line":"def create_object_with_dependency(creator, dep_getter, dep_creator,"},{"line_number":654,"context_line":"                                  dep_id_attr):"},{"line_number":655,"context_line":"    \"\"\"Creates an object that binds to a dependency while handling races."},{"line_number":656,"context_line":""}],"source_content_type":"text/x-python","patch_set":23,"id":"3afc51ec_2c0e3f3b","line":653,"range":{"start_line":653,"start_character":4,"end_line":653,"end_character":33},"updated":"2016-03-14 16:12:06.000000000","message":"I might be missing something here - if creator() fails for MAX_RETRIES times - where does the dependency get deleted? This might not always be called from a transaction, so...?","commit_id":"f83328c80dc3eb29c8bbb2c0571735e7f4f91898"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"874d983582397e2785fef3e6ec022f8e28410a57","unresolved":false,"context_lines":[{"line_number":650,"context_line":"    return rules"},{"line_number":651,"context_line":""},{"line_number":652,"context_line":""},{"line_number":653,"context_line":"def create_object_with_dependency(creator, dep_getter, dep_creator,"},{"line_number":654,"context_line":"                                  dep_id_attr):"},{"line_number":655,"context_line":"    \"\"\"Creates an object that binds to a dependency while handling races."},{"line_number":656,"context_line":""}],"source_content_type":"text/x-python","patch_set":23,"id":"3afc51ec_53787f2a","line":653,"updated":"2016-03-14 18:07:28.000000000","message":"It doesn\u0027t get deleted right now. It preserves the same behavior as the existing ha network creation logic. We can revisit changing it in a follow-up patch.","commit_id":"f83328c80dc3eb29c8bbb2c0571735e7f4f91898"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"db1173704d2584a71af032d2422791d04de8d910","unresolved":false,"context_lines":[{"line_number":650,"context_line":"    return rules"},{"line_number":651,"context_line":""},{"line_number":652,"context_line":""},{"line_number":653,"context_line":"def create_object_with_dependency(creator, dep_getter, dep_creator,"},{"line_number":654,"context_line":"                                  dep_id_attr):"},{"line_number":655,"context_line":"    \"\"\"Creates an object that binds to a dependency while handling races."},{"line_number":656,"context_line":""}],"source_content_type":"text/x-python","patch_set":23,"id":"3afc51ec_e96efe94","line":653,"updated":"2016-03-14 18:35:09.000000000","message":"Sure","commit_id":"f83328c80dc3eb29c8bbb2c0571735e7f4f91898"},{"author":{"_account_id":12444,"name":"John Schwarz","email":"jschwarz@redhat.com","username":"jschwarz"},"change_message_id":"cda2d8a3fd92477b12b7f62cc2223be66092b42d","unresolved":false,"context_lines":[{"line_number":650,"context_line":"    return rules"},{"line_number":651,"context_line":""},{"line_number":652,"context_line":""},{"line_number":653,"context_line":"def create_object_with_dependency(creator, dep_getter, dep_creator,"},{"line_number":654,"context_line":"                                  dep_id_attr):"},{"line_number":655,"context_line":"    \"\"\"Creates an object that binds to a dependency while handling races."},{"line_number":656,"context_line":""}],"source_content_type":"text/x-python","patch_set":23,"id":"3afc51ec_0e97f048","line":653,"in_reply_to":"3afc51ec_53787f2a","updated":"2016-03-14 18:21:44.000000000","message":"Fine by me. Can we add this little note to the docstring so it will be clearer?","commit_id":"f83328c80dc3eb29c8bbb2c0571735e7f4f91898"},{"author":{"_account_id":10267,"name":"venkata anil","email":"anilvenkata@redhat.com","username":"anil"},"change_message_id":"8292b5d653bb18df9597489843ff7bdd2ca9f4da","unresolved":false,"context_lines":[{"line_number":702,"context_line":"            break"},{"line_number":703,"context_line":"        except Exception:"},{"line_number":704,"context_line":"            with excutils.save_and_reraise_exception() as ctx:"},{"line_number":705,"context_line":"                # check if dependency we tried to use was removed during"},{"line_number":706,"context_line":"                # object creation"},{"line_number":707,"context_line":"                if attempts \u003c db_api.MAX_RETRIES:"},{"line_number":708,"context_line":"                    dependency \u003d dep_getter()"}],"source_content_type":"text/x-python","patch_set":26,"id":"1af94dfe_41283233","line":705,"updated":"2016-03-19 06:01:03.000000000","message":"https://review.openstack.org/#/c/294672/  avoids this removing","commit_id":"b8dd8d888eb7b6786904ee502bae157e68b57ec3"},{"author":{"_account_id":8873,"name":"Assaf Muller","email":"amuller@redhat.com","username":"amuller"},"change_message_id":"9e57879797e43bdbd98643697205f5ed9c1f5017","unresolved":false,"context_lines":[{"line_number":664,"context_line":"    dep_getter should return None if the dependency does not exist"},{"line_number":665,"context_line":""},{"line_number":666,"context_line":"    dep_creator can raise a DBDuplicateEntry to indicate that a concurrent"},{"line_number":667,"context_line":"    create of the dependency occured and the process will restart to get the"},{"line_number":668,"context_line":"    concurrently created one"},{"line_number":669,"context_line":""},{"line_number":670,"context_line":"    This function will return both the created object and the dependency it"}],"source_content_type":"text/x-python","patch_set":27,"id":"fa0719c6_5e836998","line":667,"updated":"2016-03-22 15:21:02.000000000","message":"occurred","commit_id":"4897a51a82d5f0aa2db52c41388602a1e4240c45"}],"neutron/db/l3_hamode_db.py":[{"author":{"_account_id":8124,"name":"cbrandily","email":"zzelle@gmail.com","username":"cbrandily"},"change_message_id":"abd4ea6af8b6ba48ffccd1d594a18061090f513f","unresolved":false,"context_lines":[{"line_number":348,"context_line":"        deletion \u003d functools.partial(self._core_plugin.delete_port, context,"},{"line_number":349,"context_line":"                                     l3_port_check\u003dFalse)"},{"line_number":350,"context_line":"        try:"},{"line_number":351,"context_line":"            port, bindings \u003d common_db_mixin.safe_creation(context, creation,"},{"line_number":352,"context_line":"                                                           deletion, content)"},{"line_number":353,"context_line":"        except db_exc.DBReferenceError as ex:"},{"line_number":354,"context_line":"            # router was likely concurrently deleted. issue a retry up to the"}],"source_content_type":"text/x-python","patch_set":4,"id":"bae84128_191c6d12","line":351,"range":{"start_line":351,"start_character":28,"end_line":351,"end_character":29},"updated":"2016-02-21 23:47:20.000000000","message":"I understand both changes in this module but i am not sure to understand how/if they are related, could you provide some details?","commit_id":"89dcd90cdb3872fc2968f8176f2b9c442575d295"},{"author":{"_account_id":9531,"name":"liuyulong","display_name":"LIU Yulong","email":"i@liuyulong.me","username":"LIU-Yulong"},"change_message_id":"6deb11eeccee4d69422eab27e3c191e7702a6044","unresolved":false,"context_lines":[{"line_number":415,"context_line":"        encounters after that."},{"line_number":416,"context_line":"        \"\"\""},{"line_number":417,"context_line":"        attempts \u003d 0"},{"line_number":418,"context_line":"        while True:"},{"line_number":419,"context_line":"            attempts +\u003d 1"},{"line_number":420,"context_line":"            ha_network \u003d self.get_ha_network(context,"},{"line_number":421,"context_line":"                                             router_db.tenant_id)"}],"source_content_type":"text/x-python","patch_set":11,"id":"bae84128_931491a0","line":418,"range":{"start_line":418,"start_character":18,"end_line":418,"end_character":19},"updated":"2016-02-23 10:28:32.000000000","message":"It\u0027s better to use \u0027for _ in range(db_api.MAX_RETRIES)\u0027 to replace this infinite loop ？","commit_id":"6dfc404d58daa539722fa03befba5a92a6dac108"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"7d350fa31ce0607d376471bec060a58b1252e013","unresolved":false,"context_lines":[{"line_number":415,"context_line":"        encounters after that."},{"line_number":416,"context_line":"        \"\"\""},{"line_number":417,"context_line":"        attempts \u003d 0"},{"line_number":418,"context_line":"        while True:"},{"line_number":419,"context_line":"            attempts +\u003d 1"},{"line_number":420,"context_line":"            ha_network \u003d self.get_ha_network(context,"},{"line_number":421,"context_line":"                                             router_db.tenant_id)"}],"source_content_type":"text/x-python","patch_set":11,"id":"bae84128_0165bab3","line":418,"updated":"2016-02-23 15:45:47.000000000","message":"Well it\u0027s not infinite because it will return on no exceptions or reraise after any exceptions if the attempts have exceeded. I can convert it to a for loop though if you aren\u0027t convinced that this will exit. However, it will mean more code because we need to raise an exception if the for loop exits.","commit_id":"6dfc404d58daa539722fa03befba5a92a6dac108"},{"author":{"_account_id":9531,"name":"liuyulong","display_name":"LIU Yulong","email":"i@liuyulong.me","username":"LIU-Yulong"},"change_message_id":"6deb11eeccee4d69422eab27e3c191e7702a6044","unresolved":false,"context_lines":[{"line_number":569,"context_line":"                    context, ha_network, router_db.extra_attributes.ha_vr_id)"},{"line_number":570,"context_line":"                self._delete_ha_interfaces(context, router_db.id)"},{"line_number":571,"context_line":""},{"line_number":572,"context_line":"                # always attempt to cleanup the network as the router is"},{"line_number":573,"context_line":"                # deleted. the core plugin will stop us if its in use"},{"line_number":574,"context_line":"                try:"},{"line_number":575,"context_line":"                    self._delete_ha_network(context, ha_network)"}],"source_content_type":"text/x-python","patch_set":11,"id":"bae84128_73ce2d2f","line":572,"range":{"start_line":572,"start_character":18,"end_line":572,"end_character":24},"updated":"2016-02-23 10:28:32.000000000","message":"Maybe add the a coder name for this aggression.","commit_id":"6dfc404d58daa539722fa03befba5a92a6dac108"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"7d350fa31ce0607d376471bec060a58b1252e013","unresolved":false,"context_lines":[{"line_number":569,"context_line":"                    context, ha_network, router_db.extra_attributes.ha_vr_id)"},{"line_number":570,"context_line":"                self._delete_ha_interfaces(context, router_db.id)"},{"line_number":571,"context_line":""},{"line_number":572,"context_line":"                # always attempt to cleanup the network as the router is"},{"line_number":573,"context_line":"                # deleted. the core plugin will stop us if its in use"},{"line_number":574,"context_line":"                try:"},{"line_number":575,"context_line":"                    self._delete_ha_network(context, ha_network)"}],"source_content_type":"text/x-python","patch_set":11,"id":"bae84128_615646cf","line":572,"updated":"2016-02-23 15:45:47.000000000","message":"what do you mean?","commit_id":"6dfc404d58daa539722fa03befba5a92a6dac108"},{"author":{"_account_id":13667,"name":"ZongKai LI","email":"onionpiece@163.com","username":"lzklibj"},"change_message_id":"fe61626ccb6ad1c62d1827b28a16929b8fdb3ac8","unresolved":false,"context_lines":[{"line_number":264,"context_line":"                # network is deleted and the process is started over where the"},{"line_number":265,"context_line":"                # existing network will be selected."},{"line_number":266,"context_line":"                for item in items:"},{"line_number":267,"context_line":"                    if item.tenant_id \u003d\u003d tenant_id:"},{"line_number":268,"context_line":"                        context.session.delete(item)"},{"line_number":269,"context_line":"                        raise db_exc.DBDuplicateEntry(columns\u003d[\u0027tenant_id\u0027])"},{"line_number":270,"context_line":"        return ha_network"}],"source_content_type":"text/x-python","patch_set":12,"id":"bae84128_b7522565","line":267,"range":{"start_line":267,"start_character":23,"end_line":267,"end_character":51},"updated":"2016-02-24 09:19:42.000000000","message":"Since it\u0027s filtered by tenant_id in L261, it\u0027s unnecessary to do checking here.","commit_id":"b2b7e3f41bd9455cdb3ed76c93d250458958537e"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"b88667b9c6b5d009adde076572ed99befcc926c1","unresolved":false,"context_lines":[{"line_number":264,"context_line":"                # network is deleted and the process is started over where the"},{"line_number":265,"context_line":"                # existing network will be selected."},{"line_number":266,"context_line":"                for item in items:"},{"line_number":267,"context_line":"                    if item.tenant_id \u003d\u003d tenant_id:"},{"line_number":268,"context_line":"                        context.session.delete(item)"},{"line_number":269,"context_line":"                        raise db_exc.DBDuplicateEntry(columns\u003d[\u0027tenant_id\u0027])"},{"line_number":270,"context_line":"        return ha_network"}],"source_content_type":"text/x-python","patch_set":12,"id":"bae84128_75198a79","line":267,"range":{"start_line":267,"start_character":23,"end_line":267,"end_character":51},"in_reply_to":"bae84128_b7522565","updated":"2016-02-24 19:20:51.000000000","message":"whoops, this is supposed to be network id.","commit_id":"b2b7e3f41bd9455cdb3ed76c93d250458958537e"},{"author":{"_account_id":13667,"name":"ZongKai LI","email":"onionpiece@163.com","username":"lzklibj"},"change_message_id":"fe61626ccb6ad1c62d1827b28a16929b8fdb3ac8","unresolved":false,"context_lines":[{"line_number":266,"context_line":"                for item in items:"},{"line_number":267,"context_line":"                    if item.tenant_id \u003d\u003d tenant_id:"},{"line_number":268,"context_line":"                        context.session.delete(item)"},{"line_number":269,"context_line":"                        raise db_exc.DBDuplicateEntry(columns\u003d[\u0027tenant_id\u0027])"},{"line_number":270,"context_line":"        return ha_network"},{"line_number":271,"context_line":""},{"line_number":272,"context_line":"    def _add_ha_network_settings(self, network):"}],"source_content_type":"text/x-python","patch_set":12,"id":"bae84128_fa5c941a","line":269,"updated":"2016-02-24 09:19:42.000000000","message":"Seems when case network tenant bindings are concurrently created happens, all the related bindings will deleted, is that make sense, shouldn\u0027t we keep one at least?","commit_id":"b2b7e3f41bd9455cdb3ed76c93d250458958537e"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"b88667b9c6b5d009adde076572ed99befcc926c1","unresolved":false,"context_lines":[{"line_number":266,"context_line":"                for item in items:"},{"line_number":267,"context_line":"                    if item.tenant_id \u003d\u003d tenant_id:"},{"line_number":268,"context_line":"                        context.session.delete(item)"},{"line_number":269,"context_line":"                        raise db_exc.DBDuplicateEntry(columns\u003d[\u0027tenant_id\u0027])"},{"line_number":270,"context_line":"        return ha_network"},{"line_number":271,"context_line":""},{"line_number":272,"context_line":"    def _add_ha_network_settings(self, network):"}],"source_content_type":"text/x-python","patch_set":12,"id":"bae84128_f523daa5","line":269,"in_reply_to":"bae84128_fa5c941a","updated":"2016-02-24 19:20:51.000000000","message":"L267 was a bug, this is only supposed to delete the one it created.","commit_id":"b2b7e3f41bd9455cdb3ed76c93d250458958537e"},{"author":{"_account_id":9531,"name":"liuyulong","display_name":"LIU Yulong","email":"i@liuyulong.me","username":"LIU-Yulong"},"change_message_id":"cd83f2a8145aeb47d8516f97b099de1aea5baa75","unresolved":false,"context_lines":[{"line_number":446,"context_line":"                            ctx.reraise \u003d False"},{"line_number":447,"context_line":"                            continue"},{"line_number":448,"context_line":"            try:"},{"line_number":449,"context_line":"                self._create_ha_interfaces(context, router_db, ha_network)"},{"line_number":450,"context_line":"                # our interfaces have been created and now the network can no"},{"line_number":451,"context_line":"                # longer be concurrently deleted by other workers automatically"},{"line_number":452,"context_line":"                # so it is safe to break and return"}],"source_content_type":"text/x-python","patch_set":12,"id":"bae84128_84c7ea94","line":449,"range":{"start_line":449,"start_character":42,"end_line":449,"end_character":43},"updated":"2016-02-24 10:31:46.000000000","message":"Here, consider a HA router need 3 HA ports for 3 L3 agents, but now only 2 available IP in the HA network subnet, here will retry MAX_RETRIES times and will never success, just waste time.\nAnd the same result for any other exceptions raised here.","commit_id":"b2b7e3f41bd9455cdb3ed76c93d250458958537e"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"b88667b9c6b5d009adde076572ed99befcc926c1","unresolved":false,"context_lines":[{"line_number":446,"context_line":"                            ctx.reraise \u003d False"},{"line_number":447,"context_line":"                            continue"},{"line_number":448,"context_line":"            try:"},{"line_number":449,"context_line":"                self._create_ha_interfaces(context, router_db, ha_network)"},{"line_number":450,"context_line":"                # our interfaces have been created and now the network can no"},{"line_number":451,"context_line":"                # longer be concurrently deleted by other workers automatically"},{"line_number":452,"context_line":"                # so it is safe to break and return"}],"source_content_type":"text/x-python","patch_set":12,"id":"bae84128_f5711aaa","line":449,"range":{"start_line":449,"start_character":42,"end_line":449,"end_character":43},"in_reply_to":"bae84128_84c7ea94","updated":"2016-02-24 19:20:51.000000000","message":"It doesn\u0027t matter right now. That\u0027s a corner case that can be optimized later.\n\n* Make it work\n\n* Make it right  (\u003c-- this is the step we are on, L3HA breaks under load and we need to prioritize fixing that)\n\n* Make it fast","commit_id":"b2b7e3f41bd9455cdb3ed76c93d250458958537e"},{"author":{"_account_id":9531,"name":"liuyulong","display_name":"LIU Yulong","email":"i@liuyulong.me","username":"LIU-Yulong"},"change_message_id":"cd83f2a8145aeb47d8516f97b099de1aea5baa75","unresolved":false,"context_lines":[{"line_number":588,"context_line":"                    context, ha_network, router_db.extra_attributes.ha_vr_id)"},{"line_number":589,"context_line":"                self._delete_ha_interfaces(context, router_db.id)"},{"line_number":590,"context_line":""},{"line_number":591,"context_line":"                # always attempt to cleanup the network as the router is"},{"line_number":592,"context_line":"                # deleted. the core plugin will stop us if its in use"},{"line_number":593,"context_line":"                try:"},{"line_number":594,"context_line":"                    self._delete_ha_network(context, ha_network)"}],"source_content_type":"text/x-python","patch_set":12,"id":"bae84128_64d906f3","line":591,"range":{"start_line":591,"start_character":18,"end_line":591,"end_character":24},"updated":"2016-02-24 10:31:46.000000000","message":"Add \u0027NOTE(someone):\u0027 for this aggression code.","commit_id":"b2b7e3f41bd9455cdb3ed76c93d250458958537e"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"b88667b9c6b5d009adde076572ed99befcc926c1","unresolved":false,"context_lines":[{"line_number":588,"context_line":"                    context, ha_network, router_db.extra_attributes.ha_vr_id)"},{"line_number":589,"context_line":"                self._delete_ha_interfaces(context, router_db.id)"},{"line_number":590,"context_line":""},{"line_number":591,"context_line":"                # always attempt to cleanup the network as the router is"},{"line_number":592,"context_line":"                # deleted. the core plugin will stop us if its in use"},{"line_number":593,"context_line":"                try:"},{"line_number":594,"context_line":"                    self._delete_ha_network(context, ha_network)"}],"source_content_type":"text/x-python","patch_set":12,"id":"bae84128_9561aed6","line":591,"range":{"start_line":591,"start_character":18,"end_line":591,"end_character":24},"in_reply_to":"bae84128_64d906f3","updated":"2016-02-24 19:20:51.000000000","message":"What is \u0027aggression\u0027 code?","commit_id":"b2b7e3f41bd9455cdb3ed76c93d250458958537e"},{"author":{"_account_id":8124,"name":"cbrandily","email":"zzelle@gmail.com","username":"cbrandily"},"change_message_id":"b4b945307d3c2c38e7d165f44fa54e704b8f4ebe","unresolved":false,"context_lines":[{"line_number":256,"context_line":"                                           network_id\u003dnetwork_id)"},{"line_number":257,"context_line":"            context.session.add(ha_network)"},{"line_number":258,"context_line":"        # we need to check if someone else just inserted at exactly the"},{"line_number":259,"context_line":"        # same time as us because there is no constrain in L3HARouterNetwork"},{"line_number":260,"context_line":"        # that prevents multiple networks per tenant"},{"line_number":261,"context_line":"        with context.session.begin(nested\u003dTrue):"},{"line_number":262,"context_line":"            items \u003d (context.session.query(L3HARouterNetwork)."}],"source_content_type":"text/x-python","patch_set":13,"id":"9aed3d3a_409f5a03","line":259,"range":{"start_line":259,"start_character":34,"end_line":259,"end_character":39},"updated":"2016-02-25 23:33:23.000000000","message":"we cannot add this db constraint to ensure a most one L3HANetwork per tenant?","commit_id":"abcb0e32a4fefbc3754045f2ad62cd4be2c04014"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"40ad3d61907eaa4352640ceb3c3a01de0f981fa4","unresolved":false,"context_lines":[{"line_number":256,"context_line":"                                           network_id\u003dnetwork_id)"},{"line_number":257,"context_line":"            context.session.add(ha_network)"},{"line_number":258,"context_line":"        # we need to check if someone else just inserted at exactly the"},{"line_number":259,"context_line":"        # same time as us because there is no constrain in L3HARouterNetwork"},{"line_number":260,"context_line":"        # that prevents multiple networks per tenant"},{"line_number":261,"context_line":"        with context.session.begin(nested\u003dTrue):"},{"line_number":262,"context_line":"            items \u003d (context.session.query(L3HARouterNetwork)."}],"source_content_type":"text/x-python","patch_set":13,"id":"9aed3d3a_e462f9d7","line":259,"range":{"start_line":259,"start_character":34,"end_line":259,"end_character":39},"in_reply_to":"9aed3d3a_409f5a03","updated":"2016-02-26 03:18:28.000000000","message":"I talked with Assaf about this on IRC. The reason the constraint wasn\u0027t there to start with was to eventually allow multiple networks to allow a tenant to have more than 255 HA routers. So once we have the code to manage multiple networks, this can be lifted.\n\nAlso, there is a risk that deployments out there already have a case where a tenant has two HA networks because of this race condition and the migration script would have to be quite complex to move the HA router over to the correct network and delete the duplicated one.","commit_id":"abcb0e32a4fefbc3754045f2ad62cd4be2c04014"},{"author":{"_account_id":12444,"name":"John Schwarz","email":"jschwarz@redhat.com","username":"jschwarz"},"change_message_id":"039f62d83d9f6279b515cbd5bab3acdbb9f855b6","unresolved":false,"context_lines":[{"line_number":455,"context_line":"                                                         router_db.tenant_id)"},{"line_number":456,"context_line":"                except db_exc.DBDuplicateEntry:"},{"line_number":457,"context_line":"                    # network was concurrently created by another"},{"line_number":458,"context_line":"                    # api worker. restart assuming we will find on next"},{"line_number":459,"context_line":"                    # iteration"},{"line_number":460,"context_line":"                    with excutils.save_and_reraise_exception() as ctx:"},{"line_number":461,"context_line":"                        if attempts \u003c db_api.MAX_RETRIES:"}],"source_content_type":"text/x-python","patch_set":15,"id":"9aed3d3a_0d3dcb8e","line":458,"range":{"start_line":458,"start_character":50,"end_line":458,"end_character":64},"updated":"2016-03-01 09:40:17.000000000","message":"nit: it\u0027s unclear what we\u0027ll find on the next iteration.","commit_id":"32209607a224c0823e19db0b83def639e6f16b33"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"edfb10825faadc5954923dbdb948252bdb3924c8","unresolved":false,"context_lines":[{"line_number":455,"context_line":"                                                         router_db.tenant_id)"},{"line_number":456,"context_line":"                except db_exc.DBDuplicateEntry:"},{"line_number":457,"context_line":"                    # network was concurrently created by another"},{"line_number":458,"context_line":"                    # api worker. restart assuming we will find on next"},{"line_number":459,"context_line":"                    # iteration"},{"line_number":460,"context_line":"                    with excutils.save_and_reraise_exception() as ctx:"},{"line_number":461,"context_line":"                        if attempts \u003c db_api.MAX_RETRIES:"}],"source_content_type":"text/x-python","patch_set":15,"id":"9aed3d3a_0dcdcb30","line":458,"range":{"start_line":458,"start_character":50,"end_line":458,"end_character":64},"in_reply_to":"9aed3d3a_0d3dcb8e","updated":"2016-03-01 09:46:46.000000000","message":"Done","commit_id":"32209607a224c0823e19db0b83def639e6f16b33"},{"author":{"_account_id":12444,"name":"John Schwarz","email":"jschwarz@redhat.com","username":"jschwarz"},"change_message_id":"039f62d83d9f6279b515cbd5bab3acdbb9f855b6","unresolved":false,"context_lines":[{"line_number":462,"context_line":"                            # sleep for a random time between 0 and 1 second to"},{"line_number":463,"context_line":"                            # make sure a concurrent worker doesn\u0027t retry again"},{"line_number":464,"context_line":"                            # at exactly the same time"},{"line_number":465,"context_line":"                            time.sleep(random.uniform(0, 1))"},{"line_number":466,"context_line":"                            ctx.reraise \u003d False"},{"line_number":467,"context_line":"                            continue"},{"line_number":468,"context_line":"            try:"}],"source_content_type":"text/x-python","patch_set":15,"id":"9aed3d3a_ed6b4783","line":465,"range":{"start_line":465,"start_character":28,"end_line":465,"end_character":32},"updated":"2016-03-01 09:40:17.000000000","message":"Using time.sleep() will block all eventlet threads. You want to use eventlet.sleep() instead.","commit_id":"32209607a224c0823e19db0b83def639e6f16b33"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"45491bdcdd71edd11ef735357982d3af69628043","unresolved":false,"context_lines":[{"line_number":462,"context_line":"                            # sleep for a random time between 0 and 1 second to"},{"line_number":463,"context_line":"                            # make sure a concurrent worker doesn\u0027t retry again"},{"line_number":464,"context_line":"                            # at exactly the same time"},{"line_number":465,"context_line":"                            time.sleep(random.uniform(0, 1))"},{"line_number":466,"context_line":"                            ctx.reraise \u003d False"},{"line_number":467,"context_line":"                            continue"},{"line_number":468,"context_line":"            try:"}],"source_content_type":"text/x-python","patch_set":15,"id":"9aed3d3a_2db9afcc","line":465,"range":{"start_line":465,"start_character":28,"end_line":465,"end_character":32},"in_reply_to":"9aed3d3a_ed6b4783","updated":"2016-03-01 09:46:15.000000000","message":"We call eventlet.monkey_patch() which swaps time.sleep with eventlet.sleep. http://eventlet.net/doc/patching.html#eventlet.patcher.monkey_patch","commit_id":"32209607a224c0823e19db0b83def639e6f16b33"},{"author":{"_account_id":7249,"name":"Ann Taraday","email":"akamyshnikova@mirantis.com","username":"AKamyshnikova"},"change_message_id":"48c4db66d221c3b53448dd1004cc3ff5a1e2d353","unresolved":false,"context_lines":[{"line_number":260,"context_line":"                                           network_id\u003dnetwork_id)"},{"line_number":261,"context_line":"            context.session.add(ha_network)"},{"line_number":262,"context_line":"        # we need to check if someone else just inserted at exactly the"},{"line_number":263,"context_line":"        # same time as us because there is no constrain in L3HARouterNetwork"},{"line_number":264,"context_line":"        # that prevents multiple networks per tenant"},{"line_number":265,"context_line":"        with context.session.begin(nested\u003dTrue):"},{"line_number":266,"context_line":"            items \u003d (context.session.query(L3HARouterNetwork)."}],"source_content_type":"text/x-python","patch_set":16,"id":"7af24918_733b1f39","line":263,"range":{"start_line":263,"start_character":34,"end_line":263,"end_character":76},"updated":"2016-03-02 09:32:14.000000000","message":"I understand why we do not add this constraint, but having constraint will be definitely more strict solution and may be it will be good to think this over in future.","commit_id":"8d799e17fc9d659aac030b7658214220c04b4f12"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"1bcf4feb450172d09d34c6cc39b8e3a4339dfca6","unresolved":false,"context_lines":[{"line_number":260,"context_line":"                                           network_id\u003dnetwork_id)"},{"line_number":261,"context_line":"            context.session.add(ha_network)"},{"line_number":262,"context_line":"        # we need to check if someone else just inserted at exactly the"},{"line_number":263,"context_line":"        # same time as us because there is no constrain in L3HARouterNetwork"},{"line_number":264,"context_line":"        # that prevents multiple networks per tenant"},{"line_number":265,"context_line":"        with context.session.begin(nested\u003dTrue):"},{"line_number":266,"context_line":"            items \u003d (context.session.query(L3HARouterNetwork)."}],"source_content_type":"text/x-python","patch_set":16,"id":"7af24918_8b3f5286","line":263,"updated":"2016-03-03 00:59:51.000000000","message":"If we try to add it we also need to handle the really complex migration to fix people on upgrade that have accidentally already hit this condition and have multiple L3 HA networks.","commit_id":"8d799e17fc9d659aac030b7658214220c04b4f12"},{"author":{"_account_id":7249,"name":"Ann Taraday","email":"akamyshnikova@mirantis.com","username":"AKamyshnikova"},"change_message_id":"2e78cf3b455b0d341b76bc9f50d3639f4be7790d","unresolved":false,"context_lines":[{"line_number":260,"context_line":"                                           network_id\u003dnetwork_id)"},{"line_number":261,"context_line":"            context.session.add(ha_network)"},{"line_number":262,"context_line":"        # we need to check if someone else just inserted at exactly the"},{"line_number":263,"context_line":"        # same time as us because there is no constrain in L3HARouterNetwork"},{"line_number":264,"context_line":"        # that prevents multiple networks per tenant"},{"line_number":265,"context_line":"        with context.session.begin(nested\u003dTrue):"},{"line_number":266,"context_line":"            items \u003d (context.session.query(L3HARouterNetwork)."}],"source_content_type":"text/x-python","patch_set":16,"id":"7af24918_b200a102","line":263,"in_reply_to":"7af24918_8b3f5286","updated":"2016-03-03 13:36:03.000000000","message":"Yes, I understand this, but I\u0027m not fully comfortable that we create ha_network and then delete it. Though I cannot suggest something better.","commit_id":"8d799e17fc9d659aac030b7658214220c04b4f12"},{"author":{"_account_id":9531,"name":"liuyulong","display_name":"LIU Yulong","email":"i@liuyulong.me","username":"LIU-Yulong"},"change_message_id":"14486a59318e703142049b4e5026a20292bdd974","unresolved":false,"context_lines":[{"line_number":449,"context_line":"            # errors at the end"},{"line_number":450,"context_line":"            ha_network \u003d self.get_ha_network(context,"},{"line_number":451,"context_line":"                                             router_db.tenant_id)"},{"line_number":452,"context_line":"            if not ha_network:"},{"line_number":453,"context_line":"                try:"},{"line_number":454,"context_line":"                    ha_network \u003d self._create_ha_network(context,"},{"line_number":455,"context_line":"                                                         router_db.tenant_id)"}],"source_content_type":"text/x-python","patch_set":16,"id":"7af24918_1bb9862e","line":452,"range":{"start_line":452,"start_character":29,"end_line":452,"end_character":30},"updated":"2016-03-04 02:00:55.000000000","message":"Assume that there are multiple API just run here for the same tenant, both will create HA network, one success, another raise DuplicateEntry and remove all HA network. Then Line 469 will not success. Try again, maybe the first conflict with the new third one, or the third and the fourth, and so on.","commit_id":"8d799e17fc9d659aac030b7658214220c04b4f12"},{"author":{"_account_id":9531,"name":"liuyulong","display_name":"LIU Yulong","email":"i@liuyulong.me","username":"LIU-Yulong"},"change_message_id":"9cefa446fdf9ce9163de0f95d7a4158d98e12822","unresolved":false,"context_lines":[{"line_number":449,"context_line":"            # errors at the end"},{"line_number":450,"context_line":"            ha_network \u003d self.get_ha_network(context,"},{"line_number":451,"context_line":"                                             router_db.tenant_id)"},{"line_number":452,"context_line":"            if not ha_network:"},{"line_number":453,"context_line":"                try:"},{"line_number":454,"context_line":"                    ha_network \u003d self._create_ha_network(context,"},{"line_number":455,"context_line":"                                                         router_db.tenant_id)"}],"source_content_type":"text/x-python","patch_set":16,"id":"7af24918_c92b9493","line":452,"range":{"start_line":452,"start_character":29,"end_line":452,"end_character":30},"in_reply_to":"7af24918_026c5506","updated":"2016-03-05 10:37:11.000000000","message":"Sorry for the inadequacy, seems this patch now is only dealing with the HA network not found/existed exception.","commit_id":"8d799e17fc9d659aac030b7658214220c04b4f12"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"fe137c6eae077d4f0c9d6c2521580593ad1efb12","unresolved":false,"context_lines":[{"line_number":449,"context_line":"            # errors at the end"},{"line_number":450,"context_line":"            ha_network \u003d self.get_ha_network(context,"},{"line_number":451,"context_line":"                                             router_db.tenant_id)"},{"line_number":452,"context_line":"            if not ha_network:"},{"line_number":453,"context_line":"                try:"},{"line_number":454,"context_line":"                    ha_network \u003d self._create_ha_network(context,"},{"line_number":455,"context_line":"                                                         router_db.tenant_id)"}],"source_content_type":"text/x-python","patch_set":16,"id":"7af24918_026c5506","line":452,"range":{"start_line":452,"start_character":29,"end_line":452,"end_character":30},"in_reply_to":"7af24918_1bb9862e","updated":"2016-03-04 15:36:27.000000000","message":"No, that\u0027s not correct. When one fails because of a duplicate, it will only delete its own network.","commit_id":"8d799e17fc9d659aac030b7658214220c04b4f12"},{"author":{"_account_id":9531,"name":"liuyulong","display_name":"LIU Yulong","email":"i@liuyulong.me","username":"LIU-Yulong"},"change_message_id":"14486a59318e703142049b4e5026a20292bdd974","unresolved":false,"context_lines":[{"line_number":466,"context_line":"                            ctx.reraise \u003d False"},{"line_number":467,"context_line":"                            continue"},{"line_number":468,"context_line":"            try:"},{"line_number":469,"context_line":"                self._create_ha_interfaces(context, router_db, ha_network)"},{"line_number":470,"context_line":"                # our interfaces have been created and now the network can no"},{"line_number":471,"context_line":"                # longer be concurrently deleted by other workers automatically"},{"line_number":472,"context_line":"                # so it is safe to break and return"}],"source_content_type":"text/x-python","patch_set":16,"id":"7af24918_5b614ea8","line":469,"updated":"2016-03-04 02:00:55.000000000","message":"And here, if HA network has no more available IP retry is no use, just waste of time, and let neutron server do useless work, delay execution of other API process.","commit_id":"8d799e17fc9d659aac030b7658214220c04b4f12"},{"author":{"_account_id":9531,"name":"liuyulong","display_name":"LIU Yulong","email":"i@liuyulong.me","username":"LIU-Yulong"},"change_message_id":"9cefa446fdf9ce9163de0f95d7a4158d98e12822","unresolved":false,"context_lines":[{"line_number":466,"context_line":"                            ctx.reraise \u003d False"},{"line_number":467,"context_line":"                            continue"},{"line_number":468,"context_line":"            try:"},{"line_number":469,"context_line":"                self._create_ha_interfaces(context, router_db, ha_network)"},{"line_number":470,"context_line":"                # our interfaces have been created and now the network can no"},{"line_number":471,"context_line":"                # longer be concurrently deleted by other workers automatically"},{"line_number":472,"context_line":"                # so it is safe to break and return"}],"source_content_type":"text/x-python","patch_set":16,"id":"7af24918_13092dde","line":469,"in_reply_to":"7af24918_023a95e6","updated":"2016-03-05 10:37:11.000000000","message":"Sorry for the inadequacy, seems that you added some code to L478 to  continue retry only when there is no HA network since patch set 14.","commit_id":"8d799e17fc9d659aac030b7658214220c04b4f12"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"fe137c6eae077d4f0c9d6c2521580593ad1efb12","unresolved":false,"context_lines":[{"line_number":466,"context_line":"                            ctx.reraise \u003d False"},{"line_number":467,"context_line":"                            continue"},{"line_number":468,"context_line":"            try:"},{"line_number":469,"context_line":"                self._create_ha_interfaces(context, router_db, ha_network)"},{"line_number":470,"context_line":"                # our interfaces have been created and now the network can no"},{"line_number":471,"context_line":"                # longer be concurrently deleted by other workers automatically"},{"line_number":472,"context_line":"                # so it is safe to break and return"}],"source_content_type":"text/x-python","patch_set":16,"id":"7af24918_023a95e6","line":469,"in_reply_to":"7af24918_5b614ea8","updated":"2016-03-04 15:36:27.000000000","message":"That\u0027s not correct, read the exception handler on L478. It will only retry if the ha network does not exist (i.e. it was deleted).","commit_id":"8d799e17fc9d659aac030b7658214220c04b4f12"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"e55b41d11196d0de2153882ee646bc54026c08d0","unresolved":false,"context_lines":[{"line_number":269,"context_line":"                # we need to now delete our binding and throw an error so our"},{"line_number":270,"context_line":"                # network is deleted and the process is started over where the"},{"line_number":271,"context_line":"                # existing network will be selected."},{"line_number":272,"context_line":"                for item in items:"},{"line_number":273,"context_line":"                    if item.network_id \u003d\u003d network_id:"},{"line_number":274,"context_line":"                        context.session.delete(item)"},{"line_number":275,"context_line":"                        raise db_exc.DBDuplicateEntry(columns\u003d[\u0027tenant_id\u0027])"}],"source_content_type":"text/x-python","patch_set":17,"id":"7af24918_1bbae96e","line":272,"updated":"2016-03-05 02:19:23.000000000","message":"Good catch.","commit_id":"1784a9314097bcb6098121189675c5f19e03ef4a"},{"author":{"_account_id":8873,"name":"Assaf Muller","email":"amuller@redhat.com","username":"amuller"},"change_message_id":"913dd7d78f0994f1fa424ce50c3a653f12544d08","unresolved":false,"context_lines":[{"line_number":269,"context_line":"                # we need to now delete our binding and throw an error so our"},{"line_number":270,"context_line":"                # network is deleted and the process is started over where the"},{"line_number":271,"context_line":"                # existing network will be selected."},{"line_number":272,"context_line":"                for item in items:"},{"line_number":273,"context_line":"                    if item.network_id \u003d\u003d network_id:"},{"line_number":274,"context_line":"                        context.session.delete(item)"},{"line_number":275,"context_line":"                        raise db_exc.DBDuplicateEntry(columns\u003d[\u0027tenant_id\u0027])"}],"source_content_type":"text/x-python","patch_set":17,"id":"7af24918_a072a047","line":272,"updated":"2016-03-05 01:17:30.000000000","message":"I think this block of code doesn\u0027t have test coverage.","commit_id":"1784a9314097bcb6098121189675c5f19e03ef4a"},{"author":{"_account_id":8873,"name":"Assaf Muller","email":"amuller@redhat.com","username":"amuller"},"change_message_id":"913dd7d78f0994f1fa424ce50c3a653f12544d08","unresolved":false,"context_lines":[{"line_number":271,"context_line":"                # existing network will be selected."},{"line_number":272,"context_line":"                for item in items:"},{"line_number":273,"context_line":"                    if item.network_id \u003d\u003d network_id:"},{"line_number":274,"context_line":"                        context.session.delete(item)"},{"line_number":275,"context_line":"                        raise db_exc.DBDuplicateEntry(columns\u003d[\u0027tenant_id\u0027])"},{"line_number":276,"context_line":"        return ha_network"},{"line_number":277,"context_line":""}],"source_content_type":"text/x-python","patch_set":17,"id":"7af24918_55e720ac","line":274,"updated":"2016-03-05 01:17:30.000000000","message":"Excuse my ignorance, how well is this going to work, when we\u0027re not deleting the network via the plugin layer, if we have a bunch of ML2 mech drivers loaded?","commit_id":"1784a9314097bcb6098121189675c5f19e03ef4a"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"e55b41d11196d0de2153882ee646bc54026c08d0","unresolved":false,"context_lines":[{"line_number":271,"context_line":"                # existing network will be selected."},{"line_number":272,"context_line":"                for item in items:"},{"line_number":273,"context_line":"                    if item.network_id \u003d\u003d network_id:"},{"line_number":274,"context_line":"                        context.session.delete(item)"},{"line_number":275,"context_line":"                        raise db_exc.DBDuplicateEntry(columns\u003d[\u0027tenant_id\u0027])"},{"line_number":276,"context_line":"        return ha_network"},{"line_number":277,"context_line":""}],"source_content_type":"text/x-python","patch_set":17,"id":"7af24918_7bafad2b","line":274,"updated":"2016-03-05 02:19:23.000000000","message":"This is just deleting the binding. However, after thinking about it this isn\u0027t necessary since safe_create is going to delete the network anyway. We just need to raise here.","commit_id":"1784a9314097bcb6098121189675c5f19e03ef4a"},{"author":{"_account_id":8873,"name":"Assaf Muller","email":"amuller@redhat.com","username":"amuller"},"change_message_id":"913dd7d78f0994f1fa424ce50c3a653f12544d08","unresolved":false,"context_lines":[{"line_number":429,"context_line":"            ha \u003d cfg.CONF.l3_ha"},{"line_number":430,"context_line":"        return ha"},{"line_number":431,"context_line":""},{"line_number":432,"context_line":"    def _create_ha_interfaces_and_ensure_network(self, context, router_db):"},{"line_number":433,"context_line":"        \"\"\"Attach interfaces to a network while tolerating network deletes."},{"line_number":434,"context_line":""},{"line_number":435,"context_line":"        The logic surrounding how HA networks for a tenant are managed is racey"}],"source_content_type":"text/x-python","patch_set":17,"id":"7af24918_f57c6ced","line":432,"updated":"2016-03-05 01:17:30.000000000","message":"We should future proof by insuring that context.session.is_active is False like you did in add_ha_port, otherwise the retry logic won\u0027t work because get_ha_network will return the same network in all iterations if we\u0027re working with \u0027repeated read\u0027.","commit_id":"1784a9314097bcb6098121189675c5f19e03ef4a"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"e55b41d11196d0de2153882ee646bc54026c08d0","unresolved":false,"context_lines":[{"line_number":429,"context_line":"            ha \u003d cfg.CONF.l3_ha"},{"line_number":430,"context_line":"        return ha"},{"line_number":431,"context_line":""},{"line_number":432,"context_line":"    def _create_ha_interfaces_and_ensure_network(self, context, router_db):"},{"line_number":433,"context_line":"        \"\"\"Attach interfaces to a network while tolerating network deletes."},{"line_number":434,"context_line":""},{"line_number":435,"context_line":"        The logic surrounding how HA networks for a tenant are managed is racey"}],"source_content_type":"text/x-python","patch_set":17,"id":"7af24918_5bac7135","line":432,"updated":"2016-03-05 02:19:23.000000000","message":"will do","commit_id":"1784a9314097bcb6098121189675c5f19e03ef4a"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"e55b41d11196d0de2153882ee646bc54026c08d0","unresolved":false,"context_lines":[{"line_number":471,"context_line":"                # longer be concurrently deleted by other workers automatically"},{"line_number":472,"context_line":"                # so it is safe to break and return"},{"line_number":473,"context_line":"                break"},{"line_number":474,"context_line":"            except Exception:"},{"line_number":475,"context_line":"                with excutils.save_and_reraise_exception() as ctx:"},{"line_number":476,"context_line":"                    # check if the network was deleted or changed out from"},{"line_number":477,"context_line":"                    # underneath us and retry if it was"}],"source_content_type":"text/x-python","patch_set":17,"id":"7af24918_bba93527","line":474,"updated":"2016-03-05 02:19:23.000000000","message":"I don\u0027t trust the core plugin to throw a consistent exception. Because it will probably be a reference error if the network is deleted after the get_network call (inside of create_port), but then it will be a network not found if before. And it could be something else if it happens later during dictionary extension processing... you get the point.","commit_id":"1784a9314097bcb6098121189675c5f19e03ef4a"},{"author":{"_account_id":8873,"name":"Assaf Muller","email":"amuller@redhat.com","username":"amuller"},"change_message_id":"913dd7d78f0994f1fa424ce50c3a653f12544d08","unresolved":false,"context_lines":[{"line_number":471,"context_line":"                # longer be concurrently deleted by other workers automatically"},{"line_number":472,"context_line":"                # so it is safe to break and return"},{"line_number":473,"context_line":"                break"},{"line_number":474,"context_line":"            except Exception:"},{"line_number":475,"context_line":"                with excutils.save_and_reraise_exception() as ctx:"},{"line_number":476,"context_line":"                    # check if the network was deleted or changed out from"},{"line_number":477,"context_line":"                    # underneath us and retry if it was"}],"source_content_type":"text/x-python","patch_set":17,"id":"7af24918_20b850e5","line":474,"updated":"2016-03-05 01:17:30.000000000","message":"If you catch specific exceptions, can you simplify/erase the logic in lines 479 to 483? For example if we tried to create a port but the network didn\u0027t exist, we should be able to catch a specific exception (ReferenceError?), in that case we know we have to just try again, no need for lines 480 to 483 right?","commit_id":"1784a9314097bcb6098121189675c5f19e03ef4a"},{"author":{"_account_id":8873,"name":"Assaf Muller","email":"amuller@redhat.com","username":"amuller"},"change_message_id":"913dd7d78f0994f1fa424ce50c3a653f12544d08","unresolved":false,"context_lines":[{"line_number":481,"context_line":"                            context, router_db.tenant_id)"},{"line_number":482,"context_line":"                        if not ha_network or ha_network.network_id !\u003d old_id:"},{"line_number":483,"context_line":"                            ctx.reraise \u003d False"},{"line_number":484,"context_line":"        return ha_network"},{"line_number":485,"context_line":""},{"line_number":486,"context_line":"    def create_router(self, context, router):"},{"line_number":487,"context_line":"        is_ha \u003d self._is_ha(router[\u0027router\u0027])"}],"source_content_type":"text/x-python","patch_set":17,"id":"7af24918_55d0c0c9","line":484,"updated":"2016-03-05 01:17:30.000000000","message":"I\u0027m not sure how intuitive it is for this method to return anything because the method does more than one thing. Could it be split between the creation of the network and the ports?","commit_id":"1784a9314097bcb6098121189675c5f19e03ef4a"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"e55b41d11196d0de2153882ee646bc54026c08d0","unresolved":false,"context_lines":[{"line_number":481,"context_line":"                            context, router_db.tenant_id)"},{"line_number":482,"context_line":"                        if not ha_network or ha_network.network_id !\u003d old_id:"},{"line_number":483,"context_line":"                            ctx.reraise \u003d False"},{"line_number":484,"context_line":"        return ha_network"},{"line_number":485,"context_line":""},{"line_number":486,"context_line":"    def create_router(self, context, router):"},{"line_number":487,"context_line":"        is_ha \u003d self._is_ha(router[\u0027router\u0027])"}],"source_content_type":"text/x-python","patch_set":17,"id":"7af24918_9ba6f951","line":484,"updated":"2016-03-05 02:19:23.000000000","message":"Maybe it should return both.","commit_id":"1784a9314097bcb6098121189675c5f19e03ef4a"},{"author":{"_account_id":7249,"name":"Ann Taraday","email":"akamyshnikova@mirantis.com","username":"AKamyshnikova"},"change_message_id":"0b7a6bb038aeb01f9f1efcafcba01c9a4139cf28","unresolved":false,"context_lines":[{"line_number":430,"context_line":"        if context.session.is_active:"},{"line_number":431,"context_line":"            # sanity check to make sure developers call this correctly."},{"line_number":432,"context_line":"            # TODO(kevinbenton): replace this with decorator in"},{"line_number":433,"context_line":"            # I5c00b186585369ef6c8e2b9cb5a43b8bba0e5a7c once it merges"},{"line_number":434,"context_line":"            raise RuntimeError(_(\u0027interfaces cannot be created inside of a \u0027"},{"line_number":435,"context_line":"                                 \u0027transaction.\u0027))"},{"line_number":436,"context_line":"        creator \u003d functools.partial(self._create_ha_interfaces,"}],"source_content_type":"text/x-python","patch_set":23,"id":"3afc51ec_89a4c1a6","line":433,"range":{"start_line":433,"start_character":14,"end_line":433,"end_character":55},"updated":"2016-03-14 08:44:56.000000000","message":"as far as I see this one is already merged","commit_id":"f83328c80dc3eb29c8bbb2c0571735e7f4f91898"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"874d983582397e2785fef3e6ec022f8e28410a57","unresolved":false,"context_lines":[{"line_number":430,"context_line":"        if context.session.is_active:"},{"line_number":431,"context_line":"            # sanity check to make sure developers call this correctly."},{"line_number":432,"context_line":"            # TODO(kevinbenton): replace this with decorator in"},{"line_number":433,"context_line":"            # I5c00b186585369ef6c8e2b9cb5a43b8bba0e5a7c once it merges"},{"line_number":434,"context_line":"            raise RuntimeError(_(\u0027interfaces cannot be created inside of a \u0027"},{"line_number":435,"context_line":"                                 \u0027transaction.\u0027))"},{"line_number":436,"context_line":"        creator \u003d functools.partial(self._create_ha_interfaces,"}],"source_content_type":"text/x-python","patch_set":23,"id":"3afc51ec_93904745","line":433,"updated":"2016-03-14 18:07:28.000000000","message":"yep, i can update this now","commit_id":"f83328c80dc3eb29c8bbb2c0571735e7f4f91898"},{"author":{"_account_id":12444,"name":"John Schwarz","email":"jschwarz@redhat.com","username":"jschwarz"},"change_message_id":"d2ce491740dbca9d1348d289c282c894dd27e12d","unresolved":false,"context_lines":[{"line_number":429,"context_line":"    def _create_ha_interfaces_and_ensure_network(self, context, router_db):"},{"line_number":430,"context_line":"        \"\"\"Attach interfaces to a network while tolerating network deletes.\"\"\""},{"line_number":431,"context_line":"        if context.session.is_active:"},{"line_number":432,"context_line":"            # sanity check to make sure developers call this correctly."},{"line_number":433,"context_line":"            # TODO(kevinbenton): replace this with decorator in"},{"line_number":434,"context_line":"            # I5c00b186585369ef6c8e2b9cb5a43b8bba0e5a7c once it merges"},{"line_number":435,"context_line":"            raise RuntimeError(_(\u0027interfaces cannot be created inside of a \u0027"},{"line_number":436,"context_line":"                                 \u0027transaction.\u0027))"},{"line_number":437,"context_line":"        creator \u003d functools.partial(self._create_ha_interfaces,"}],"source_content_type":"text/x-python","patch_set":25,"id":"3afc51ec_d6faa174","line":434,"range":{"start_line":432,"start_character":12,"end_line":434,"end_character":70},"updated":"2016-03-15 13:28:35.000000000","message":"Since we\u0027re using the transaction guard, this code can be removed now.","commit_id":"e150416f3127b6841624fc4e2fa28899fb5d640c"},{"author":{"_account_id":10267,"name":"venkata anil","email":"anilvenkata@redhat.com","username":"anil"},"change_message_id":"8292b5d653bb18df9597489843ff7bdd2ca9f4da","unresolved":false,"context_lines":[{"line_number":259,"context_line":"            context.session.add(ha_network)"},{"line_number":260,"context_line":"        # we need to check if someone else just inserted at exactly the"},{"line_number":261,"context_line":"        # same time as us because there is no constrain in L3HARouterNetwork"},{"line_number":262,"context_line":"        # that prevents multiple networks per tenant"},{"line_number":263,"context_line":"        with context.session.begin(subtransactions\u003dTrue):"},{"line_number":264,"context_line":"            items \u003d (context.session.query(L3HARouterNetwork)."},{"line_number":265,"context_line":"                     filter_by(tenant_id\u003dtenant_id).all())"}],"source_content_type":"text/x-python","patch_set":26,"id":"1af94dfe_fcd80155","line":262,"updated":"2016-03-19 06:01:03.000000000","message":"But this doesn\u0027t prevent two different tenants using same network. \"Two different tenants using same network\" doesn\u0027t happen as get_ha_network is queried using tenant_id, so if tenant_id not present in table, new network created for the (new) tenant. So this is not an issue.\n\n\nI feel DB constraints are better than code checks to avoid duplicate entries(i.e \"for duplicate tenant_id\") during concurrencies. We can impose DB constraint by removing \"primary_key\" for network_id in L3HARouterNetwork table i.e\nhttps://github.com/openstack/neutron/blob/master/neutron/db/l3_hamode_db.py#L133\nand allowing primary_key only for tenant_id.","commit_id":"b8dd8d888eb7b6786904ee502bae157e68b57ec3"},{"author":{"_account_id":9531,"name":"liuyulong","display_name":"LIU Yulong","email":"i@liuyulong.me","username":"LIU-Yulong"},"change_message_id":"ec8ad85f06ecb9c5cad2eac570e5e47eef343a47","unresolved":false,"context_lines":[{"line_number":436,"context_line":"                                        context, router_db.tenant_id)"},{"line_number":437,"context_line":"        dep_id_attr \u003d \u0027network_id\u0027"},{"line_number":438,"context_line":"        return n_utils.create_object_with_dependency("},{"line_number":439,"context_line":"            creator, dep_getter, dep_creator, dep_id_attr)"},{"line_number":440,"context_line":""},{"line_number":441,"context_line":"    def create_router(self, context, router):"},{"line_number":442,"context_line":"        is_ha \u003d self._is_ha(router[\u0027router\u0027])"}],"source_content_type":"text/x-python","patch_set":26,"id":"fa0719c6_e8aac618","line":439,"range":{"start_line":439,"start_character":46,"end_line":439,"end_character":57},"updated":"2016-03-21 12:34:45.000000000","message":"Why not directly \u0027network_id\u0027 ? or \"dep_id_attr\u003d\u0027network_id\u0027\"?","commit_id":"b8dd8d888eb7b6786904ee502bae157e68b57ec3"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"5f0f16e852cb14a0784efa8e2cd0f805c7b6567a","unresolved":false,"context_lines":[{"line_number":436,"context_line":"                                        context, router_db.tenant_id)"},{"line_number":437,"context_line":"        dep_id_attr \u003d \u0027network_id\u0027"},{"line_number":438,"context_line":"        return n_utils.create_object_with_dependency("},{"line_number":439,"context_line":"            creator, dep_getter, dep_creator, dep_id_attr)"},{"line_number":440,"context_line":""},{"line_number":441,"context_line":"    def create_router(self, context, router):"},{"line_number":442,"context_line":"        is_ha \u003d self._is_ha(router[\u0027router\u0027])"}],"source_content_type":"text/x-python","patch_set":26,"id":"fa0719c6_cb6ec0c8","line":439,"updated":"2016-03-21 20:57:21.000000000","message":"just consistency with the rest of the built up arguments above","commit_id":"b8dd8d888eb7b6786904ee502bae157e68b57ec3"}],"neutron/scheduler/l3_agent_scheduler.py":[{"author":{"_account_id":9531,"name":"liuyulong","display_name":"LIU Yulong","email":"i@liuyulong.me","username":"LIU-Yulong"},"change_message_id":"3495b1106d63f8c8d2cefffdc63564255b1edde6","unresolved":false,"context_lines":[{"line_number":268,"context_line":"        creator \u003d functools.partial(self._add_port_from_net,"},{"line_number":269,"context_line":"                                    plugin, ctxt, router_id, tenant_id)"},{"line_number":270,"context_line":"        dep_getter \u003d functools.partial(plugin.get_ha_network, ctxt, tenant_id)"},{"line_number":271,"context_line":"        dep_creator \u003d functools.partial(plugin._create_ha_network,"},{"line_number":272,"context_line":"                                        ctxt, tenant_id)"},{"line_number":273,"context_line":"        dep_id_attr \u003d \u0027network_id\u0027"},{"line_number":274,"context_line":"        try:"}],"source_content_type":"text/x-python","patch_set":23,"id":"3afc51ec_942691cc","line":271,"range":{"start_line":271,"start_character":40,"end_line":271,"end_character":66},"updated":"2016-03-14 10:02:34.000000000","message":"Here is similar to John Schwarz\u0027s patch https://review.openstack.org/#/c/284400/9/neutron/scheduler/l3_agent_scheduler.py, which also has a HA network creation expression. It could be a race condition for some scenarios like below:\n1. Create the first(last) HA router\n2. l3 agent sync router info\n3. HA router delete API comes, concurrently, delete HA router and HA network\n4. concurrently, RPC worker go to auto_schedule_router\n5. then here try to create the HA port\n6. there is no HA network then retry to create one (dep_creator)\n7. finally HA port creation procedure meeds RouterNotFound.\n8. then HA network will remain. This may against the purpose of https://bugs.launchpad.net/neutron/+bug/1367157.\n\nAs we discuss there, do not make shared resource, HA network, a multiple creation path.","commit_id":"f83328c80dc3eb29c8bbb2c0571735e7f4f91898"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"7e532e159f69bb7dc11fb16d1f17a5d047d18887","unresolved":false,"context_lines":[{"line_number":268,"context_line":"        creator \u003d functools.partial(self._add_port_from_net,"},{"line_number":269,"context_line":"                                    plugin, ctxt, router_id, tenant_id)"},{"line_number":270,"context_line":"        dep_getter \u003d functools.partial(plugin.get_ha_network, ctxt, tenant_id)"},{"line_number":271,"context_line":"        dep_creator \u003d functools.partial(plugin._create_ha_network,"},{"line_number":272,"context_line":"                                        ctxt, tenant_id)"},{"line_number":273,"context_line":"        dep_id_attr \u003d \u0027network_id\u0027"},{"line_number":274,"context_line":"        try:"}],"source_content_type":"text/x-python","patch_set":23,"id":"3afc51ec_52eb4478","line":271,"updated":"2016-03-15 06:45:17.000000000","message":"No it doesn\u0027t. It reduces the probability of leaving an orphan because port creation will need to fail 10 times before an orphan is left rather than only needing to fail once.\n\nRemember, if you make a statement like this in a code review, please provide pointers or examples supporting your claim.","commit_id":"f83328c80dc3eb29c8bbb2c0571735e7f4f91898"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"874d983582397e2785fef3e6ec022f8e28410a57","unresolved":false,"context_lines":[{"line_number":268,"context_line":"        creator \u003d functools.partial(self._add_port_from_net,"},{"line_number":269,"context_line":"                                    plugin, ctxt, router_id, tenant_id)"},{"line_number":270,"context_line":"        dep_getter \u003d functools.partial(plugin.get_ha_network, ctxt, tenant_id)"},{"line_number":271,"context_line":"        dep_creator \u003d functools.partial(plugin._create_ha_network,"},{"line_number":272,"context_line":"                                        ctxt, tenant_id)"},{"line_number":273,"context_line":"        dep_id_attr \u003d \u0027network_id\u0027"},{"line_number":274,"context_line":"        try:"}],"source_content_type":"text/x-python","patch_set":23,"id":"3afc51ec_3373334f","line":271,"updated":"2016-03-14 18:07:28.000000000","message":"The logic creating the network in the create_router function can already leave an orphaned network on a failure. There is nothing new here.","commit_id":"f83328c80dc3eb29c8bbb2c0571735e7f4f91898"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"c2fdac1f05e520cec69907047bdebb5dcfd0cbfd","unresolved":false,"context_lines":[{"line_number":268,"context_line":"        creator \u003d functools.partial(self._add_port_from_net,"},{"line_number":269,"context_line":"                                    plugin, ctxt, router_id, tenant_id)"},{"line_number":270,"context_line":"        dep_getter \u003d functools.partial(plugin.get_ha_network, ctxt, tenant_id)"},{"line_number":271,"context_line":"        dep_creator \u003d functools.partial(plugin._create_ha_network,"},{"line_number":272,"context_line":"                                        ctxt, tenant_id)"},{"line_number":273,"context_line":"        dep_id_attr \u003d \u0027network_id\u0027"},{"line_number":274,"context_line":"        try:"}],"source_content_type":"text/x-python","patch_set":23,"id":"1af94dfe_f85f4873","line":271,"in_reply_to":"1af94dfe_e4b96bee","updated":"2016-03-15 14:51:07.000000000","message":"I don\u0027t know what you mean by \"extend the race effect\". The race condition that was in the scheduler before was that the scheduling would completely break if the ha network was deleted during this operation. This fixes the broken scheduling and introduces the possibility of an orphaned network if it still fails to maintain the network after 10 iterations.\n\nSo it\u0027s replacing something that completely breaks with something that could leave a leftover network, I\u0027m not sure what is being extended. Can you please explain?","commit_id":"f83328c80dc3eb29c8bbb2c0571735e7f4f91898"},{"author":{"_account_id":9531,"name":"liuyulong","display_name":"LIU Yulong","email":"i@liuyulong.me","username":"LIU-Yulong"},"change_message_id":"d8e1ef7c2892101109355b83ad6176cc6d40e718","unresolved":false,"context_lines":[{"line_number":268,"context_line":"        creator \u003d functools.partial(self._add_port_from_net,"},{"line_number":269,"context_line":"                                    plugin, ctxt, router_id, tenant_id)"},{"line_number":270,"context_line":"        dep_getter \u003d functools.partial(plugin.get_ha_network, ctxt, tenant_id)"},{"line_number":271,"context_line":"        dep_creator \u003d functools.partial(plugin._create_ha_network,"},{"line_number":272,"context_line":"                                        ctxt, tenant_id)"},{"line_number":273,"context_line":"        dep_id_attr \u003d \u0027network_id\u0027"},{"line_number":274,"context_line":"        try:"}],"source_content_type":"text/x-python","patch_set":23,"id":"3afc51ec_d672ab48","line":271,"in_reply_to":"3afc51ec_3373334f","updated":"2016-03-15 03:49:30.000000000","message":"This creation extends the race effect.","commit_id":"f83328c80dc3eb29c8bbb2c0571735e7f4f91898"},{"author":{"_account_id":9531,"name":"liuyulong","display_name":"LIU Yulong","email":"i@liuyulong.me","username":"LIU-Yulong"},"change_message_id":"43c5126ffbc2377d1a943e3dab5b33b9bf4950f0","unresolved":false,"context_lines":[{"line_number":268,"context_line":"        creator \u003d functools.partial(self._add_port_from_net,"},{"line_number":269,"context_line":"                                    plugin, ctxt, router_id, tenant_id)"},{"line_number":270,"context_line":"        dep_getter \u003d functools.partial(plugin.get_ha_network, ctxt, tenant_id)"},{"line_number":271,"context_line":"        dep_creator \u003d functools.partial(plugin._create_ha_network,"},{"line_number":272,"context_line":"                                        ctxt, tenant_id)"},{"line_number":273,"context_line":"        dep_id_attr \u003d \u0027network_id\u0027"},{"line_number":274,"context_line":"        try:"}],"source_content_type":"text/x-python","patch_set":23,"id":"1af94dfe_e4b96bee","line":271,"in_reply_to":"3afc51ec_52eb4478","updated":"2016-03-15 13:43:50.000000000","message":"Why the race condition need a \"10 times fail\" ? For the original auto_scheduler_router code procedure, there was no chance to CREATE an orphan HA network, but after this, it does, which means \"extends the race effect\".\n\nObviously, the pointers or examples, for this series of comments are all under the marked, `Yellow Highlight`, expression \"plugin._create_ha_network\".","commit_id":"f83328c80dc3eb29c8bbb2c0571735e7f4f91898"},{"author":{"_account_id":9531,"name":"liuyulong","display_name":"LIU Yulong","email":"i@liuyulong.me","username":"LIU-Yulong"},"change_message_id":"ec8ad85f06ecb9c5cad2eac570e5e47eef343a47","unresolved":false,"context_lines":[{"line_number":264,"context_line":"    def create_ha_port_and_bind(self, plugin, context, router_id,"},{"line_number":265,"context_line":"                                tenant_id, agent):"},{"line_number":266,"context_line":"        \"\"\"Creates and binds a new HA port for this agent.\"\"\""},{"line_number":267,"context_line":"        ctxt \u003d context.elevated()"},{"line_number":268,"context_line":"        creator \u003d functools.partial(self._add_port_from_net,"},{"line_number":269,"context_line":"                                    plugin, ctxt, router_id, tenant_id)"},{"line_number":270,"context_line":"        dep_getter \u003d functools.partial(plugin.get_ha_network, ctxt, tenant_id)"},{"line_number":271,"context_line":"        dep_creator \u003d functools.partial(plugin._create_ha_network,"},{"line_number":272,"context_line":"                                        ctxt, tenant_id)"},{"line_number":273,"context_line":"        dep_id_attr \u003d \u0027network_id\u0027"},{"line_number":274,"context_line":"        try:"},{"line_number":275,"context_line":"            port_binding \u003d utils.create_object_with_dependency("}],"source_content_type":"text/x-python","patch_set":26,"id":"fa0719c6_e8dbe619","line":272,"range":{"start_line":267,"start_character":0,"end_line":272,"end_character":56},"updated":"2016-03-21 12:34:45.000000000","message":"If this patch will be merged, please add test code for this. In particular, please make sure test code covered  \"plugin._create_ha_network\" to simulate the orphan HA network.","commit_id":"b8dd8d888eb7b6786904ee502bae157e68b57ec3"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"5f0f16e852cb14a0784efa8e2cd0f805c7b6567a","unresolved":false,"context_lines":[{"line_number":269,"context_line":"                                    plugin, ctxt, router_id, tenant_id)"},{"line_number":270,"context_line":"        dep_getter \u003d functools.partial(plugin.get_ha_network, ctxt, tenant_id)"},{"line_number":271,"context_line":"        dep_creator \u003d functools.partial(plugin._create_ha_network,"},{"line_number":272,"context_line":"                                        ctxt, tenant_id)"},{"line_number":273,"context_line":"        dep_id_attr \u003d \u0027network_id\u0027"},{"line_number":274,"context_line":"        try:"},{"line_number":275,"context_line":"            port_binding \u003d utils.create_object_with_dependency("}],"source_content_type":"text/x-python","patch_set":26,"id":"fa0719c6_8b74c89c","line":272,"updated":"2016-03-21 20:57:21.000000000","message":"What is the purpose of simulating an orphan network? That sounds like a test that belongs in the patch the depends on this one.","commit_id":"b8dd8d888eb7b6786904ee502bae157e68b57ec3"},{"author":{"_account_id":12444,"name":"John Schwarz","email":"jschwarz@redhat.com","username":"jschwarz"},"change_message_id":"1086e7bbbc28fe3ba2c8e3e198551afc6118c2c3","unresolved":false,"context_lines":[{"line_number":269,"context_line":"                                    plugin, ctxt, router_id, tenant_id)"},{"line_number":270,"context_line":"        dep_getter \u003d functools.partial(plugin.get_ha_network, ctxt, tenant_id)"},{"line_number":271,"context_line":"        dep_creator \u003d functools.partial(plugin._create_ha_network,"},{"line_number":272,"context_line":"                                        ctxt, tenant_id)"},{"line_number":273,"context_line":"        dep_id_attr \u003d \u0027network_id\u0027"},{"line_number":274,"context_line":"        try:"},{"line_number":275,"context_line":"            port_binding \u003d utils.create_object_with_dependency("}],"source_content_type":"text/x-python","patch_set":26,"id":"fa0719c6_ff57e5ff","line":272,"in_reply_to":"fa0719c6_04e9ac80","updated":"2016-03-22 12:41:32.000000000","message":"as Kevin said before: we are fine with this code leaving an orphaned HA network, since followup patches will deal with this issue.","commit_id":"b8dd8d888eb7b6786904ee502bae157e68b57ec3"},{"author":{"_account_id":9531,"name":"liuyulong","display_name":"LIU Yulong","email":"i@liuyulong.me","username":"LIU-Yulong"},"change_message_id":"a704c39bdcef1737820b93fe26c74afa374b179f","unresolved":false,"context_lines":[{"line_number":269,"context_line":"                                    plugin, ctxt, router_id, tenant_id)"},{"line_number":270,"context_line":"        dep_getter \u003d functools.partial(plugin.get_ha_network, ctxt, tenant_id)"},{"line_number":271,"context_line":"        dep_creator \u003d functools.partial(plugin._create_ha_network,"},{"line_number":272,"context_line":"                                        ctxt, tenant_id)"},{"line_number":273,"context_line":"        dep_id_attr \u003d \u0027network_id\u0027"},{"line_number":274,"context_line":"        try:"},{"line_number":275,"context_line":"            port_binding \u003d utils.create_object_with_dependency("}],"source_content_type":"text/x-python","patch_set":26,"id":"fa0719c6_659238a1","line":272,"in_reply_to":"fa0719c6_255b2030","updated":"2016-03-22 02:29:25.000000000","message":"It\u0027s the race scenario I described in patch set 23. https://review.openstack.org/#/c/282876/23/neutron/scheduler/l3_agent_scheduler.py\nHA network has a multiple creation path.","commit_id":"b8dd8d888eb7b6786904ee502bae157e68b57ec3"},{"author":{"_account_id":12444,"name":"John Schwarz","email":"jschwarz@redhat.com","username":"jschwarz"},"change_message_id":"9d39750df6b6863d4b98f392062fb718e7017793","unresolved":false,"context_lines":[{"line_number":269,"context_line":"                                    plugin, ctxt, router_id, tenant_id)"},{"line_number":270,"context_line":"        dep_getter \u003d functools.partial(plugin.get_ha_network, ctxt, tenant_id)"},{"line_number":271,"context_line":"        dep_creator \u003d functools.partial(plugin._create_ha_network,"},{"line_number":272,"context_line":"                                        ctxt, tenant_id)"},{"line_number":273,"context_line":"        dep_id_attr \u003d \u0027network_id\u0027"},{"line_number":274,"context_line":"        try:"},{"line_number":275,"context_line":"            port_binding \u003d utils.create_object_with_dependency("}],"source_content_type":"text/x-python","patch_set":26,"id":"fa0719c6_d64f7cbb","line":272,"in_reply_to":"fa0719c6_659238a1","updated":"2016-03-22 06:13:29.000000000","message":"A test that produces a race (or lack of thereof) is expected to actually call 2 separate code flows with some settings/timings and show that a possible scenario is not possible. For example, [1] is such a test - it triggers the actual code and makes sure that something that can be called simultaneously by 2 different eventlet threads is only called once.\n\nLiu, your test doesn\u0027t produce a race - it simply calls create_ha_port_and_bind (where the \u0027create_ha_port\u0027 and \u0027bind\u0027 functionality are mocked and won\u0027t run), so all the function is left to do is to call _create_ha_network, which is what\u0027s checked. Moreover, it doesn\u0027t provide a \u0027multiple creation path\u0027 check since it doesn\u0027t actually verify that the ha network was created twice.\n\nWhat\u0027s more confusing is that you provide a test for \"a multiple creation path\" on the topic of \"orphan network\". Please keep the conversations separate to make reviewing easier.\n\n[1]: https://github.com/openstack/neutron/blob/deb3a61a622ad16bf93e3061979892056e8f3aee/neutron/tests/unit/agent/linux/test_async_process.py#L289","commit_id":"b8dd8d888eb7b6786904ee502bae157e68b57ec3"},{"author":{"_account_id":9531,"name":"liuyulong","display_name":"LIU Yulong","email":"i@liuyulong.me","username":"LIU-Yulong"},"change_message_id":"1c5e9d2ca053664f13730caced6401233c192d20","unresolved":false,"context_lines":[{"line_number":269,"context_line":"                                    plugin, ctxt, router_id, tenant_id)"},{"line_number":270,"context_line":"        dep_getter \u003d functools.partial(plugin.get_ha_network, ctxt, tenant_id)"},{"line_number":271,"context_line":"        dep_creator \u003d functools.partial(plugin._create_ha_network,"},{"line_number":272,"context_line":"                                        ctxt, tenant_id)"},{"line_number":273,"context_line":"        dep_id_attr \u003d \u0027network_id\u0027"},{"line_number":274,"context_line":"        try:"},{"line_number":275,"context_line":"            port_binding \u003d utils.create_object_with_dependency("}],"source_content_type":"text/x-python","patch_set":26,"id":"fa0719c6_255b2030","line":272,"in_reply_to":"fa0719c6_8b74c89c","updated":"2016-03-22 02:24:08.000000000","message":"neutron.tests.unit.scheduler.test_l3_agent_scheduler.L3HATestCaseMixin.test_create_ha_port_and_bind_hanetwork_was_concurrently_deleted\n\n    def test_create_ha_port_and_bind_hanetwork_was_concurrently_deleted(self):\n        # Origin HA network was deleted beacause the last HA route was deleted.\n        # And concurrently a l3 agent sync router info RPC run here.\n        tenant_id \u003d str(uuid.uuid4())\n        agent \u003d {\u0027id\u0027: \u0027foo_agent\u0027}\n        nets_before \u003d [net[\u0027name\u0027] for net in\n                       self.plugin.get_networks(self.adminContext)]\n        self.assertNotIn(\u0027HA network tenant %s\u0027 % tenant_id,\n                         nets_before)\n\n        with mock.patch.object(self.plugin.router_scheduler,\n                               \u0027bind_router\u0027) as bind_router:\n            with mock.patch.object(self.plugin, \u0027add_ha_port\u0027,\n                                   return_value\u003dmock.Mock()):\n                self.plugin.router_scheduler.create_ha_port_and_bind(\n                    self.plugin, self.adminContext,\n                    \u0027foo_router\u0027, tenant_id, agent)\n\n                nets_after \u003d [net[\u0027name\u0027] for net in\n                    self.plugin.get_networks(self.adminContext)]\n                # orphan HA network\n                self.assertIn(\u0027HA network tenant %s\u0027 % tenant_id,\n                    nets_after)\n\n                self.assertTrue(bind_router.called)","commit_id":"b8dd8d888eb7b6786904ee502bae157e68b57ec3"},{"author":{"_account_id":9531,"name":"liuyulong","display_name":"LIU Yulong","email":"i@liuyulong.me","username":"LIU-Yulong"},"change_message_id":"91f15c8832a1891eb4868da178e544c358ccf89a","unresolved":false,"context_lines":[{"line_number":269,"context_line":"                                    plugin, ctxt, router_id, tenant_id)"},{"line_number":270,"context_line":"        dep_getter \u003d functools.partial(plugin.get_ha_network, ctxt, tenant_id)"},{"line_number":271,"context_line":"        dep_creator \u003d functools.partial(plugin._create_ha_network,"},{"line_number":272,"context_line":"                                        ctxt, tenant_id)"},{"line_number":273,"context_line":"        dep_id_attr \u003d \u0027network_id\u0027"},{"line_number":274,"context_line":"        try:"},{"line_number":275,"context_line":"            port_binding \u003d utils.create_object_with_dependency("}],"source_content_type":"text/x-python","patch_set":26,"id":"fa0719c6_04e9ac80","line":272,"in_reply_to":"fa0719c6_d64f7cbb","updated":"2016-03-22 12:38:38.000000000","message":"The test code just let the race condition happen, the tenant has no HA network because of a deletion API of last HA router.\nAnd the test code has a comment:\n\"\"\"\n# Origin HA network was deleted because the last HA route was deleted.\n# And concurrently a l3 agent sync router info RPC run here.\n\"\"\"\n\nThis patch is dealing with a small chance race condition. And the test code just tells you another small change race which was introduced by this patch code \"plugin._create_ha_network\". The new race condition here will have a chance to leave an orphan HA network.","commit_id":"b8dd8d888eb7b6786904ee502bae157e68b57ec3"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"5f0f16e852cb14a0784efa8e2cd0f805c7b6567a","unresolved":false,"context_lines":[{"line_number":273,"context_line":"        dep_id_attr \u003d \u0027network_id\u0027"},{"line_number":274,"context_line":"        try:"},{"line_number":275,"context_line":"            port_binding \u003d utils.create_object_with_dependency("},{"line_number":276,"context_line":"                creator, dep_getter, dep_creator, dep_id_attr)[0]"},{"line_number":277,"context_line":"            with db_api.autonested_transaction(context.session):"},{"line_number":278,"context_line":"                port_binding.l3_agent_id \u003d agent[\u0027id\u0027]"},{"line_number":279,"context_line":"        except db_exc.DBDuplicateEntry:"}],"source_content_type":"text/x-python","patch_set":26,"id":"fa0719c6_6b797493","line":276,"updated":"2016-03-21 20:57:21.000000000","message":"Consistency with how the other arguments are built for this function.","commit_id":"b8dd8d888eb7b6786904ee502bae157e68b57ec3"},{"author":{"_account_id":9531,"name":"liuyulong","display_name":"LIU Yulong","email":"i@liuyulong.me","username":"LIU-Yulong"},"change_message_id":"ec8ad85f06ecb9c5cad2eac570e5e47eef343a47","unresolved":false,"context_lines":[{"line_number":273,"context_line":"        dep_id_attr \u003d \u0027network_id\u0027"},{"line_number":274,"context_line":"        try:"},{"line_number":275,"context_line":"            port_binding \u003d utils.create_object_with_dependency("},{"line_number":276,"context_line":"                creator, dep_getter, dep_creator, dep_id_attr)[0]"},{"line_number":277,"context_line":"            with db_api.autonested_transaction(context.session):"},{"line_number":278,"context_line":"                port_binding.l3_agent_id \u003d agent[\u0027id\u0027]"},{"line_number":279,"context_line":"        except db_exc.DBDuplicateEntry:"}],"source_content_type":"text/x-python","patch_set":26,"id":"fa0719c6_e8fc8640","line":276,"range":{"start_line":276,"start_character":50,"end_line":276,"end_character":61},"updated":"2016-03-21 12:34:45.000000000","message":"Why not directly \u0027network_id\u0027 ? or \"dep_id_attr\u003d\u0027network_id\u0027\"?","commit_id":"b8dd8d888eb7b6786904ee502bae157e68b57ec3"}],"neutron/tests/unit/db/test_l3_hamode_db.py":[{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"e55b41d11196d0de2153882ee646bc54026c08d0","unresolved":false,"context_lines":[{"line_number":597,"context_line":"    def test_create_ha_interfaces_and_ensure_network_no_net(self):"},{"line_number":598,"context_line":"        router \u003d self._create_router(ha\u003dFalse)"},{"line_number":599,"context_line":"        router_db \u003d self.plugin._get_router(self.admin_ctx, router[\u0027id\u0027])"},{"line_number":600,"context_line":"        self.plugin._create_ha_interfaces_and_ensure_network("},{"line_number":601,"context_line":"            self.admin_ctx, router_db)"},{"line_number":602,"context_line":""},{"line_number":603,"context_line":"    def test_create_ha_interfaces_and_ensure_network_concurrent_create(self):"}],"source_content_type":"text/x-python","patch_set":17,"id":"7af24918_fb61fd12","line":600,"updated":"2016-03-05 02:19:23.000000000","message":"Hmmm. This is a little pointless. I just wanted to make sure the function _create_ha_interfaces_and... worked in the happy case. But this is logic that happens on every router create for HA so its not really necessary.","commit_id":"1784a9314097bcb6098121189675c5f19e03ef4a"},{"author":{"_account_id":8873,"name":"Assaf Muller","email":"amuller@redhat.com","username":"amuller"},"change_message_id":"913dd7d78f0994f1fa424ce50c3a653f12544d08","unresolved":false,"context_lines":[{"line_number":597,"context_line":"    def test_create_ha_interfaces_and_ensure_network_no_net(self):"},{"line_number":598,"context_line":"        router \u003d self._create_router(ha\u003dFalse)"},{"line_number":599,"context_line":"        router_db \u003d self.plugin._get_router(self.admin_ctx, router[\u0027id\u0027])"},{"line_number":600,"context_line":"        self.plugin._create_ha_interfaces_and_ensure_network("},{"line_number":601,"context_line":"            self.admin_ctx, router_db)"},{"line_number":602,"context_line":""},{"line_number":603,"context_line":"    def test_create_ha_interfaces_and_ensure_network_concurrent_create(self):"}],"source_content_type":"text/x-python","patch_set":17,"id":"7af24918_553a80e8","line":600,"updated":"2016-03-05 01:17:30.000000000","message":"What did you want to test here? Do we really need to test this method with non-HA routers?","commit_id":"1784a9314097bcb6098121189675c5f19e03ef4a"},{"author":{"_account_id":8873,"name":"Assaf Muller","email":"amuller@redhat.com","username":"amuller"},"change_message_id":"913dd7d78f0994f1fa424ce50c3a653f12544d08","unresolved":false,"context_lines":[{"line_number":601,"context_line":"            self.admin_ctx, router_db)"},{"line_number":602,"context_line":""},{"line_number":603,"context_line":"    def test_create_ha_interfaces_and_ensure_network_concurrent_create(self):"},{"line_number":604,"context_line":"        router \u003d self._create_router(ha\u003dFalse)"},{"line_number":605,"context_line":"        router_db \u003d self.plugin._get_router(self.admin_ctx, router[\u0027id\u0027])"},{"line_number":606,"context_line":"        orig_create \u003d self.plugin._create_ha_network"},{"line_number":607,"context_line":"        created_nets \u003d []"}],"source_content_type":"text/x-python","patch_set":17,"id":"7af24918_8095e489","line":604,"updated":"2016-03-05 01:17:30.000000000","message":"I think this line deserves a comment, something like: We create a non-HA router so that create_ha_network is never called. This way we can call it manually later in lines so and so.","commit_id":"1784a9314097bcb6098121189675c5f19e03ef4a"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"e55b41d11196d0de2153882ee646bc54026c08d0","unresolved":false,"context_lines":[{"line_number":601,"context_line":"            self.admin_ctx, router_db)"},{"line_number":602,"context_line":""},{"line_number":603,"context_line":"    def test_create_ha_interfaces_and_ensure_network_concurrent_create(self):"},{"line_number":604,"context_line":"        router \u003d self._create_router(ha\u003dFalse)"},{"line_number":605,"context_line":"        router_db \u003d self.plugin._get_router(self.admin_ctx, router[\u0027id\u0027])"},{"line_number":606,"context_line":"        orig_create \u003d self.plugin._create_ha_network"},{"line_number":607,"context_line":"        created_nets \u003d []"}],"source_content_type":"text/x-python","patch_set":17,"id":"7af24918_db66c128","line":604,"updated":"2016-03-05 02:19:23.000000000","message":"ack","commit_id":"1784a9314097bcb6098121189675c5f19e03ef4a"},{"author":{"_account_id":8873,"name":"Assaf Muller","email":"amuller@redhat.com","username":"amuller"},"change_message_id":"913dd7d78f0994f1fa424ce50c3a653f12544d08","unresolved":false,"context_lines":[{"line_number":636,"context_line":"                self.admin_ctx, router_db)"},{"line_number":637,"context_line":"            self.assertTrue(_create_ha_interfaces.called)"},{"line_number":638,"context_line":""},{"line_number":639,"context_line":"    def test_create_ha_interfaces_and_ensure_network_concurrent_swap(self):"},{"line_number":640,"context_line":"        router \u003d self._create_router(ha\u003dFalse)"},{"line_number":641,"context_line":"        orig_create \u003d self.plugin._create_ha_interfaces"},{"line_number":642,"context_line":""}],"source_content_type":"text/x-python","patch_set":17,"id":"7af24918_c019ac24","line":639,"updated":"2016-03-05 01:17:30.000000000","message":"Do you wanna squash these two tests with a private method and have both tests use the same method? The only difference is line 649.","commit_id":"1784a9314097bcb6098121189675c5f19e03ef4a"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"e55b41d11196d0de2153882ee646bc54026c08d0","unresolved":false,"context_lines":[{"line_number":636,"context_line":"                self.admin_ctx, router_db)"},{"line_number":637,"context_line":"            self.assertTrue(_create_ha_interfaces.called)"},{"line_number":638,"context_line":""},{"line_number":639,"context_line":"    def test_create_ha_interfaces_and_ensure_network_concurrent_swap(self):"},{"line_number":640,"context_line":"        router \u003d self._create_router(ha\u003dFalse)"},{"line_number":641,"context_line":"        orig_create \u003d self.plugin._create_ha_interfaces"},{"line_number":642,"context_line":""}],"source_content_type":"text/x-python","patch_set":17,"id":"7af24918_3b6c0508","line":639,"updated":"2016-03-05 02:19:23.000000000","message":"yeah, i\u0027ll figure out a way to clean this up","commit_id":"1784a9314097bcb6098121189675c5f19e03ef4a"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"e55b41d11196d0de2153882ee646bc54026c08d0","unresolved":false,"context_lines":[{"line_number":640,"context_line":"        router \u003d self._create_router(ha\u003dFalse)"},{"line_number":641,"context_line":"        orig_create \u003d self.plugin._create_ha_interfaces"},{"line_number":642,"context_line":""},{"line_number":643,"context_line":"        def _create_ha_interfaces(ctx, rdb, ha_net):"},{"line_number":644,"context_line":"            # concurrent delete on the first attempt"},{"line_number":645,"context_line":"            if not getattr(_create_ha_interfaces, \u0027called\u0027, False):"},{"line_number":646,"context_line":"                setattr(_create_ha_interfaces, \u0027called\u0027, True)"}],"source_content_type":"text/x-python","patch_set":17,"id":"7af24918_1b7149e1","line":643,"updated":"2016-03-05 02:19:23.000000000","message":"Done","commit_id":"1784a9314097bcb6098121189675c5f19e03ef4a"},{"author":{"_account_id":8873,"name":"Assaf Muller","email":"amuller@redhat.com","username":"amuller"},"change_message_id":"913dd7d78f0994f1fa424ce50c3a653f12544d08","unresolved":false,"context_lines":[{"line_number":640,"context_line":"        router \u003d self._create_router(ha\u003dFalse)"},{"line_number":641,"context_line":"        orig_create \u003d self.plugin._create_ha_interfaces"},{"line_number":642,"context_line":""},{"line_number":643,"context_line":"        def _create_ha_interfaces(ctx, rdb, ha_net):"},{"line_number":644,"context_line":"            # concurrent delete on the first attempt"},{"line_number":645,"context_line":"            if not getattr(_create_ha_interfaces, \u0027called\u0027, False):"},{"line_number":646,"context_line":"                setattr(_create_ha_interfaces, \u0027called\u0027, True)"}],"source_content_type":"text/x-python","patch_set":17,"id":"7af24918_80f844c6","line":643,"updated":"2016-03-05 01:17:30.000000000","message":"rdb -\u003e r_db, or even just \u0027r\u0027","commit_id":"1784a9314097bcb6098121189675c5f19e03ef4a"}]}
