)]}'
{"/COMMIT_MSG":[{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"5880da54c161b5aa95abb09cb88a86626b521fda","unresolved":false,"context_lines":[{"line_number":41,"context_line":"DB_MAX_RETRIES is introduced in neutron.common.constants to define"},{"line_number":42,"context_line":"the maximum number of times that a DB operation can be retried"},{"line_number":43,"context_line":""},{"line_number":44,"context_line":"Closes-bug: #1331564"},{"line_number":45,"context_line":"Closes-bug: #1332923"},{"line_number":46,"context_line":"Closes-bug: #1313851"},{"line_number":47,"context_line":""}],"source_content_type":"text/x-gerrit-commit-message","patch_set":17,"id":"fa98f980_e048c030","line":44,"updated":"2014-09-16 22:41:02.000000000","message":"Does this completely close this bug?  This bug seems a bit too broad to fix in one patch.","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"139acc3d96b4e29b2d1aafb3213007716d11d42b","unresolved":false,"context_lines":[{"line_number":41,"context_line":"DB_MAX_RETRIES is introduced in neutron.common.constants to define"},{"line_number":42,"context_line":"the maximum number of times that a DB operation can be retried"},{"line_number":43,"context_line":""},{"line_number":44,"context_line":"Closes-bug: #1331564"},{"line_number":45,"context_line":"Closes-bug: #1332923"},{"line_number":46,"context_line":"Closes-bug: #1313851"},{"line_number":47,"context_line":""}],"source_content_type":"text/x-gerrit-commit-message","patch_set":17,"id":"fa98f980_de5c4d4f","line":44,"in_reply_to":"fa98f980_e048c030","updated":"2014-09-18 14:20:16.000000000","message":"Yes it closed it. In this patch select for update is completely removed from db_base_plugin","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"5880da54c161b5aa95abb09cb88a86626b521fda","unresolved":false,"context_lines":[{"line_number":43,"context_line":""},{"line_number":44,"context_line":"Closes-bug: #1331564"},{"line_number":45,"context_line":"Closes-bug: #1332923"},{"line_number":46,"context_line":"Closes-bug: #1313851"},{"line_number":47,"context_line":""},{"line_number":48,"context_line":"Change-Id: I7eeb687a8071c8f82cadbd51beb4668e371b2d4c"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":17,"id":"fa98f980_8008d4da","line":46,"updated":"2014-09-16 22:41:02.000000000","message":"This bug was closed as fix released.  What?!\n\nI think we should file a new bug about the general issue of \u0027lock wait timeout\u0027 around these tables.   There is another related one that was marked as duplicate [1].\n\n[1] https://bugs.launchpad.net/neutron/+bug/1330644","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"139acc3d96b4e29b2d1aafb3213007716d11d42b","unresolved":false,"context_lines":[{"line_number":43,"context_line":""},{"line_number":44,"context_line":"Closes-bug: #1331564"},{"line_number":45,"context_line":"Closes-bug: #1332923"},{"line_number":46,"context_line":"Closes-bug: #1313851"},{"line_number":47,"context_line":""},{"line_number":48,"context_line":"Change-Id: I7eeb687a8071c8f82cadbd51beb4668e371b2d4c"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":17,"id":"fa98f980_fe1e7173","line":46,"in_reply_to":"fa98f980_8008d4da","updated":"2014-09-18 14:20:16.000000000","message":"We can file a general bug, anyway those bugs already exist, what\u0027s your proposal? To create an umbrella bug and mark the smaller ones as duplicated?","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":11825,"name":"Sudhakar Babu Gariganti","email":"sudhakar.gariganti@gmail.com","username":"sudhakar-gariganti"},"change_message_id":"e880c2c4baff16d26b8d13c2d4d2ec6a0cdf1222","unresolved":false,"context_lines":[{"line_number":32,"context_line":"_rebuild_availability_ranges at the same time, that\u0027s why a"},{"line_number":33,"context_line":"DBDuplicateEntry is catched."},{"line_number":34,"context_line":""},{"line_number":35,"context_line":"This change moves DB_MAX_ENTRIES to constants in order to make it"},{"line_number":36,"context_line":"available for reference from this new code."},{"line_number":37,"context_line":""},{"line_number":38,"context_line":"In _try_generate_ip IPAllocationFailure is raised instead of"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":27,"id":"9aa7fdbe_6c0fb737","line":35,"updated":"2014-10-27 10:37:31.000000000","message":"I guess you meant DB_MAX_RETRIES here. Also you may want to watch out for this patch ( https://review.openstack.org/#/c/130205/ ) getting merged as its a potential merge conflict.","commit_id":"abdb26cb94d79a8f750034efd8f460f24900f316"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"2e4a295bef6fd78f451723a06cc7bd09088ddf1d","unresolved":false,"context_lines":[{"line_number":32,"context_line":"_rebuild_availability_ranges at the same time, that\u0027s why a"},{"line_number":33,"context_line":"DBDuplicateEntry is catched."},{"line_number":34,"context_line":""},{"line_number":35,"context_line":"This change moves DB_MAX_ENTRIES to constants in order to make it"},{"line_number":36,"context_line":"available for reference from this new code."},{"line_number":37,"context_line":""},{"line_number":38,"context_line":"In _try_generate_ip IPAllocationFailure is raised instead of"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":27,"id":"9aa7fdbe_caaaf484","line":35,"in_reply_to":"9aa7fdbe_6c0fb737","updated":"2014-10-29 17:54:02.000000000","message":"Thanks!","commit_id":"abdb26cb94d79a8f750034efd8f460f24900f316"},{"author":{"_account_id":8124,"name":"cbrandily","email":"zzelle@gmail.com","username":"cbrandily"},"change_message_id":"15e0014032301b22cfb0c5f1c869c0c2c95d0c9c","unresolved":false,"context_lines":[{"line_number":39,"context_line":"IpAddressGenerationFailure to be consistent with the decorator"},{"line_number":40,"context_line":"_retry_ip_allocation. _generate_ip is refactored accordingly"},{"line_number":41,"context_line":""},{"line_number":42,"context_line":"Closes-bug: #1331564"},{"line_number":43,"context_line":"Closes-bug: #1332923"},{"line_number":44,"context_line":"Closes-bug: #1313851"},{"line_number":45,"context_line":""}],"source_content_type":"text/x-gerrit-commit-message","patch_set":27,"id":"9aa7fdbe_4c12f309","line":42,"updated":"2014-10-27 10:12:47.000000000","message":"Closes-Bug: #1331564 seems incorrect as daughter change also removes lock in db_base_plugin","commit_id":"abdb26cb94d79a8f750034efd8f460f24900f316"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"bfabdf0b0a09d355257c45731fc9a837fb70387b","unresolved":false,"context_lines":[{"line_number":39,"context_line":"IpAddressGenerationFailure to be consistent with the decorator"},{"line_number":40,"context_line":"_retry_ip_allocation. _generate_ip is refactored accordingly"},{"line_number":41,"context_line":""},{"line_number":42,"context_line":"Closes-bug: #1331564"},{"line_number":43,"context_line":"Closes-bug: #1332923"},{"line_number":44,"context_line":"Closes-bug: #1313851"},{"line_number":45,"context_line":""}],"source_content_type":"text/x-gerrit-commit-message","patch_set":27,"id":"9aa7fdbe_be20a5b1","line":42,"updated":"2014-10-29 05:34:17.000000000","message":"Partial-Bug is the keyword here.","commit_id":"abdb26cb94d79a8f750034efd8f460f24900f316"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"2e4a295bef6fd78f451723a06cc7bd09088ddf1d","unresolved":false,"context_lines":[{"line_number":39,"context_line":"IpAddressGenerationFailure to be consistent with the decorator"},{"line_number":40,"context_line":"_retry_ip_allocation. _generate_ip is refactored accordingly"},{"line_number":41,"context_line":""},{"line_number":42,"context_line":"Closes-bug: #1331564"},{"line_number":43,"context_line":"Closes-bug: #1332923"},{"line_number":44,"context_line":"Closes-bug: #1313851"},{"line_number":45,"context_line":""}],"source_content_type":"text/x-gerrit-commit-message","patch_set":27,"id":"9aa7fdbe_206e4197","line":42,"in_reply_to":"9aa7fdbe_be20a5b1","updated":"2014-10-29 17:54:02.000000000","message":"Done","commit_id":"abdb26cb94d79a8f750034efd8f460f24900f316"},{"author":{"_account_id":11825,"name":"Sudhakar Babu Gariganti","email":"sudhakar.gariganti@gmail.com","username":"sudhakar-gariganti"},"change_message_id":"9e23e3fa0f33dc710481695dd0576929ed2fa3e0","unresolved":false,"context_lines":[{"line_number":32,"context_line":"_rebuild_availability_ranges at the same time, that\u0027s why a"},{"line_number":33,"context_line":"DBDuplicateEntry is catched."},{"line_number":34,"context_line":""},{"line_number":35,"context_line":"This change moves DB_MAX_RETRIES to constants in order to make it"},{"line_number":36,"context_line":"available for reference from this new code."},{"line_number":37,"context_line":""},{"line_number":38,"context_line":"In _try_generate_ip IPAllocationFailure is raised instead of"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":28,"id":"9aa7fdbe_e05ef975","line":35,"updated":"2014-10-29 18:06:56.000000000","message":"As mentioned in earlier patchset, DB_MAX_RETRIES is renamed to DB_MAX_ATTEMPTS via https://review.openstack.org/#/c/130205/ \n\nYou need to rebase real quick to avoid re-work for the reviewers :)","commit_id":"13cec6c911b519a6b4afe3ab8afe8a11e7af9923"}],"neutron/common/exceptions.py":[{"author":{"_account_id":2035,"name":"Maru Newby","email":"marun@redhat.com","username":"maru"},"change_message_id":"3f57654c608bf2458783412dbda59e26f7fa8abe","unresolved":false,"context_lines":[{"line_number":184,"context_line":"                \"No available network found in maximum allowed attempts.\")"},{"line_number":185,"context_line":""},{"line_number":186,"context_line":""},{"line_number":187,"context_line":"class NoIpAllocatedInMaximumAllowedAttempt(ServiceUnavailable):"},{"line_number":188,"context_line":"    message \u003d _(\"Unable to allocate the IP in maximum allowed attempts.\")"},{"line_number":189,"context_line":""},{"line_number":190,"context_line":""}],"source_content_type":"text/x-python","patch_set":14,"id":"1abeadc6_4641cda7","line":187,"updated":"2014-09-01 11:14:51.000000000","message":"(No action required) Wow, we\u0027re approaching java-length class names.  :(","commit_id":"cf13fe3fe11e87d0cbe3d089ff8f893b4b107b92"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"64574cc394cbc013d2b877fd38e8b0f792beae2b","unresolved":false,"context_lines":[{"line_number":222,"context_line":""},{"line_number":223,"context_line":""},{"line_number":224,"context_line":"class IPAllocationFailure(NeutronException):"},{"line_number":225,"context_line":"    message \u003d _(\"IP allocation failed\")"},{"line_number":226,"context_line":""},{"line_number":227,"context_line":""},{"line_number":228,"context_line":"class IpAddressGenerationFailure(Conflict):"}],"source_content_type":"text/x-python","patch_set":25,"id":"da9df570_3cbf18fd","line":225,"updated":"2014-09-23 18:18:35.000000000","message":"Translated string","commit_id":"4001992431297804b011c969e6ec5f55e2bb75b5"}],"neutron/db/db_base_plugin_v2.py":[{"author":{"_account_id":8124,"name":"cbrandily","email":"zzelle@gmail.com","username":"cbrandily"},"change_message_id":"cd287af932e82ad818952d0ee83576636ef92463","unresolved":false,"context_lines":[{"line_number":52,"context_line":"# IP allocations being cleaned up by cascade."},{"line_number":53,"context_line":"AUTO_DELETE_PORT_OWNERS \u003d [constants.DEVICE_OWNER_DHCP]"},{"line_number":54,"context_line":""},{"line_number":55,"context_line":"DB_MAX_RETRIES \u003d 10"},{"line_number":56,"context_line":""},{"line_number":57,"context_line":""},{"line_number":58,"context_line":"class NeutronDbPluginV2(neutron_plugin_base_v2.NeutronPluginBaseV2,"}],"source_content_type":"text/x-python","patch_set":3,"id":"baada198_5a784dc1","line":55,"updated":"2014-08-06 20:27:14.000000000","message":"perhaps we should share this constant with ml2.drivers.helpers?","commit_id":"b9ae485de8eed32c9677e4a913cb70fc50b7de9a"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"a00a8cc1d0aebab8148a669702b599c85f269e2e","unresolved":false,"context_lines":[{"line_number":52,"context_line":"# IP allocations being cleaned up by cascade."},{"line_number":53,"context_line":"AUTO_DELETE_PORT_OWNERS \u003d [constants.DEVICE_OWNER_DHCP]"},{"line_number":54,"context_line":""},{"line_number":55,"context_line":"DB_MAX_RETRIES \u003d 10"},{"line_number":56,"context_line":""},{"line_number":57,"context_line":""},{"line_number":58,"context_line":"class NeutronDbPluginV2(neutron_plugin_base_v2.NeutronPluginBaseV2,"}],"source_content_type":"text/x-python","patch_set":3,"id":"baada198_59cf6a8b","line":55,"in_reply_to":"baada198_5a784dc1","updated":"2014-08-07 10:53:26.000000000","message":"Done :)","commit_id":"b9ae485de8eed32c9677e4a913cb70fc50b7de9a"},{"author":{"_account_id":8124,"name":"cbrandily","email":"zzelle@gmail.com","username":"cbrandily"},"change_message_id":"cd287af932e82ad818952d0ee83576636ef92463","unresolved":false,"context_lines":[{"line_number":242,"context_line":"                                      filter_by(first_ip\u003dip_range[\u0027first_ip\u0027])."},{"line_number":243,"context_line":"                                      filter_by(last_ip\u003dip_range[\u0027last_ip\u0027]))"},{"line_number":244,"context_line":"                ip_address \u003d ip_range[\u0027first_ip\u0027]"},{"line_number":245,"context_line":"                LOG.debug(\"Allocated IP - %(ip_address)s from %(first_ip)s \""},{"line_number":246,"context_line":"                          \"to %(last_ip)s\","},{"line_number":247,"context_line":"                          {\u0027ip_address\u0027: ip_address,"},{"line_number":248,"context_line":"                           \u0027first_ip\u0027: ip_range[\u0027first_ip\u0027],"}],"source_content_type":"text/x-python","patch_set":3,"id":"baada198_7ab8b178","line":245,"updated":"2014-08-06 20:27:14.000000000","message":"the LOG.debug message is invalid, at this step of the allocation, we only have an ip/ip range candidate,  we are sure the ip is allocated after \"if not count\" test","commit_id":"b9ae485de8eed32c9677e4a913cb70fc50b7de9a"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"a00a8cc1d0aebab8148a669702b599c85f269e2e","unresolved":false,"context_lines":[{"line_number":242,"context_line":"                                      filter_by(first_ip\u003dip_range[\u0027first_ip\u0027])."},{"line_number":243,"context_line":"                                      filter_by(last_ip\u003dip_range[\u0027last_ip\u0027]))"},{"line_number":244,"context_line":"                ip_address \u003d ip_range[\u0027first_ip\u0027]"},{"line_number":245,"context_line":"                LOG.debug(\"Allocated IP - %(ip_address)s from %(first_ip)s \""},{"line_number":246,"context_line":"                          \"to %(last_ip)s\","},{"line_number":247,"context_line":"                          {\u0027ip_address\u0027: ip_address,"},{"line_number":248,"context_line":"                           \u0027first_ip\u0027: ip_range[\u0027first_ip\u0027],"}],"source_content_type":"text/x-python","patch_set":3,"id":"baada198_47bb0674","line":245,"in_reply_to":"baada198_7ab8b178","updated":"2014-08-07 10:53:26.000000000","message":"Good point","commit_id":"b9ae485de8eed32c9677e4a913cb70fc50b7de9a"},{"author":{"_account_id":8124,"name":"cbrandily","email":"zzelle@gmail.com","username":"cbrandily"},"change_message_id":"cd287af932e82ad818952d0ee83576636ef92463","unresolved":false,"context_lines":[{"line_number":262,"context_line":"                    if not count:"},{"line_number":263,"context_line":"                        continue"},{"line_number":264,"context_line":""},{"line_number":265,"context_line":"                NeutronDbPluginV2._store_ip_allocation("},{"line_number":266,"context_line":"                    context, ip_address, subnet[\u0027network_id\u0027],"},{"line_number":267,"context_line":"                    subnet[\u0027id\u0027], port_id)"},{"line_number":268,"context_line":"                return {\u0027ip_address\u0027: ip_address,"}],"source_content_type":"text/x-python","patch_set":3,"id":"baada198_fac9217b","line":265,"updated":"2014-08-06 20:27:14.000000000","message":"Althrough it\u0027s done everywhere is this class, it\u0027s not pythonic to use the following (java?) pattern:\n\n class MyClass:\n\n  @staticmethod\n  def method1():\n    pass\n\n  @staticmethod\n  def method2():\n    MyClass.method1()\n\nbecause it breaks python inheritance  principle: if a subclass SubClass of MyClass overloads method1, SubClass method2 will still use MyClass.method1!\n\nyou should prefer in python:\n\n class MyClass:\n\n  @staticmethod\n  def method1():\n    pass\n\n  @classmethod\n  def method2(cls):\n    cls.method1()","commit_id":"b9ae485de8eed32c9677e4a913cb70fc50b7de9a"},{"author":{"_account_id":8124,"name":"cbrandily","email":"zzelle@gmail.com","username":"cbrandily"},"change_message_id":"eb86c5774991f893b26a39509484c75c93b1fc4c","unresolved":false,"context_lines":[{"line_number":262,"context_line":"                    if not count:"},{"line_number":263,"context_line":"                        continue"},{"line_number":264,"context_line":""},{"line_number":265,"context_line":"                NeutronDbPluginV2._store_ip_allocation("},{"line_number":266,"context_line":"                    context, ip_address, subnet[\u0027network_id\u0027],"},{"line_number":267,"context_line":"                    subnet[\u0027id\u0027], port_id)"},{"line_number":268,"context_line":"                return {\u0027ip_address\u0027: ip_address,"}],"source_content_type":"text/x-python","patch_set":3,"id":"baada198_c86d629c","line":265,"in_reply_to":"baada198_87119e5e","updated":"2014-08-07 12:02:35.000000000","message":"as you want","commit_id":"b9ae485de8eed32c9677e4a913cb70fc50b7de9a"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"a00a8cc1d0aebab8148a669702b599c85f269e2e","unresolved":false,"context_lines":[{"line_number":262,"context_line":"                    if not count:"},{"line_number":263,"context_line":"                        continue"},{"line_number":264,"context_line":""},{"line_number":265,"context_line":"                NeutronDbPluginV2._store_ip_allocation("},{"line_number":266,"context_line":"                    context, ip_address, subnet[\u0027network_id\u0027],"},{"line_number":267,"context_line":"                    subnet[\u0027id\u0027], port_id)"},{"line_number":268,"context_line":"                return {\u0027ip_address\u0027: ip_address,"}],"source_content_type":"text/x-python","patch_set":3,"id":"baada198_87119e5e","line":265,"in_reply_to":"baada198_fac9217b","updated":"2014-08-07 10:53:26.000000000","message":"Thanks for the suggestion. Let\u0027s address that in a separate patch since this issue was not introduced here. What do you think?","commit_id":"b9ae485de8eed32c9677e4a913cb70fc50b7de9a"},{"author":{"_account_id":8124,"name":"cbrandily","email":"zzelle@gmail.com","username":"cbrandily"},"change_message_id":"6c0746e5b0ee8ae4ab40b2b1c17ec7c98ec7c853","unresolved":false,"context_lines":[{"line_number":224,"context_line":"            models_v2.IPAllocationPool)"},{"line_number":225,"context_line":""},{"line_number":226,"context_line":"        for subnet in subnets:"},{"line_number":227,"context_line":"            for attempt in range(1, constants.DB_MAX_RETRIES + 1):"},{"line_number":228,"context_line":"                ip_range \u003d range_qry.filter_by(subnet_id\u003dsubnet[\u0027id\u0027]).first()"},{"line_number":229,"context_line":"                if not ip_range:"},{"line_number":230,"context_line":"                    LOG.debug(\"All IPs from subnet %(subnet_id)s (%(cidr)s) \""}],"source_content_type":"text/x-python","patch_set":5,"id":"baada198_f90808da","line":227,"updated":"2014-08-08 15:03:07.000000000","message":"do we really need to perform DB_MAX_RETRIES per subnet instead of DB_MAX_RETRIES per _try_generate_ip otherwise for network with many subnets we could try many times? ie: attempt could be incremented when count \u003d\u003d 0","commit_id":"03e5f5e6b0776f9354d11b92a98829cc4d20193b"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"430ae9efe92a39b37a2ad958f0ccf2837d9bd088","unresolved":false,"context_lines":[{"line_number":224,"context_line":"            models_v2.IPAllocationPool)"},{"line_number":225,"context_line":""},{"line_number":226,"context_line":"        for subnet in subnets:"},{"line_number":227,"context_line":"            for attempt in range(1, constants.DB_MAX_RETRIES + 1):"},{"line_number":228,"context_line":"                ip_range \u003d range_qry.filter_by(subnet_id\u003dsubnet[\u0027id\u0027]).first()"},{"line_number":229,"context_line":"                if not ip_range:"},{"line_number":230,"context_line":"                    LOG.debug(\"All IPs from subnet %(subnet_id)s (%(cidr)s) \""}],"source_content_type":"text/x-python","patch_set":5,"id":"baada198_f2519a31","line":227,"in_reply_to":"baada198_348605bb","updated":"2014-08-12 13:58:51.000000000","message":"I will add a check, if the maximum number of attempts is reached, an exception is thrown instead of trying the following subnet. Thanks!","commit_id":"03e5f5e6b0776f9354d11b92a98829cc4d20193b"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"2e790caa79e32eb0b64c580d7af9404d23764b73","unresolved":false,"context_lines":[{"line_number":224,"context_line":"            models_v2.IPAllocationPool)"},{"line_number":225,"context_line":""},{"line_number":226,"context_line":"        for subnet in subnets:"},{"line_number":227,"context_line":"            for attempt in range(1, constants.DB_MAX_RETRIES + 1):"},{"line_number":228,"context_line":"                ip_range \u003d range_qry.filter_by(subnet_id\u003dsubnet[\u0027id\u0027]).first()"},{"line_number":229,"context_line":"                if not ip_range:"},{"line_number":230,"context_line":"                    LOG.debug(\"All IPs from subnet %(subnet_id)s (%(cidr)s) \""}],"source_content_type":"text/x-python","patch_set":5,"id":"baada198_142993f1","line":227,"in_reply_to":"baada198_4890d641","updated":"2014-08-12 16:41:35.000000000","message":"OK :)","commit_id":"03e5f5e6b0776f9354d11b92a98829cc4d20193b"},{"author":{"_account_id":8124,"name":"cbrandily","email":"zzelle@gmail.com","username":"cbrandily"},"change_message_id":"38d738ab4c975d69b17afc7b1ef94e332b4a30d6","unresolved":false,"context_lines":[{"line_number":224,"context_line":"            models_v2.IPAllocationPool)"},{"line_number":225,"context_line":""},{"line_number":226,"context_line":"        for subnet in subnets:"},{"line_number":227,"context_line":"            for attempt in range(1, constants.DB_MAX_RETRIES + 1):"},{"line_number":228,"context_line":"                ip_range \u003d range_qry.filter_by(subnet_id\u003dsubnet[\u0027id\u0027]).first()"},{"line_number":229,"context_line":"                if not ip_range:"},{"line_number":230,"context_line":"                    LOG.debug(\"All IPs from subnet %(subnet_id)s (%(cidr)s) \""}],"source_content_type":"text/x-python","patch_set":5,"id":"baada198_348605bb","line":227,"in_reply_to":"baada198_b976900a","updated":"2014-08-09 00:36:29.000000000","message":"in the worst case, with X subnets we could try X * DB_MAX_RETRIES before raising an error, i am not sure we should retry so much ... we could retry until we find an ip in subnet with at most DB_MAX_RETRIES cases where count is 0 (attempt computation becomes more complex) so:\n\n- if we hit DB_MAX_RETRIES cases with count is 0 with the first subnet, then we raise an error\n- if we hit 1 case with count is 0 with the first subnet and finally 1st subnet has no more free ip, then we move to the 2nd subnet and if we hit DB_MAX_RETRIES -1 cases with count is 0 then we raise an error ...","commit_id":"03e5f5e6b0776f9354d11b92a98829cc4d20193b"},{"author":{"_account_id":2592,"name":"Mark McClain","email":"mark@mcclain.xyz","username":"markmcclain"},"change_message_id":"ddadf7cfd30468fcb746ef840d4b7b5a4ab8e196","unresolved":false,"context_lines":[{"line_number":224,"context_line":"            models_v2.IPAllocationPool)"},{"line_number":225,"context_line":""},{"line_number":226,"context_line":"        for subnet in subnets:"},{"line_number":227,"context_line":"            for attempt in range(1, constants.DB_MAX_RETRIES + 1):"},{"line_number":228,"context_line":"                ip_range \u003d range_qry.filter_by(subnet_id\u003dsubnet[\u0027id\u0027]).first()"},{"line_number":229,"context_line":"                if not ip_range:"},{"line_number":230,"context_line":"                    LOG.debug(\"All IPs from subnet %(subnet_id)s (%(cidr)s) \""}],"source_content_type":"text/x-python","patch_set":5,"id":"baada198_4890d641","line":227,"in_reply_to":"baada198_f2519a31","updated":"2014-08-12 15:17:30.000000000","message":"I think I\u0027d rather try all subnets once before trying to repeat the action on a particular subnet.","commit_id":"03e5f5e6b0776f9354d11b92a98829cc4d20193b"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"f4ab3510f08254958a454bbd20141e351348c168","unresolved":false,"context_lines":[{"line_number":224,"context_line":"            models_v2.IPAllocationPool)"},{"line_number":225,"context_line":""},{"line_number":226,"context_line":"        for subnet in subnets:"},{"line_number":227,"context_line":"            for attempt in range(1, constants.DB_MAX_RETRIES + 1):"},{"line_number":228,"context_line":"                ip_range \u003d range_qry.filter_by(subnet_id\u003dsubnet[\u0027id\u0027]).first()"},{"line_number":229,"context_line":"                if not ip_range:"},{"line_number":230,"context_line":"                    LOG.debug(\"All IPs from subnet %(subnet_id)s (%(cidr)s) \""}],"source_content_type":"text/x-python","patch_set":5,"id":"baada198_b976900a","line":227,"in_reply_to":"baada198_f90808da","updated":"2014-08-08 15:10:31.000000000","message":"We retry only if the DB is not in the state we left it (count is 0 ). In that case I don\u0027t think we should move to another subnet. \nIf there\u0027s no IP available in the current subnet, that is the ip_range is not present, we hit the break at line 234 so immediately try a new subnet. Does that answer your concern?","commit_id":"03e5f5e6b0776f9354d11b92a98829cc4d20193b"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"833f23dfc29ca458f45d9301db4fb230d3c5ecbb","unresolved":false,"context_lines":[{"line_number":223,"context_line":"            models_v2.IPAvailabilityRange).join("},{"line_number":224,"context_line":"            models_v2.IPAllocationPool)"},{"line_number":225,"context_line":""},{"line_number":226,"context_line":"        for attempt in range(1, constants.DB_MAX_RETRIES + 1):"},{"line_number":227,"context_line":"            for subnet in subnets:"},{"line_number":228,"context_line":"                ip_range \u003d range_qry.filter_by(subnet_id\u003dsubnet[\u0027id\u0027]).first()"},{"line_number":229,"context_line":"                if not ip_range:"}],"source_content_type":"text/x-python","patch_set":6,"id":"1abeadc6_61264f18","line":226,"updated":"2014-08-19 05:55:33.000000000","message":"nit:  range(constants.DB_MAX_RETRIES).  Since attempt is never read, it doesn\u0027t matter that the range starts at 0.  Also, since it isn\u0027t read, consider using \u0027_\u0027 instead of \"attempt\".","commit_id":"9e36edef48b4c6b4e4ecf7392b053d7287fe5e7d"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"412c2ac3041321bdfa8ea087563fadfbb9c1fe0e","unresolved":false,"context_lines":[{"line_number":223,"context_line":"            models_v2.IPAvailabilityRange).join("},{"line_number":224,"context_line":"            models_v2.IPAllocationPool)"},{"line_number":225,"context_line":""},{"line_number":226,"context_line":"        for attempt in range(1, constants.DB_MAX_RETRIES + 1):"},{"line_number":227,"context_line":"            for subnet in subnets:"},{"line_number":228,"context_line":"                ip_range \u003d range_qry.filter_by(subnet_id\u003dsubnet[\u0027id\u0027]).first()"},{"line_number":229,"context_line":"                if not ip_range:"}],"source_content_type":"text/x-python","patch_set":6,"id":"1abeadc6_875c44ef","line":226,"in_reply_to":"1abeadc6_61264f18","updated":"2014-08-19 15:25:26.000000000","message":"Thanks!","commit_id":"9e36edef48b4c6b4e4ecf7392b053d7287fe5e7d"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"833f23dfc29ca458f45d9301db4fb230d3c5ecbb","unresolved":false,"context_lines":[{"line_number":225,"context_line":""},{"line_number":226,"context_line":"        for attempt in range(1, constants.DB_MAX_RETRIES + 1):"},{"line_number":227,"context_line":"            for subnet in subnets:"},{"line_number":228,"context_line":"                ip_range \u003d range_qry.filter_by(subnet_id\u003dsubnet[\u0027id\u0027]).first()"},{"line_number":229,"context_line":"                if not ip_range:"},{"line_number":230,"context_line":"                    LOG.debug(\"All IPs from subnet %(subnet_id)s (%(cidr)s) \""},{"line_number":231,"context_line":"                              \"allocated\","}],"source_content_type":"text/x-python","patch_set":6,"id":"1abeadc6_c68d797d","line":228,"updated":"2014-08-19 05:55:33.000000000","message":"I wonder if this would be easier to review if you split out a few of the simpler refactors in to other patches.  For example, I\u0027m thinking something like this but I haven\u0027t thought it all the way through.\n\n1) Rename range -\u003e ip_range to avoid shadowing the builtin.\n2) Pass port_id down to _try_generate_ip\n3) Move DB_MAX_RETRIES to constants\n\nI made a few attempts.  I found a few loose ends that this patch leaves by pulling them out.  So, I put them up for review [1].  Could you rebase this patch on top of those?  They should be pretty easy to merge.\n\n[1] https://review.openstack.org/#/c/115175/","commit_id":"9e36edef48b4c6b4e4ecf7392b053d7287fe5e7d"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"412c2ac3041321bdfa8ea087563fadfbb9c1fe0e","unresolved":false,"context_lines":[{"line_number":225,"context_line":""},{"line_number":226,"context_line":"        for attempt in range(1, constants.DB_MAX_RETRIES + 1):"},{"line_number":227,"context_line":"            for subnet in subnets:"},{"line_number":228,"context_line":"                ip_range \u003d range_qry.filter_by(subnet_id\u003dsubnet[\u0027id\u0027]).first()"},{"line_number":229,"context_line":"                if not ip_range:"},{"line_number":230,"context_line":"                    LOG.debug(\"All IPs from subnet %(subnet_id)s (%(cidr)s) \""},{"line_number":231,"context_line":"                              \"allocated\","}],"source_content_type":"text/x-python","patch_set":6,"id":"1abeadc6_87860412","line":228,"in_reply_to":"1abeadc6_c68d797d","updated":"2014-08-19 15:25:26.000000000","message":"Thanks, will do that!","commit_id":"9e36edef48b4c6b4e4ecf7392b053d7287fe5e7d"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"833f23dfc29ca458f45d9301db4fb230d3c5ecbb","unresolved":false,"context_lines":[{"line_number":245,"context_line":"                    LOG.debug(\"No more free IP\u0027s in slice. Deleting \""},{"line_number":246,"context_line":"                              \"allocation pool.\")"},{"line_number":247,"context_line":"                    count \u003d check_update_query.delete()"},{"line_number":248,"context_line":"                    if not count:"},{"line_number":249,"context_line":"                        continue"},{"line_number":250,"context_line":"                else:"},{"line_number":251,"context_line":"                    # increment the first free"}],"source_content_type":"text/x-python","patch_set":6,"id":"1abeadc6_e19b3fc7","line":248,"updated":"2014-08-19 05:55:33.000000000","message":"nit:  prefer if count \u003d\u003d 0: here.","commit_id":"9e36edef48b4c6b4e4ecf7392b053d7287fe5e7d"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"412c2ac3041321bdfa8ea087563fadfbb9c1fe0e","unresolved":false,"context_lines":[{"line_number":245,"context_line":"                    LOG.debug(\"No more free IP\u0027s in slice. Deleting \""},{"line_number":246,"context_line":"                              \"allocation pool.\")"},{"line_number":247,"context_line":"                    count \u003d check_update_query.delete()"},{"line_number":248,"context_line":"                    if not count:"},{"line_number":249,"context_line":"                        continue"},{"line_number":250,"context_line":"                else:"},{"line_number":251,"context_line":"                    # increment the first free"}],"source_content_type":"text/x-python","patch_set":6,"id":"1abeadc6_67b1e8e0","line":248,"in_reply_to":"1abeadc6_e19b3fc7","updated":"2014-08-19 15:25:26.000000000","message":"Done","commit_id":"9e36edef48b4c6b4e4ecf7392b053d7287fe5e7d"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"833f23dfc29ca458f45d9301db4fb230d3c5ecbb","unresolved":false,"context_lines":[{"line_number":252,"context_line":"                    new_first_ip \u003d str(netaddr.IPAddress(ip_address) + 1)"},{"line_number":253,"context_line":"                    count \u003d check_update_query.update("},{"line_number":254,"context_line":"                        {\"first_ip\": new_first_ip})"},{"line_number":255,"context_line":"                    if not count:"},{"line_number":256,"context_line":"                        continue"},{"line_number":257,"context_line":""},{"line_number":258,"context_line":"                LOG.debug(\"Allocated IP - %(ip_address)s from %(first_ip)s \""}],"source_content_type":"text/x-python","patch_set":6,"id":"1abeadc6_c1e4833d","line":255,"updated":"2014-08-19 05:55:33.000000000","message":"ditto","commit_id":"9e36edef48b4c6b4e4ecf7392b053d7287fe5e7d"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"412c2ac3041321bdfa8ea087563fadfbb9c1fe0e","unresolved":false,"context_lines":[{"line_number":252,"context_line":"                    new_first_ip \u003d str(netaddr.IPAddress(ip_address) + 1)"},{"line_number":253,"context_line":"                    count \u003d check_update_query.update("},{"line_number":254,"context_line":"                        {\"first_ip\": new_first_ip})"},{"line_number":255,"context_line":"                    if not count:"},{"line_number":256,"context_line":"                        continue"},{"line_number":257,"context_line":""},{"line_number":258,"context_line":"                LOG.debug(\"Allocated IP - %(ip_address)s from %(first_ip)s \""}],"source_content_type":"text/x-python","patch_set":6,"id":"1abeadc6_a7ca204d","line":255,"in_reply_to":"1abeadc6_c1e4833d","updated":"2014-08-19 15:25:26.000000000","message":"Done","commit_id":"9e36edef48b4c6b4e4ecf7392b053d7287fe5e7d"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"833f23dfc29ca458f45d9301db4fb230d3c5ecbb","unresolved":false,"context_lines":[{"line_number":562,"context_line":""},{"line_number":563,"context_line":"        if to_add:"},{"line_number":564,"context_line":"            LOG.debug(_(\"Port update. Adding %s\"), to_add)"},{"line_number":565,"context_line":"            ips \u003d self._allocate_fixed_ips(context, network_id, to_add,"},{"line_number":566,"context_line":"                                           port_id)"},{"line_number":567,"context_line":"        return ips, prev_ips"},{"line_number":568,"context_line":""}],"source_content_type":"text/x-python","patch_set":6,"id":"1abeadc6_61f9efc7","line":565,"updated":"2014-08-19 05:55:33.000000000","message":"Could go in to refactoring.","commit_id":"9e36edef48b4c6b4e4ecf7392b053d7287fe5e7d"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"833f23dfc29ca458f45d9301db4fb230d3c5ecbb","unresolved":false,"context_lines":[{"line_number":566,"context_line":"                                           port_id)"},{"line_number":567,"context_line":"        return ips, prev_ips"},{"line_number":568,"context_line":""},{"line_number":569,"context_line":"    def _allocate_ips_for_port(self, context, network, port, port_id):"},{"line_number":570,"context_line":"        \"\"\"Allocate IP addresses for the port."},{"line_number":571,"context_line":""},{"line_number":572,"context_line":"        If port[\u0027fixed_ips\u0027] is set to \u0027ATTR_NOT_SPECIFIED\u0027, allocate IP"}],"source_content_type":"text/x-python","patch_set":6,"id":"1abeadc6_a69f9d5e","line":569,"updated":"2014-08-19 05:55:33.000000000","message":"Network is now an unused parameter.  This is one of the loose ends I found by pulling out a couple of refactors [1].  Since I was looking at it already, I pushed this patch [1] to properly clean it up in a refactor.\n\n[1] https://review.openstack.org/#/c/115175/","commit_id":"9e36edef48b4c6b4e4ecf7392b053d7287fe5e7d"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"412c2ac3041321bdfa8ea087563fadfbb9c1fe0e","unresolved":false,"context_lines":[{"line_number":566,"context_line":"                                           port_id)"},{"line_number":567,"context_line":"        return ips, prev_ips"},{"line_number":568,"context_line":""},{"line_number":569,"context_line":"    def _allocate_ips_for_port(self, context, network, port, port_id):"},{"line_number":570,"context_line":"        \"\"\"Allocate IP addresses for the port."},{"line_number":571,"context_line":""},{"line_number":572,"context_line":"        If port[\u0027fixed_ips\u0027] is set to \u0027ATTR_NOT_SPECIFIED\u0027, allocate IP"}],"source_content_type":"text/x-python","patch_set":6,"id":"1abeadc6_a73f8024","line":569,"in_reply_to":"1abeadc6_a69f9d5e","updated":"2014-08-19 15:25:26.000000000","message":"thanks","commit_id":"9e36edef48b4c6b4e4ecf7392b053d7287fe5e7d"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"833f23dfc29ca458f45d9301db4fb230d3c5ecbb","unresolved":false,"context_lines":[{"line_number":612,"context_line":"            for subnets in version_subnets:"},{"line_number":613,"context_line":"                if subnets:"},{"line_number":614,"context_line":"                    NeutronDbPluginV2._generate_ip(context, subnets, port_id)"},{"line_number":615,"context_line":"        return"},{"line_number":616,"context_line":""},{"line_number":617,"context_line":"    def _validate_subnet_cidr(self, context, network, new_subnet_cidr):"},{"line_number":618,"context_line":"        \"\"\"Validate the CIDR for a subnet."}],"source_content_type":"text/x-python","patch_set":6,"id":"1abeadc6_61200f4a","line":615,"updated":"2014-08-19 05:55:33.000000000","message":"This return looks a bit funny as is unnecessary.","commit_id":"9e36edef48b4c6b4e4ecf7392b053d7287fe5e7d"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"412c2ac3041321bdfa8ea087563fadfbb9c1fe0e","unresolved":false,"context_lines":[{"line_number":612,"context_line":"            for subnets in version_subnets:"},{"line_number":613,"context_line":"                if subnets:"},{"line_number":614,"context_line":"                    NeutronDbPluginV2._generate_ip(context, subnets, port_id)"},{"line_number":615,"context_line":"        return"},{"line_number":616,"context_line":""},{"line_number":617,"context_line":"    def _validate_subnet_cidr(self, context, network, new_subnet_cidr):"},{"line_number":618,"context_line":"        \"\"\"Validate the CIDR for a subnet."}],"source_content_type":"text/x-python","patch_set":6,"id":"1abeadc6_074594b2","line":615,"in_reply_to":"1abeadc6_61200f4a","updated":"2014-08-19 15:25:26.000000000","message":"Done","commit_id":"9e36edef48b4c6b4e4ecf7392b053d7287fe5e7d"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"e95f80e5b1f6d8e1d56b30435766023e7ed0ba4a","unresolved":false,"context_lines":[{"line_number":201,"context_line":"        context.session.add(allocated)"},{"line_number":202,"context_line":""},{"line_number":203,"context_line":"    @staticmethod"},{"line_number":204,"context_line":"    def _generate_ip(context, subnets, port_id):"},{"line_number":205,"context_line":"        try:"},{"line_number":206,"context_line":"            return NeutronDbPluginV2._try_generate_ip(context, subnets,"},{"line_number":207,"context_line":"                                                      port_id)"}],"source_content_type":"text/x-python","patch_set":8,"id":"1abeadc6_8a5b6486","line":204,"updated":"2014-08-19 17:19:42.000000000","message":"I wonder if making the changes to get port_id added to these methods could go in another patch to clean this up a bit.  What do you think?\n\nI\u0027m just trying to help reviewers see the really important changes in this patch without as much noise.","commit_id":"ea0486ff54a8e25e9fd6d0eb2661498032926886"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"3686ff348088d95a4136a5b9e8bfb8e2161e1311","unresolved":false,"context_lines":[{"line_number":201,"context_line":"        context.session.add(allocated)"},{"line_number":202,"context_line":""},{"line_number":203,"context_line":"    @staticmethod"},{"line_number":204,"context_line":"    def _generate_ip(context, subnets, port_id):"},{"line_number":205,"context_line":"        try:"},{"line_number":206,"context_line":"            return NeutronDbPluginV2._try_generate_ip(context, subnets,"},{"line_number":207,"context_line":"                                                      port_id)"}],"source_content_type":"text/x-python","patch_set":8,"id":"1abeadc6_d3a5f9b5","line":204,"in_reply_to":"1abeadc6_8a5b6486","updated":"2014-08-20 11:55:41.000000000","message":"Done. I have also created another patch to isolate the addition of the method _store_ip_allocation","commit_id":"ea0486ff54a8e25e9fd6d0eb2661498032926886"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"e95f80e5b1f6d8e1d56b30435766023e7ed0ba4a","unresolved":false,"context_lines":[{"line_number":221,"context_line":"            models_v2.IPAvailabilityRange).join("},{"line_number":222,"context_line":"            models_v2.IPAllocationPool)"},{"line_number":223,"context_line":""},{"line_number":224,"context_line":"        for _ in range(constants.DB_MAX_RETRIES + 1):"},{"line_number":225,"context_line":"            for subnet in subnets:"},{"line_number":226,"context_line":"                ip_range \u003d range_qry.filter_by(subnet_id\u003dsubnet[\u0027id\u0027]).first()"},{"line_number":227,"context_line":"                if not ip_range:"}],"source_content_type":"text/x-python","patch_set":8,"id":"1abeadc6_597a0cf2","line":224,"updated":"2014-08-19 17:19:42.000000000","message":"nit:  Sorry, one more nit.  This range is actually [0..10] so it will loop 11 times with the +1.\n\nrange(constants.DB_MAX_RETRIES)","commit_id":"ea0486ff54a8e25e9fd6d0eb2661498032926886"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"3686ff348088d95a4136a5b9e8bfb8e2161e1311","unresolved":false,"context_lines":[{"line_number":221,"context_line":"            models_v2.IPAvailabilityRange).join("},{"line_number":222,"context_line":"            models_v2.IPAllocationPool)"},{"line_number":223,"context_line":""},{"line_number":224,"context_line":"        for _ in range(constants.DB_MAX_RETRIES + 1):"},{"line_number":225,"context_line":"            for subnet in subnets:"},{"line_number":226,"context_line":"                ip_range \u003d range_qry.filter_by(subnet_id\u003dsubnet[\u0027id\u0027]).first()"},{"line_number":227,"context_line":"                if not ip_range:"}],"source_content_type":"text/x-python","patch_set":8,"id":"1abeadc6_6956f6d3","line":224,"in_reply_to":"1abeadc6_597a0cf2","updated":"2014-08-20 11:55:41.000000000","message":"Right!","commit_id":"ea0486ff54a8e25e9fd6d0eb2661498032926886"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"e95f80e5b1f6d8e1d56b30435766023e7ed0ba4a","unresolved":false,"context_lines":[{"line_number":332,"context_line":"        range_qry \u003d context.session.query("},{"line_number":333,"context_line":"            models_v2.IPAvailabilityRange).join("},{"line_number":334,"context_line":"                models_v2.IPAllocationPool)"},{"line_number":335,"context_line":"        for _ in range(constants.DB_MAX_RETRIES + 1):"},{"line_number":336,"context_line":"            results \u003d range_qry.filter_by(subnet_id\u003dsubnet_id)"},{"line_number":337,"context_line":"            for ip_range in results:"},{"line_number":338,"context_line":"                first \u003d int(netaddr.IPAddress(ip_range[\u0027first_ip\u0027]))"}],"source_content_type":"text/x-python","patch_set":8,"id":"1abeadc6_6c4e2898","line":335,"updated":"2014-08-19 17:19:42.000000000","message":"See L224.","commit_id":"ea0486ff54a8e25e9fd6d0eb2661498032926886"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"3686ff348088d95a4136a5b9e8bfb8e2161e1311","unresolved":false,"context_lines":[{"line_number":332,"context_line":"        range_qry \u003d context.session.query("},{"line_number":333,"context_line":"            models_v2.IPAvailabilityRange).join("},{"line_number":334,"context_line":"                models_v2.IPAllocationPool)"},{"line_number":335,"context_line":"        for _ in range(constants.DB_MAX_RETRIES + 1):"},{"line_number":336,"context_line":"            results \u003d range_qry.filter_by(subnet_id\u003dsubnet_id)"},{"line_number":337,"context_line":"            for ip_range in results:"},{"line_number":338,"context_line":"                first \u003d int(netaddr.IPAddress(ip_range[\u0027first_ip\u0027]))"}],"source_content_type":"text/x-python","patch_set":8,"id":"1abeadc6_49f5bac9","line":335,"in_reply_to":"1abeadc6_6c4e2898","updated":"2014-08-20 11:55:41.000000000","message":"Done","commit_id":"ea0486ff54a8e25e9fd6d0eb2661498032926886"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"e95f80e5b1f6d8e1d56b30435766023e7ed0ba4a","unresolved":false,"context_lines":[{"line_number":347,"context_line":"                if first \u003c\u003d ip \u003c\u003d last:"},{"line_number":348,"context_line":"                    if first \u003d\u003d last:"},{"line_number":349,"context_line":"                        count \u003d check_update_query.delete()"},{"line_number":350,"context_line":"                        if not count:"},{"line_number":351,"context_line":"                            continue"},{"line_number":352,"context_line":"                    elif first \u003d\u003d ip:"},{"line_number":353,"context_line":"                        new_first_ip \u003d str(netaddr.IPAddress(ip_address) + 1)"}],"source_content_type":"text/x-python","patch_set":8,"id":"1abeadc6_ac7120e2","line":350,"updated":"2014-08-19 17:19:42.000000000","message":"nit: also prefer count \u003d\u003d 0 here and below.","commit_id":"ea0486ff54a8e25e9fd6d0eb2661498032926886"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"3686ff348088d95a4136a5b9e8bfb8e2161e1311","unresolved":false,"context_lines":[{"line_number":347,"context_line":"                if first \u003c\u003d ip \u003c\u003d last:"},{"line_number":348,"context_line":"                    if first \u003d\u003d last:"},{"line_number":349,"context_line":"                        count \u003d check_update_query.delete()"},{"line_number":350,"context_line":"                        if not count:"},{"line_number":351,"context_line":"                            continue"},{"line_number":352,"context_line":"                    elif first \u003d\u003d ip:"},{"line_number":353,"context_line":"                        new_first_ip \u003d str(netaddr.IPAddress(ip_address) + 1)"}],"source_content_type":"text/x-python","patch_set":8,"id":"1abeadc6_c930eaa0","line":350,"in_reply_to":"1abeadc6_ac7120e2","updated":"2014-08-20 11:55:41.000000000","message":"Thanks!","commit_id":"ea0486ff54a8e25e9fd6d0eb2661498032926886"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"e95f80e5b1f6d8e1d56b30435766023e7ed0ba4a","unresolved":false,"context_lines":[{"line_number":507,"context_line":"            raise n_exc.InvalidInput(error_message\u003dmsg)"},{"line_number":508,"context_line":"        return fixed_ip_set"},{"line_number":509,"context_line":""},{"line_number":510,"context_line":"    def _allocate_fixed_ips(self, context, network_id, fixed_ips, port_id):"},{"line_number":511,"context_line":"        \"\"\"Allocate IP addresses according to the configured fixed_ips.\"\"\""},{"line_number":512,"context_line":"        ips \u003d []"},{"line_number":513,"context_line":"        for fixed in fixed_ips:"}],"source_content_type":"text/x-python","patch_set":8,"id":"1abeadc6_eafdb83c","line":510,"updated":"2014-08-19 17:19:42.000000000","message":"nit:  Maybe swap network_id and fixed_ips so that you\u0027re not inserting arguments in the middle.","commit_id":"ea0486ff54a8e25e9fd6d0eb2661498032926886"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"3686ff348088d95a4136a5b9e8bfb8e2161e1311","unresolved":false,"context_lines":[{"line_number":507,"context_line":"            raise n_exc.InvalidInput(error_message\u003dmsg)"},{"line_number":508,"context_line":"        return fixed_ip_set"},{"line_number":509,"context_line":""},{"line_number":510,"context_line":"    def _allocate_fixed_ips(self, context, network_id, fixed_ips, port_id):"},{"line_number":511,"context_line":"        \"\"\"Allocate IP addresses according to the configured fixed_ips.\"\"\""},{"line_number":512,"context_line":"        ips \u003d []"},{"line_number":513,"context_line":"        for fixed in fixed_ips:"}],"source_content_type":"text/x-python","patch_set":8,"id":"1abeadc6_f3acb5a2","line":510,"in_reply_to":"1abeadc6_eafdb83c","updated":"2014-08-20 11:55:41.000000000","message":"Done","commit_id":"ea0486ff54a8e25e9fd6d0eb2661498032926886"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"e95f80e5b1f6d8e1d56b30435766023e7ed0ba4a","unresolved":false,"context_lines":[{"line_number":566,"context_line":"                                           port_id)"},{"line_number":567,"context_line":"        return ips, prev_ips"},{"line_number":568,"context_line":""},{"line_number":569,"context_line":"    def _allocate_ips_for_port(self, context, port, port_id):"},{"line_number":570,"context_line":"        \"\"\"Allocate IP addresses for the port."},{"line_number":571,"context_line":""},{"line_number":572,"context_line":"        If port[\u0027fixed_ips\u0027] is set to \u0027ATTR_NOT_SPECIFIED\u0027, allocate IP"}],"source_content_type":"text/x-python","patch_set":8,"id":"1abeadc6_0aabd41d","line":569,"updated":"2014-08-19 17:19:42.000000000","message":"I\u0027m wondering if we need to pass port_id here or if we can get it from p[\u0027id\u0027]","commit_id":"ea0486ff54a8e25e9fd6d0eb2661498032926886"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"1d96232434b67c43e7d10c766635a726c4a6e132","unresolved":false,"context_lines":[{"line_number":566,"context_line":"                                           port_id)"},{"line_number":567,"context_line":"        return ips, prev_ips"},{"line_number":568,"context_line":""},{"line_number":569,"context_line":"    def _allocate_ips_for_port(self, context, port, port_id):"},{"line_number":570,"context_line":"        \"\"\"Allocate IP addresses for the port."},{"line_number":571,"context_line":""},{"line_number":572,"context_line":"        If port[\u0027fixed_ips\u0027] is set to \u0027ATTR_NOT_SPECIFIED\u0027, allocate IP"}],"source_content_type":"text/x-python","patch_set":8,"id":"1abeadc6_a59db35b","line":569,"in_reply_to":"1abeadc6_0aabd41d","updated":"2014-08-19 17:25:27.000000000","message":"No, we can\u0027t.  See L1313.","commit_id":"ea0486ff54a8e25e9fd6d0eb2661498032926886"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"1d96232434b67c43e7d10c766635a726c4a6e132","unresolved":false,"context_lines":[{"line_number":1309,"context_line":"        return self._create_bulk(\u0027port\u0027, context, ports)"},{"line_number":1310,"context_line":""},{"line_number":1311,"context_line":"    def create_port(self, context, port):"},{"line_number":1312,"context_line":"        p \u003d port[\u0027port\u0027]"},{"line_number":1313,"context_line":"        port_id \u003d p.get(\u0027id\u0027) or uuidutils.generate_uuid()"},{"line_number":1314,"context_line":"        network_id \u003d p[\u0027network_id\u0027]"},{"line_number":1315,"context_line":"        # NOTE(jkoelker) Get the tenant_id outside of the session to avoid"}],"source_content_type":"text/x-python","patch_set":8,"id":"1abeadc6_25728349","line":1312,"updated":"2014-08-19 17:25:27.000000000","message":"This answers my question about whether we can get port_id from p[\u0027id\u0027] on L569.","commit_id":"ea0486ff54a8e25e9fd6d0eb2661498032926886"},{"author":{"_account_id":8788,"name":"Miguel Angel Ajo","email":"mangelajo@redhat.com","username":"mangelajo"},"change_message_id":"2c59e847f5bd5a48756cd120667fb2ebc4adf1c2","unresolved":false,"context_lines":[{"line_number":219,"context_line":"        \"\"\""},{"line_number":220,"context_line":"        range_qry \u003d context.session.query("},{"line_number":221,"context_line":"            models_v2.IPAvailabilityRange).join("},{"line_number":222,"context_line":"            models_v2.IPAllocationPool)"},{"line_number":223,"context_line":""},{"line_number":224,"context_line":"        for _ in range(constants.DB_MAX_RETRIES):"},{"line_number":225,"context_line":"            for subnet in subnets:"}],"source_content_type":"text/x-python","patch_set":14,"id":"fa98f980_c70e6be5","line":222,"updated":"2014-09-08 09:39:08.000000000","message":"nit: This line doesn\u0027t need to be split anymore.","commit_id":"cf13fe3fe11e87d0cbe3d089ff8f893b4b107b92"},{"author":{"_account_id":8788,"name":"Miguel Angel Ajo","email":"mangelajo@redhat.com","username":"mangelajo"},"change_message_id":"2c59e847f5bd5a48756cd120667fb2ebc4adf1c2","unresolved":false,"context_lines":[{"line_number":250,"context_line":"                    new_first_ip \u003d str(netaddr.IPAddress(ip_address) + 1)"},{"line_number":251,"context_line":"                    count \u003d check_update_query.update("},{"line_number":252,"context_line":"                        {\"first_ip\": new_first_ip})"},{"line_number":253,"context_line":"                    if count \u003d\u003d 0:"},{"line_number":254,"context_line":"                        continue"},{"line_number":255,"context_line":""},{"line_number":256,"context_line":"                LOG.debug(\"Allocated IP - %(ip_address)s from %(first_ip)s \""}],"source_content_type":"text/x-python","patch_set":14,"id":"fa98f980_07c9535a","line":253,"updated":"2014-09-08 09:39:08.000000000","message":"Have you considered logging the retry as debug?","commit_id":"cf13fe3fe11e87d0cbe3d089ff8f893b4b107b92"},{"author":{"_account_id":2035,"name":"Maru Newby","email":"marun@redhat.com","username":"maru"},"change_message_id":"3f57654c608bf2458783412dbda59e26f7fa8abe","unresolved":false,"context_lines":[{"line_number":267,"context_line":""},{"line_number":268,"context_line":"    @staticmethod"},{"line_number":269,"context_line":"    def _rebuild_availability_ranges(context, subnets):"},{"line_number":270,"context_line":"        ip_qry \u003d context.session.query("},{"line_number":271,"context_line":"            models_v2.IPAllocation)"},{"line_number":272,"context_line":"        # PostgreSQL does not support select...for update with an outer join."},{"line_number":273,"context_line":"        # No join is needed here."}],"source_content_type":"text/x-python","patch_set":14,"id":"1abeadc6_2685b1ce","line":270,"updated":"2014-09-01 11:14:51.000000000","message":"nit: This line probably doesn\u0027t need to be split anymore.","commit_id":"cf13fe3fe11e87d0cbe3d089ff8f893b4b107b92"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"be2414c9c86bc43cc3e7c969988732a52bb89d96","unresolved":false,"context_lines":[{"line_number":267,"context_line":""},{"line_number":268,"context_line":"    @staticmethod"},{"line_number":269,"context_line":"    def _rebuild_availability_ranges(context, subnets):"},{"line_number":270,"context_line":"        ip_qry \u003d context.session.query("},{"line_number":271,"context_line":"            models_v2.IPAllocation)"},{"line_number":272,"context_line":"        # PostgreSQL does not support select...for update with an outer join."},{"line_number":273,"context_line":"        # No join is needed here."}],"source_content_type":"text/x-python","patch_set":14,"id":"fa98f980_91d68f4d","line":270,"in_reply_to":"1abeadc6_2685b1ce","updated":"2014-09-08 08:54:30.000000000","message":"Done","commit_id":"cf13fe3fe11e87d0cbe3d089ff8f893b4b107b92"},{"author":{"_account_id":2035,"name":"Maru Newby","email":"marun@redhat.com","username":"maru"},"change_message_id":"3f57654c608bf2458783412dbda59e26f7fa8abe","unresolved":false,"context_lines":[{"line_number":311,"context_line":"                            last_ip\u003dstr(netaddr.IPAddress(ip_range.last)))"},{"line_number":312,"context_line":"                        context.session.add(available_range)"},{"line_number":313,"context_line":"                except db_exc.DBDuplicateEntry:"},{"line_number":314,"context_line":"                    # _rebuild_availability_ranges is called only when there\u0027s"},{"line_number":315,"context_line":"                    # no more IP available or by"},{"line_number":316,"context_line":"                    # _update_subnet_allocation_pools."},{"line_number":317,"context_line":"                    # _update_subnet_allocation_pools before calling this"}],"source_content_type":"text/x-python","patch_set":14,"id":"1abeadc6_66ade930","line":314,"updated":"2014-09-01 11:14:51.000000000","message":"Consider rewriting this comment as a method-level docstring, since it\u0027s quite central to the purpose of the method.","commit_id":"cf13fe3fe11e87d0cbe3d089ff8f893b4b107b92"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"be2414c9c86bc43cc3e7c969988732a52bb89d96","unresolved":false,"context_lines":[{"line_number":311,"context_line":"                            last_ip\u003dstr(netaddr.IPAddress(ip_range.last)))"},{"line_number":312,"context_line":"                        context.session.add(available_range)"},{"line_number":313,"context_line":"                except db_exc.DBDuplicateEntry:"},{"line_number":314,"context_line":"                    # _rebuild_availability_ranges is called only when there\u0027s"},{"line_number":315,"context_line":"                    # no more IP available or by"},{"line_number":316,"context_line":"                    # _update_subnet_allocation_pools."},{"line_number":317,"context_line":"                    # _update_subnet_allocation_pools before calling this"}],"source_content_type":"text/x-python","patch_set":14,"id":"fa98f980_acf25803","line":314,"in_reply_to":"1abeadc6_66ade930","updated":"2014-09-08 08:54:30.000000000","message":"Done","commit_id":"cf13fe3fe11e87d0cbe3d089ff8f893b4b107b92"},{"author":{"_account_id":2035,"name":"Maru Newby","email":"marun@redhat.com","username":"maru"},"change_message_id":"3f57654c608bf2458783412dbda59e26f7fa8abe","unresolved":false,"context_lines":[{"line_number":314,"context_line":"                    # _rebuild_availability_ranges is called only when there\u0027s"},{"line_number":315,"context_line":"                    # no more IP available or by"},{"line_number":316,"context_line":"                    # _update_subnet_allocation_pools."},{"line_number":317,"context_line":"                    # _update_subnet_allocation_pools before calling this"},{"line_number":318,"context_line":"                    # function deletes the IPAllocationPools associated with"},{"line_number":319,"context_line":"                    # the subnet that is updating, which will result in"},{"line_number":320,"context_line":"                    # deleting the IPAvailabilityRange too. If DBDuplicateEntry"}],"source_content_type":"text/x-python","patch_set":14,"id":"1abeadc6_0659958d","line":317,"updated":"2014-09-01 11:14:51.000000000","message":"_update_subnet_allocation_pools -\u003e Calling _update_subnet_allocation_pools","commit_id":"cf13fe3fe11e87d0cbe3d089ff8f893b4b107b92"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"be2414c9c86bc43cc3e7c969988732a52bb89d96","unresolved":false,"context_lines":[{"line_number":314,"context_line":"                    # _rebuild_availability_ranges is called only when there\u0027s"},{"line_number":315,"context_line":"                    # no more IP available or by"},{"line_number":316,"context_line":"                    # _update_subnet_allocation_pools."},{"line_number":317,"context_line":"                    # _update_subnet_allocation_pools before calling this"},{"line_number":318,"context_line":"                    # function deletes the IPAllocationPools associated with"},{"line_number":319,"context_line":"                    # the subnet that is updating, which will result in"},{"line_number":320,"context_line":"                    # deleting the IPAvailabilityRange too. If DBDuplicateEntry"}],"source_content_type":"text/x-python","patch_set":14,"id":"fa98f980_713a0b9a","line":317,"in_reply_to":"1abeadc6_0659958d","updated":"2014-09-08 08:54:30.000000000","message":"Done","commit_id":"cf13fe3fe11e87d0cbe3d089ff8f893b4b107b92"},{"author":{"_account_id":2035,"name":"Maru Newby","email":"marun@redhat.com","username":"maru"},"change_message_id":"3f57654c608bf2458783412dbda59e26f7fa8abe","unresolved":false,"context_lines":[{"line_number":320,"context_line":"                    # deleting the IPAvailabilityRange too. If DBDuplicateEntry"},{"line_number":321,"context_line":"                    # is thrown, another Neutron server has run"},{"line_number":322,"context_line":"                    # _rebuild_availability_ranges, in this case that\u0027s no"},{"line_number":323,"context_line":"                    # need of reraising the exception"},{"line_number":324,"context_line":"                    LOG.error(_(\"A concurrent _rebuild_availability_ranges\""},{"line_number":325,"context_line":"                              \" had already added this range\"))"},{"line_number":326,"context_line":""}],"source_content_type":"text/x-python","patch_set":14,"id":"1abeadc6_c6c95d27","line":323,"updated":"2014-09-01 11:14:51.000000000","message":"need of reraising -\u003e need to reraise","commit_id":"cf13fe3fe11e87d0cbe3d089ff8f893b4b107b92"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"be2414c9c86bc43cc3e7c969988732a52bb89d96","unresolved":false,"context_lines":[{"line_number":320,"context_line":"                    # deleting the IPAvailabilityRange too. If DBDuplicateEntry"},{"line_number":321,"context_line":"                    # is thrown, another Neutron server has run"},{"line_number":322,"context_line":"                    # _rebuild_availability_ranges, in this case that\u0027s no"},{"line_number":323,"context_line":"                    # need of reraising the exception"},{"line_number":324,"context_line":"                    LOG.error(_(\"A concurrent _rebuild_availability_ranges\""},{"line_number":325,"context_line":"                              \" had already added this range\"))"},{"line_number":326,"context_line":""}],"source_content_type":"text/x-python","patch_set":14,"id":"fa98f980_71612ba8","line":323,"in_reply_to":"1abeadc6_c6c95d27","updated":"2014-09-08 08:54:30.000000000","message":"Done","commit_id":"cf13fe3fe11e87d0cbe3d089ff8f893b4b107b92"},{"author":{"_account_id":2035,"name":"Maru Newby","email":"marun@redhat.com","username":"maru"},"change_message_id":"3f57654c608bf2458783412dbda59e26f7fa8abe","unresolved":false,"context_lines":[{"line_number":321,"context_line":"                    # is thrown, another Neutron server has run"},{"line_number":322,"context_line":"                    # _rebuild_availability_ranges, in this case that\u0027s no"},{"line_number":323,"context_line":"                    # need of reraising the exception"},{"line_number":324,"context_line":"                    LOG.error(_(\"A concurrent _rebuild_availability_ranges\""},{"line_number":325,"context_line":"                              \" had already added this range\"))"},{"line_number":326,"context_line":""},{"line_number":327,"context_line":"    @staticmethod"}],"source_content_type":"text/x-python","patch_set":14,"id":"1abeadc6_e69ad912","line":324,"updated":"2014-09-01 11:14:51.000000000","message":"I think a warning or info log level would be more appropriate given that this condition doesn\u0027t inhibit usage.  Also, it probably makes sense to use the appropriate _L* gettext function to localize the message.","commit_id":"cf13fe3fe11e87d0cbe3d089ff8f893b4b107b92"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"be2414c9c86bc43cc3e7c969988732a52bb89d96","unresolved":false,"context_lines":[{"line_number":321,"context_line":"                    # is thrown, another Neutron server has run"},{"line_number":322,"context_line":"                    # _rebuild_availability_ranges, in this case that\u0027s no"},{"line_number":323,"context_line":"                    # need of reraising the exception"},{"line_number":324,"context_line":"                    LOG.error(_(\"A concurrent _rebuild_availability_ranges\""},{"line_number":325,"context_line":"                              \" had already added this range\"))"},{"line_number":326,"context_line":""},{"line_number":327,"context_line":"    @staticmethod"}],"source_content_type":"text/x-python","patch_set":14,"id":"fa98f980_71d68b29","line":324,"in_reply_to":"1abeadc6_e69ad912","updated":"2014-09-08 08:54:30.000000000","message":"Done","commit_id":"cf13fe3fe11e87d0cbe3d089ff8f893b4b107b92"},{"author":{"_account_id":8788,"name":"Miguel Angel Ajo","email":"mangelajo@redhat.com","username":"mangelajo"},"change_message_id":"2c59e847f5bd5a48756cd120667fb2ebc4adf1c2","unresolved":false,"context_lines":[{"line_number":353,"context_line":"                        new_first_ip \u003d str(netaddr.IPAddress(ip_address) + 1)"},{"line_number":354,"context_line":"                        count \u003d (check_update_query.update("},{"line_number":355,"context_line":"                            {\"first_ip\": new_first_ip}))"},{"line_number":356,"context_line":"                        if count \u003d\u003d 0:"},{"line_number":357,"context_line":"                            continue"},{"line_number":358,"context_line":"                    elif last \u003d\u003d ip:"},{"line_number":359,"context_line":"                        new_last_ip \u003d str(netaddr.IPAddress(ip_address) - 1)"}],"source_content_type":"text/x-python","patch_set":14,"id":"fa98f980_e710cfaa","line":356,"updated":"2014-09-08 09:39:08.000000000","message":"Debug logging retry?","commit_id":"cf13fe3fe11e87d0cbe3d089ff8f893b4b107b92"},{"author":{"_account_id":8788,"name":"Miguel Angel Ajo","email":"mangelajo@redhat.com","username":"mangelajo"},"change_message_id":"2c59e847f5bd5a48756cd120667fb2ebc4adf1c2","unresolved":false,"context_lines":[{"line_number":360,"context_line":"                        count \u003d (check_update_query.update("},{"line_number":361,"context_line":"                            {\"last_ip\": new_last_ip}))"},{"line_number":362,"context_line":"                        if count \u003d\u003d 0:"},{"line_number":363,"context_line":"                            continue"},{"line_number":364,"context_line":"                    else:"},{"line_number":365,"context_line":"                        # Split into two ranges"},{"line_number":366,"context_line":"                        new_first \u003d str(netaddr.IPAddress(ip_address) + 1)"}],"source_content_type":"text/x-python","patch_set":14,"id":"fa98f980_0725d309","line":363,"updated":"2014-09-08 09:39:08.000000000","message":"Ditto","commit_id":"cf13fe3fe11e87d0cbe3d089ff8f893b4b107b92"},{"author":{"_account_id":8788,"name":"Miguel Angel Ajo","email":"mangelajo@redhat.com","username":"mangelajo"},"change_message_id":"2c59e847f5bd5a48756cd120667fb2ebc4adf1c2","unresolved":false,"context_lines":[{"line_number":369,"context_line":"                            {\"last_ip\": str(netaddr.IPAddress("},{"line_number":370,"context_line":"                                ip_address) - 1)}))"},{"line_number":371,"context_line":"                        if count \u003d\u003d 0:"},{"line_number":372,"context_line":"                            continue"},{"line_number":373,"context_line":"                        new_ip_range \u003d models_v2.IPAvailabilityRange("},{"line_number":374,"context_line":"                            allocation_pool_id\u003dip_range["},{"line_number":375,"context_line":"                                \u0027allocation_pool_id\u0027],"}],"source_content_type":"text/x-python","patch_set":14,"id":"fa98f980_2722d701","line":372,"updated":"2014-09-08 09:39:08.000000000","message":"Ditto.","commit_id":"cf13fe3fe11e87d0cbe3d089ff8f893b4b107b92"},{"author":{"_account_id":8124,"name":"cbrandily","email":"zzelle@gmail.com","username":"cbrandily"},"change_message_id":"2c6a0d4f67733956ad06e7d86b550aa188ae684f","unresolved":false,"context_lines":[{"line_number":381,"context_line":"                    context, ip_address, network_id,"},{"line_number":382,"context_line":"                    subnet_id, port_id)"},{"line_number":383,"context_line":"                return"},{"line_number":384,"context_line":"        LOG.error(_(\"Failed allocating ip %s\"), ip_address)"},{"line_number":385,"context_line":"        raise n_exc.NoIpAllocatedInMaximumAllowedAttempt"},{"line_number":386,"context_line":""},{"line_number":387,"context_line":"    @staticmethod"}],"source_content_type":"text/x-python","patch_set":14,"id":"fa98f980_14bbea72","line":384,"updated":"2014-09-02 16:05:33.000000000","message":"it should _LE instead of _","commit_id":"cf13fe3fe11e87d0cbe3d089ff8f893b4b107b92"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"be2414c9c86bc43cc3e7c969988732a52bb89d96","unresolved":false,"context_lines":[{"line_number":381,"context_line":"                    context, ip_address, network_id,"},{"line_number":382,"context_line":"                    subnet_id, port_id)"},{"line_number":383,"context_line":"                return"},{"line_number":384,"context_line":"        LOG.error(_(\"Failed allocating ip %s\"), ip_address)"},{"line_number":385,"context_line":"        raise n_exc.NoIpAllocatedInMaximumAllowedAttempt"},{"line_number":386,"context_line":""},{"line_number":387,"context_line":"    @staticmethod"}],"source_content_type":"text/x-python","patch_set":14,"id":"fa98f980_11e53f08","line":384,"in_reply_to":"fa98f980_14bbea72","updated":"2014-09-08 08:54:30.000000000","message":"Done","commit_id":"cf13fe3fe11e87d0cbe3d089ff8f893b4b107b92"},{"author":{"_account_id":8124,"name":"cbrandily","email":"zzelle@gmail.com","username":"cbrandily"},"change_message_id":"2c6a0d4f67733956ad06e7d86b550aa188ae684f","unresolved":false,"context_lines":[{"line_number":1283,"context_line":"            tenant_ports \u003d (context.session.query(models_v2.IPAllocation)."},{"line_number":1284,"context_line":"                            filter_by(subnet_id\u003dsubnet[\u0027id\u0027])."},{"line_number":1285,"context_line":"                            join(models_v2.Port)."},{"line_number":1286,"context_line":"                            filter_by(network_id\u003dsubnet[\u0027network_id\u0027]).all())"},{"line_number":1287,"context_line":"            if tenant_ports:"},{"line_number":1288,"context_line":"                raise n_exc.SubnetInUse(subnet_id\u003did)"},{"line_number":1289,"context_line":""}],"source_content_type":"text/x-python","patch_set":14,"id":"fa98f980_97199c7b","line":1286,"updated":"2014-09-02 16:05:33.000000000","message":"as said in an other change, no need to query all tenant ports, you can get one or count them","commit_id":"cf13fe3fe11e87d0cbe3d089ff8f893b4b107b92"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"be2414c9c86bc43cc3e7c969988732a52bb89d96","unresolved":false,"context_lines":[{"line_number":1283,"context_line":"            tenant_ports \u003d (context.session.query(models_v2.IPAllocation)."},{"line_number":1284,"context_line":"                            filter_by(subnet_id\u003dsubnet[\u0027id\u0027])."},{"line_number":1285,"context_line":"                            join(models_v2.Port)."},{"line_number":1286,"context_line":"                            filter_by(network_id\u003dsubnet[\u0027network_id\u0027]).all())"},{"line_number":1287,"context_line":"            if tenant_ports:"},{"line_number":1288,"context_line":"                raise n_exc.SubnetInUse(subnet_id\u003did)"},{"line_number":1289,"context_line":""}],"source_content_type":"text/x-python","patch_set":14,"id":"fa98f980_d1b657f8","line":1286,"in_reply_to":"fa98f980_97199c7b","updated":"2014-09-08 08:54:30.000000000","message":"Done","commit_id":"cf13fe3fe11e87d0cbe3d089ff8f893b4b107b92"},{"author":{"_account_id":2035,"name":"Maru Newby","email":"marun@redhat.com","username":"maru"},"change_message_id":"3f57654c608bf2458783412dbda59e26f7fa8abe","unresolved":false,"context_lines":[{"line_number":1348,"context_line":"            else:"},{"line_number":1349,"context_line":"                status \u003d p[\u0027status\u0027]"},{"line_number":1350,"context_line":""},{"line_number":1351,"context_line":"            port_db \u003d models_v2.Port(tenant_id\u003dtenant_id,"},{"line_number":1352,"context_line":"                                     name\u003dp[\u0027name\u0027],"},{"line_number":1353,"context_line":"                                     id\u003dport_id,"},{"line_number":1354,"context_line":"                                     network_id\u003dnetwork_id,"}],"source_content_type":"text/x-python","patch_set":14,"id":"1abeadc6_290bc224","line":1351,"updated":"2014-09-01 11:14:51.000000000","message":"db_port might be a better name - port_db reads like it\u0027s referring to a database.","commit_id":"cf13fe3fe11e87d0cbe3d089ff8f893b4b107b92"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"be2414c9c86bc43cc3e7c969988732a52bb89d96","unresolved":false,"context_lines":[{"line_number":1348,"context_line":"            else:"},{"line_number":1349,"context_line":"                status \u003d p[\u0027status\u0027]"},{"line_number":1350,"context_line":""},{"line_number":1351,"context_line":"            port_db \u003d models_v2.Port(tenant_id\u003dtenant_id,"},{"line_number":1352,"context_line":"                                     name\u003dp[\u0027name\u0027],"},{"line_number":1353,"context_line":"                                     id\u003dport_id,"},{"line_number":1354,"context_line":"                                     network_id\u003dnetwork_id,"}],"source_content_type":"text/x-python","patch_set":14,"id":"fa98f980_11cc5f88","line":1351,"in_reply_to":"1abeadc6_290bc224","updated":"2014-09-08 08:54:30.000000000","message":"Done","commit_id":"cf13fe3fe11e87d0cbe3d089ff8f893b4b107b92"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"5880da54c161b5aa95abb09cb88a86626b521fda","unresolved":false,"context_lines":[{"line_number":904,"context_line":""},{"line_number":905,"context_line":"            # clean up network owned ports"},{"line_number":906,"context_line":"            for port in ports:"},{"line_number":907,"context_line":"                self._delete_port(context, port[\u0027id\u0027])"},{"line_number":908,"context_line":""},{"line_number":909,"context_line":"            # clean up subnets"},{"line_number":910,"context_line":"            subnets_qry \u003d context.session.query(models_v2.Subnet)"}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_af0ce33c","side":"PARENT","line":907,"updated":"2014-09-16 22:41:02.000000000","message":"I see you\u0027ve moved the deletion of ports to subnet.  Hmmm...","commit_id":"aaea5dd1c4f396bbd760fa677ced3518149bd6db"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"6d423794bea30109d0651405bd6510e3bbfd8a15","unresolved":false,"context_lines":[{"line_number":36,"context_line":"from neutron import neutron_plugin_base_v2"},{"line_number":37,"context_line":"from neutron.openstack.common import excutils"},{"line_number":38,"context_line":"from neutron.openstack.common.gettextutils import _LE"},{"line_number":39,"context_line":"from neutron.openstack.common.gettextutils import _LI"},{"line_number":40,"context_line":"from neutron.openstack.common import log as logging"},{"line_number":41,"context_line":"from neutron.openstack.common import uuidutils"},{"line_number":42,"context_line":"from neutron.plugins.common import constants as service_constants"}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_715304e2","line":39,"updated":"2014-09-14 09:25:47.000000000","message":"import both on one line\n\nfrom neutron.openstack.common.gettextutils import _LE, _LI","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"139acc3d96b4e29b2d1aafb3213007716d11d42b","unresolved":false,"context_lines":[{"line_number":36,"context_line":"from neutron import neutron_plugin_base_v2"},{"line_number":37,"context_line":"from neutron.openstack.common import excutils"},{"line_number":38,"context_line":"from neutron.openstack.common.gettextutils import _LE"},{"line_number":39,"context_line":"from neutron.openstack.common.gettextutils import _LI"},{"line_number":40,"context_line":"from neutron.openstack.common import log as logging"},{"line_number":41,"context_line":"from neutron.openstack.common import uuidutils"},{"line_number":42,"context_line":"from neutron.plugins.common import constants as service_constants"}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_de0a8d26","line":39,"in_reply_to":"fa98f980_715304e2","updated":"2014-09-18 14:20:16.000000000","message":"Done","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"5880da54c161b5aa95abb09cb88a86626b521fda","unresolved":false,"context_lines":[{"line_number":51,"context_line":"# finds out that all existing IP Allocations are associated with ports"},{"line_number":52,"context_line":"# with these owners, it will allow subnet deletion to proceed with the"},{"line_number":53,"context_line":"# IP allocations being cleaned up by cascade."},{"line_number":54,"context_line":"AUTO_DELETE_PORT_OWNERS \u003d [constants.DEVICE_OWNER_DHCP]"},{"line_number":55,"context_line":""},{"line_number":56,"context_line":""},{"line_number":57,"context_line":"class NeutronDbPluginV2(neutron_plugin_base_v2.NeutronPluginBaseV2,"}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_9aa3dfff","line":54,"updated":"2014-09-16 22:41:02.000000000","message":"This constant is no longer used in this file but is referenced from other files.  See comments below about not abandoning the use of this constant in this file.","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":1653,"name":"garyk","email":"gkotton@vmware.com","username":"garyk"},"change_message_id":"91972ed502b3647027ecf1c0aa3e590791088fe9","unresolved":false,"context_lines":[{"line_number":223,"context_line":"            models_v2.IPAvailabilityRange).join("},{"line_number":224,"context_line":"            models_v2.IPAllocationPool)"},{"line_number":225,"context_line":""},{"line_number":226,"context_line":"        for _ in range(constants.DB_MAX_RETRIES):"},{"line_number":227,"context_line":"            for subnet in subnets:"},{"line_number":228,"context_line":"                ip_range \u003d range_qry.filter_by(subnet_id\u003dsubnet[\u0027id\u0027]).first()"},{"line_number":229,"context_line":"                if not ip_range:"}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_678f4d24","line":226,"updated":"2014-09-09 14:13:58.000000000","message":"maybe we can break this code out and have a decorator.","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"9b5d2e53e71c5a51e60147e497e2d3a85653e18f","unresolved":false,"context_lines":[{"line_number":223,"context_line":"            models_v2.IPAvailabilityRange).join("},{"line_number":224,"context_line":"            models_v2.IPAllocationPool)"},{"line_number":225,"context_line":""},{"line_number":226,"context_line":"        for _ in range(constants.DB_MAX_RETRIES):"},{"line_number":227,"context_line":"            for subnet in subnets:"},{"line_number":228,"context_line":"                ip_range \u003d range_qry.filter_by(subnet_id\u003dsubnet[\u0027id\u0027]).first()"},{"line_number":229,"context_line":"                if not ip_range:"}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_f545dc15","line":226,"in_reply_to":"fa98f980_1bd89c7e","updated":"2014-09-16 23:08:17.000000000","message":"I see little value in that now.  I think we need to get the rest of the logic right before we go this route.  It could be done in Kilo as a follow-on.","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":8124,"name":"cbrandily","email":"zzelle@gmail.com","username":"cbrandily"},"change_message_id":"92faedbd6d9cc40399c214a5d43f3fad5a7d0ee8","unresolved":false,"context_lines":[{"line_number":223,"context_line":"            models_v2.IPAvailabilityRange).join("},{"line_number":224,"context_line":"            models_v2.IPAllocationPool)"},{"line_number":225,"context_line":""},{"line_number":226,"context_line":"        for _ in range(constants.DB_MAX_RETRIES):"},{"line_number":227,"context_line":"            for subnet in subnets:"},{"line_number":228,"context_line":"                ip_range \u003d range_qry.filter_by(subnet_id\u003dsubnet[\u0027id\u0027]).first()"},{"line_number":229,"context_line":"                if not ip_range:"}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_1bd89c7e","line":226,"in_reply_to":"fa98f980_678f4d24","updated":"2014-09-09 15:51:40.000000000","message":"such decorator will be used in two places for the moment ... and one[1] uses retry number in logs\n\n[1]https://review.openstack.org/#/c/100963/17/neutron/plugins/ml2/drivers/helpers.py","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"1a717823cd4c3b906e7e428f6380bb79d9fd1cfa","unresolved":false,"context_lines":[{"line_number":223,"context_line":"            models_v2.IPAvailabilityRange).join("},{"line_number":224,"context_line":"            models_v2.IPAllocationPool)"},{"line_number":225,"context_line":""},{"line_number":226,"context_line":"        for _ in range(constants.DB_MAX_RETRIES):"},{"line_number":227,"context_line":"            for subnet in subnets:"},{"line_number":228,"context_line":"                ip_range \u003d range_qry.filter_by(subnet_id\u003dsubnet[\u0027id\u0027]).first()"},{"line_number":229,"context_line":"                if not ip_range:"}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_694ca2c9","line":226,"in_reply_to":"fa98f980_f545dc15","updated":"2014-09-17 16:29:50.000000000","message":"+1","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"5880da54c161b5aa95abb09cb88a86626b521fda","unresolved":false,"context_lines":[{"line_number":231,"context_line":"                              \"allocated\","},{"line_number":232,"context_line":"                              {\u0027subnet_id\u0027: subnet[\u0027id\u0027],"},{"line_number":233,"context_line":"                               \u0027cidr\u0027: subnet[\u0027cidr\u0027]})"},{"line_number":234,"context_line":"                    break"},{"line_number":235,"context_line":"                # Update the database record only if the existing record"},{"line_number":236,"context_line":"                # matches exactly what it\u0027s expected, that is only if no other"},{"line_number":237,"context_line":"                # process has modified the same record"}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_60ecd093","line":234,"updated":"2014-09-16 22:41:02.000000000","message":"This break will make it so that we only consider the first subnet in subnets.  It will kick it out to the retry loop but we\u0027re very likely to get the same answer each time.  I think this should still be \"continue.\"","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"139acc3d96b4e29b2d1aafb3213007716d11d42b","unresolved":false,"context_lines":[{"line_number":231,"context_line":"                              \"allocated\","},{"line_number":232,"context_line":"                              {\u0027subnet_id\u0027: subnet[\u0027id\u0027],"},{"line_number":233,"context_line":"                               \u0027cidr\u0027: subnet[\u0027cidr\u0027]})"},{"line_number":234,"context_line":"                    break"},{"line_number":235,"context_line":"                # Update the database record only if the existing record"},{"line_number":236,"context_line":"                # matches exactly what it\u0027s expected, that is only if no other"},{"line_number":237,"context_line":"                # process has modified the same record"}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_d938e7d6","line":234,"in_reply_to":"fa98f980_49d6fec4","updated":"2014-09-18 14:20:16.000000000","message":"I swapped the 2 cycles so now the \"break\" fits the purpose :)","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"1a717823cd4c3b906e7e428f6380bb79d9fd1cfa","unresolved":false,"context_lines":[{"line_number":231,"context_line":"                              \"allocated\","},{"line_number":232,"context_line":"                              {\u0027subnet_id\u0027: subnet[\u0027id\u0027],"},{"line_number":233,"context_line":"                               \u0027cidr\u0027: subnet[\u0027cidr\u0027]})"},{"line_number":234,"context_line":"                    break"},{"line_number":235,"context_line":"                # Update the database record only if the existing record"},{"line_number":236,"context_line":"                # matches exactly what it\u0027s expected, that is only if no other"},{"line_number":237,"context_line":"                # process has modified the same record"}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_49d6fec4","line":234,"in_reply_to":"fa98f980_60ecd093","updated":"2014-09-17 16:29:50.000000000","message":"Right, thanks!","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"5880da54c161b5aa95abb09cb88a86626b521fda","unresolved":false,"context_lines":[{"line_number":242,"context_line":"                ip_address \u003d ip_range[\u0027first_ip\u0027]"},{"line_number":243,"context_line":"                if ip_range[\u0027first_ip\u0027] \u003d\u003d ip_range[\u0027last_ip\u0027]:"},{"line_number":244,"context_line":"                    # No more free indices on subnet \u003d\u003e delete"},{"line_number":245,"context_line":"                    LOG.debug(\"No more free IP\u0027s in slice. Deleting \""},{"line_number":246,"context_line":"                              \"allocation pool.\")"},{"line_number":247,"context_line":"                    count \u003d check_update_query.delete()"},{"line_number":248,"context_line":"                    if count \u003d\u003d 0:"}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_e93eebb8","line":245,"updated":"2014-09-16 22:41:02.000000000","message":"Maybe in the interest of making this patch more easily consumable by reviewers we shouldn\u0027t remove the _() in the debug messages.  Or, we could do a pre-work cleanup patch separate from this one.  I\u0027m concerned that reviewers are frightened by the size of this patch.","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"139acc3d96b4e29b2d1aafb3213007716d11d42b","unresolved":false,"context_lines":[{"line_number":242,"context_line":"                ip_address \u003d ip_range[\u0027first_ip\u0027]"},{"line_number":243,"context_line":"                if ip_range[\u0027first_ip\u0027] \u003d\u003d ip_range[\u0027last_ip\u0027]:"},{"line_number":244,"context_line":"                    # No more free indices on subnet \u003d\u003e delete"},{"line_number":245,"context_line":"                    LOG.debug(\"No more free IP\u0027s in slice. Deleting \""},{"line_number":246,"context_line":"                              \"allocation pool.\")"},{"line_number":247,"context_line":"                    count \u003d check_update_query.delete()"},{"line_number":248,"context_line":"                    if count \u003d\u003d 0:"}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_f90ccb3b","line":245,"in_reply_to":"fa98f980_30e676e9","updated":"2014-09-18 14:20:16.000000000","message":"Agreed I will use your patch chain, thanks for that! :)","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"87dea8f1391bdff91185318d8a51011f89d0cb49","unresolved":false,"context_lines":[{"line_number":242,"context_line":"                ip_address \u003d ip_range[\u0027first_ip\u0027]"},{"line_number":243,"context_line":"                if ip_range[\u0027first_ip\u0027] \u003d\u003d ip_range[\u0027last_ip\u0027]:"},{"line_number":244,"context_line":"                    # No more free indices on subnet \u003d\u003e delete"},{"line_number":245,"context_line":"                    LOG.debug(\"No more free IP\u0027s in slice. Deleting \""},{"line_number":246,"context_line":"                              \"allocation pool.\")"},{"line_number":247,"context_line":"                    count \u003d check_update_query.delete()"},{"line_number":248,"context_line":"                    if count \u003d\u003d 0:"}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_30e676e9","line":245,"in_reply_to":"fa98f980_89f70659","updated":"2014-09-17 21:00:56.000000000","message":"See my pre-work patch in my patch chain.  These things add up.  By extracting them out, it made the real substance of this patch easier to review.\n\nAlso, if we end up having the revert this patch (I hope not) then we\u0027d be back at square one.","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"1a717823cd4c3b906e7e428f6380bb79d9fd1cfa","unresolved":false,"context_lines":[{"line_number":242,"context_line":"                ip_address \u003d ip_range[\u0027first_ip\u0027]"},{"line_number":243,"context_line":"                if ip_range[\u0027first_ip\u0027] \u003d\u003d ip_range[\u0027last_ip\u0027]:"},{"line_number":244,"context_line":"                    # No more free indices on subnet \u003d\u003e delete"},{"line_number":245,"context_line":"                    LOG.debug(\"No more free IP\u0027s in slice. Deleting \""},{"line_number":246,"context_line":"                              \"allocation pool.\")"},{"line_number":247,"context_line":"                    count \u003d check_update_query.delete()"},{"line_number":248,"context_line":"                    if count \u003d\u003d 0:"}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_89f70659","line":245,"in_reply_to":"fa98f980_e93eebb8","updated":"2014-09-17 16:29:50.000000000","message":"I am mixed...no idea...in the end it\u0027s a trivial change and it\u0027s only one line!","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"9b5d2e53e71c5a51e60147e497e2d3a85653e18f","unresolved":false,"context_lines":[{"line_number":246,"context_line":"                              \"allocation pool.\")"},{"line_number":247,"context_line":"                    count \u003d check_update_query.delete()"},{"line_number":248,"context_line":"                    if count \u003d\u003d 0:"},{"line_number":249,"context_line":"                        continue"},{"line_number":250,"context_line":"                else:"},{"line_number":251,"context_line":"                    # increment the first free"},{"line_number":252,"context_line":"                    new_first_ip \u003d str(netaddr.IPAddress(ip_address) + 1)"}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_d5c1b882","line":249,"updated":"2014-09-16 23:08:17.000000000","message":"This continues on to the next subnet.  Shouldn\u0027t this continue to the next retry (L226 loop vs L227 loop).  If this were a break instead of a continue, I think that would achieve it, right?","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"139acc3d96b4e29b2d1aafb3213007716d11d42b","unresolved":false,"context_lines":[{"line_number":246,"context_line":"                              \"allocation pool.\")"},{"line_number":247,"context_line":"                    count \u003d check_update_query.delete()"},{"line_number":248,"context_line":"                    if count \u003d\u003d 0:"},{"line_number":249,"context_line":"                        continue"},{"line_number":250,"context_line":"                else:"},{"line_number":251,"context_line":"                    # increment the first free"},{"line_number":252,"context_line":"                    new_first_ip \u003d str(netaddr.IPAddress(ip_address) + 1)"}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_5925d7ac","line":249,"in_reply_to":"fa98f980_50b4dad0","updated":"2014-09-18 14:20:16.000000000","message":"In the meanwhile I swapped the 2 cycles, that is now the same subnet is retried is case an error is got","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"87dea8f1391bdff91185318d8a51011f89d0cb49","unresolved":false,"context_lines":[{"line_number":246,"context_line":"                              \"allocation pool.\")"},{"line_number":247,"context_line":"                    count \u003d check_update_query.delete()"},{"line_number":248,"context_line":"                    if count \u003d\u003d 0:"},{"line_number":249,"context_line":"                        continue"},{"line_number":250,"context_line":"                else:"},{"line_number":251,"context_line":"                    # increment the first free"},{"line_number":252,"context_line":"                    new_first_ip \u003d str(netaddr.IPAddress(ip_address) + 1)"}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_50b4dad0","line":249,"in_reply_to":"fa98f980_a9612a13","updated":"2014-09-17 21:00:56.000000000","message":"Hmmm.  I\u0027m not sure that I agree.  This could be perceived as somewhat random, non-deterministic behavior.  I\u0027ll have to give this some thought.\n\nI was thinking of suggesting raising an exception here and catching and retrying.  I\u0027ll have to think about this some more.","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"1a717823cd4c3b906e7e428f6380bb79d9fd1cfa","unresolved":false,"context_lines":[{"line_number":246,"context_line":"                              \"allocation pool.\")"},{"line_number":247,"context_line":"                    count \u003d check_update_query.delete()"},{"line_number":248,"context_line":"                    if count \u003d\u003d 0:"},{"line_number":249,"context_line":"                        continue"},{"line_number":250,"context_line":"                else:"},{"line_number":251,"context_line":"                    # increment the first free"},{"line_number":252,"context_line":"                    new_first_ip \u003d str(netaddr.IPAddress(ip_address) + 1)"}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_a9612a13","line":249,"in_reply_to":"fa98f980_d5c1b882","updated":"2014-09-17 16:29:50.000000000","message":"That my intention. If you loop at patch set 5, I received a comment from Mark Mcclain to try another subnet before retrying the operation. I copy/paste his comment here for reference. \n\"I think I\u0027d rather try all subnets once before trying to repeat the action on a particular subnet.\"","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"9b5d2e53e71c5a51e60147e497e2d3a85653e18f","unresolved":false,"context_lines":[{"line_number":253,"context_line":"                    count \u003d check_update_query.update("},{"line_number":254,"context_line":"                        {\"first_ip\": new_first_ip})"},{"line_number":255,"context_line":"                    if count \u003d\u003d 0:"},{"line_number":256,"context_line":"                        continue"},{"line_number":257,"context_line":""},{"line_number":258,"context_line":"                LOG.debug(\"Allocated IP - %(ip_address)s from %(first_ip)s \""},{"line_number":259,"context_line":"                          \"to %(last_ip)s\","}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_953f3087","line":256,"updated":"2014-09-16 23:08:17.000000000","message":"See L256 comment.","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"1a717823cd4c3b906e7e428f6380bb79d9fd1cfa","unresolved":false,"context_lines":[{"line_number":253,"context_line":"                    count \u003d check_update_query.update("},{"line_number":254,"context_line":"                        {\"first_ip\": new_first_ip})"},{"line_number":255,"context_line":"                    if count \u003d\u003d 0:"},{"line_number":256,"context_line":"                        continue"},{"line_number":257,"context_line":""},{"line_number":258,"context_line":"                LOG.debug(\"Allocated IP - %(ip_address)s from %(first_ip)s \""},{"line_number":259,"context_line":"                          \"to %(last_ip)s\","}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_e96b32ef","line":256,"in_reply_to":"fa98f980_953f3087","updated":"2014-09-17 16:29:50.000000000","message":"ditto","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"5880da54c161b5aa95abb09cb88a86626b521fda","unresolved":false,"context_lines":[{"line_number":260,"context_line":"                          {\u0027ip_address\u0027: ip_address,"},{"line_number":261,"context_line":"                           \u0027first_ip\u0027: ip_range[\u0027first_ip\u0027],"},{"line_number":262,"context_line":"                           \u0027last_ip\u0027: ip_range[\u0027last_ip\u0027]})"},{"line_number":263,"context_line":"                NeutronDbPluginV2._store_ip_allocation("},{"line_number":264,"context_line":"                    context, ip_address, subnet[\u0027network_id\u0027],"},{"line_number":265,"context_line":"                    subnet[\u0027id\u0027], port_id)"},{"line_number":266,"context_line":"                return {\u0027ip_address\u0027: ip_address,"}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_cf920758","line":263,"updated":"2014-09-16 22:41:02.000000000","message":"Rather than plumb port_id all the way down to this method, you could move the call to _store_ip_allocation out of this method and to the caller.  As long as it gets in to the same transaction, then it is equivalent, right?\n\nI don\u0027t care much which way it is done, but moving it out of the caller could reduce the size and perceived complexity of this patch.   Maybe you could follow up this patch with a refactor to move it here that could land after Juno.","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"187fc8f3647cd99e5e5a3a7e418c15a4ee3c4214","unresolved":false,"context_lines":[{"line_number":260,"context_line":"                          {\u0027ip_address\u0027: ip_address,"},{"line_number":261,"context_line":"                           \u0027first_ip\u0027: ip_range[\u0027first_ip\u0027],"},{"line_number":262,"context_line":"                           \u0027last_ip\u0027: ip_range[\u0027last_ip\u0027]})"},{"line_number":263,"context_line":"                NeutronDbPluginV2._store_ip_allocation("},{"line_number":264,"context_line":"                    context, ip_address, subnet[\u0027network_id\u0027],"},{"line_number":265,"context_line":"                    subnet[\u0027id\u0027], port_id)"},{"line_number":266,"context_line":"                return {\u0027ip_address\u0027: ip_address,"}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_417b0ef4","line":263,"in_reply_to":"fa98f980_240abf27","updated":"2014-09-18 20:39:04.000000000","message":"I\u0027m okay with this.  Actually, where I suggested calling it is equivalent from the perspective of the transaction.  But, I agree it is ultimately better here.","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"1a717823cd4c3b906e7e428f6380bb79d9fd1cfa","unresolved":false,"context_lines":[{"line_number":260,"context_line":"                          {\u0027ip_address\u0027: ip_address,"},{"line_number":261,"context_line":"                           \u0027first_ip\u0027: ip_range[\u0027first_ip\u0027],"},{"line_number":262,"context_line":"                           \u0027last_ip\u0027: ip_range[\u0027last_ip\u0027]})"},{"line_number":263,"context_line":"                NeutronDbPluginV2._store_ip_allocation("},{"line_number":264,"context_line":"                    context, ip_address, subnet[\u0027network_id\u0027],"},{"line_number":265,"context_line":"                    subnet[\u0027id\u0027], port_id)"},{"line_number":266,"context_line":"                return {\u0027ip_address\u0027: ip_address,"}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_240abf27","line":263,"in_reply_to":"fa98f980_cf920758","updated":"2014-09-17 16:29:50.000000000","message":"This transaction is very long. I prefer storing the IPAllocation here, straight away. This means acquiring the lock for the IPAllocation table right after acquiring the one for IPAvailabilityRange.","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":6854,"name":"YAMAMOTO Takashi","email":"yamamoto@midokura.com","username":"yamamoto"},"change_message_id":"9faf1f47eb9c9cecdfc9e8851c7358a3f8a4ffcf","unresolved":false,"context_lines":[{"line_number":271,"context_line":"    def _rebuild_availability_ranges(context, subnets):"},{"line_number":272,"context_line":"        \"\"\"Rebuild availability ranges."},{"line_number":273,"context_line":""},{"line_number":274,"context_line":"        This methos is called only when there\u0027s no more IP available or by"},{"line_number":275,"context_line":"        _update_subnet_allocation_pools. Calling"},{"line_number":276,"context_line":"        _update_subnet_allocation_pools before calling this function deletes"},{"line_number":277,"context_line":"        the IPAllocationPools associated with the subnet that is updating,"}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_64f3b50a","line":274,"range":{"start_line":274,"start_character":13,"end_line":274,"end_character":19},"updated":"2014-09-10 05:32:21.000000000","message":"method","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"1a717823cd4c3b906e7e428f6380bb79d9fd1cfa","unresolved":false,"context_lines":[{"line_number":271,"context_line":"    def _rebuild_availability_ranges(context, subnets):"},{"line_number":272,"context_line":"        \"\"\"Rebuild availability ranges."},{"line_number":273,"context_line":""},{"line_number":274,"context_line":"        This methos is called only when there\u0027s no more IP available or by"},{"line_number":275,"context_line":"        _update_subnet_allocation_pools. Calling"},{"line_number":276,"context_line":"        _update_subnet_allocation_pools before calling this function deletes"},{"line_number":277,"context_line":"        the IPAllocationPools associated with the subnet that is updating,"}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_49727ee4","line":274,"in_reply_to":"fa98f980_64f3b50a","updated":"2014-09-17 16:29:50.000000000","message":"thanks!","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":6854,"name":"YAMAMOTO Takashi","email":"yamamoto@midokura.com","username":"yamamoto"},"change_message_id":"9faf1f47eb9c9cecdfc9e8851c7358a3f8a4ffcf","unresolved":false,"context_lines":[{"line_number":282,"context_line":"        \"\"\""},{"line_number":283,"context_line":"        ip_qry \u003d context.session.query(models_v2.IPAllocation)"},{"line_number":284,"context_line":"        # PostgreSQL does not support select...for update with an outer join."},{"line_number":285,"context_line":"        # No join is needed here."},{"line_number":286,"context_line":"        pool_qry \u003d context.session.query("},{"line_number":287,"context_line":"            models_v2.IPAllocationPool).options("},{"line_number":288,"context_line":"                orm.noload(\u0027available_ranges\u0027))"}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_e4bde503","line":285,"updated":"2014-09-10 05:32:21.000000000","message":"L.284-285 seem stale","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"1a717823cd4c3b906e7e428f6380bb79d9fd1cfa","unresolved":false,"context_lines":[{"line_number":282,"context_line":"        \"\"\""},{"line_number":283,"context_line":"        ip_qry \u003d context.session.query(models_v2.IPAllocation)"},{"line_number":284,"context_line":"        # PostgreSQL does not support select...for update with an outer join."},{"line_number":285,"context_line":"        # No join is needed here."},{"line_number":286,"context_line":"        pool_qry \u003d context.session.query("},{"line_number":287,"context_line":"            models_v2.IPAllocationPool).options("},{"line_number":288,"context_line":"                orm.noload(\u0027available_ranges\u0027))"}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_697f42ac","line":285,"in_reply_to":"fa98f980_daad6734","updated":"2014-09-17 16:29:50.000000000","message":"I will do that, thanks!","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"5880da54c161b5aa95abb09cb88a86626b521fda","unresolved":false,"context_lines":[{"line_number":282,"context_line":"        \"\"\""},{"line_number":283,"context_line":"        ip_qry \u003d context.session.query(models_v2.IPAllocation)"},{"line_number":284,"context_line":"        # PostgreSQL does not support select...for update with an outer join."},{"line_number":285,"context_line":"        # No join is needed here."},{"line_number":286,"context_line":"        pool_qry \u003d context.session.query("},{"line_number":287,"context_line":"            models_v2.IPAllocationPool).options("},{"line_number":288,"context_line":"                orm.noload(\u0027available_ranges\u0027))"}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_daad6734","line":285,"in_reply_to":"fa98f980_e4bde503","updated":"2014-09-16 22:41:02.000000000","message":"+1 This should be removed because this patch obsoletes this comment.","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":6854,"name":"YAMAMOTO Takashi","email":"yamamoto@midokura.com","username":"yamamoto"},"change_message_id":"9faf1f47eb9c9cecdfc9e8851c7358a3f8a4ffcf","unresolved":false,"context_lines":[{"line_number":322,"context_line":"                            first_ip\u003dstr(netaddr.IPAddress(ip_range.first)),"},{"line_number":323,"context_line":"                            last_ip\u003dstr(netaddr.IPAddress(ip_range.last)))"},{"line_number":324,"context_line":"                        context.session.add(available_range)"},{"line_number":325,"context_line":"                except db_exc.DBDuplicateEntry:"},{"line_number":326,"context_line":"                    LOG.info(_LI(\"A concurrent _rebuild_availability_ranges\""},{"line_number":327,"context_line":"                             \" had already added this range\"))"},{"line_number":328,"context_line":""}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_a4d03df8","line":325,"updated":"2014-09-10 05:32:21.000000000","message":"this would not catch overlapping but not identical ranges.\ncan\u0027t it be a problem?","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"139acc3d96b4e29b2d1aafb3213007716d11d42b","unresolved":false,"context_lines":[{"line_number":322,"context_line":"                            first_ip\u003dstr(netaddr.IPAddress(ip_range.first)),"},{"line_number":323,"context_line":"                            last_ip\u003dstr(netaddr.IPAddress(ip_range.last)))"},{"line_number":324,"context_line":"                        context.session.add(available_range)"},{"line_number":325,"context_line":"                except db_exc.DBDuplicateEntry:"},{"line_number":326,"context_line":"                    LOG.info(_LI(\"A concurrent _rebuild_availability_ranges\""},{"line_number":327,"context_line":"                             \" had already added this range\"))"},{"line_number":328,"context_line":""}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_b9596337","line":325,"in_reply_to":"fa98f980_10bed2d4","updated":"2014-09-18 14:20:16.000000000","message":"They won\u0027t write the same data, that\u0027s the corner case I was mentioning in my previous comment. Maybe I was not clear enough.\nI thought about a solution, the best for me is to add two unique constraint for IPAvailabilityRange table, to make sure that the tuples (allocation_pool_id, first_ip) and (allocation_pool_id, last_ip) are unique. These constraints make sense for me generally. Here they would help a lot. Let me explain.If another process has rebuilt the ip availability ranges and has assigned an IP already then the current process would try to insert a range with a tuple (allocation_pool_id, last_ip) that is already present in the DB, that would throw a duplicate key exception.\nAny better idea?","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"1a717823cd4c3b906e7e428f6380bb79d9fd1cfa","unresolved":false,"context_lines":[{"line_number":322,"context_line":"                            first_ip\u003dstr(netaddr.IPAddress(ip_range.first)),"},{"line_number":323,"context_line":"                            last_ip\u003dstr(netaddr.IPAddress(ip_range.last)))"},{"line_number":324,"context_line":"                        context.session.add(available_range)"},{"line_number":325,"context_line":"                except db_exc.DBDuplicateEntry:"},{"line_number":326,"context_line":"                    LOG.info(_LI(\"A concurrent _rebuild_availability_ranges\""},{"line_number":327,"context_line":"                             \" had already added this range\"))"},{"line_number":328,"context_line":""}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_e4a99791","line":325,"in_reply_to":"fa98f980_35ecc4f3","updated":"2014-09-17 16:29:50.000000000","message":"That\u0027s a good point. Let me explain my reasoning. This method is called only when there\u0027s no IPAvailabilityRange available, so the DB has no IPAvailabilityRange associated with this allocation pool. It can happen that two processes run _rebuild_availability_ranges at the same time. In that case that will have the same result, they will try to write the same data in the DB, db_exc.DBDuplicateEntry is enough here. Anyway there\u0027s a corner case. It might happen that the first process run this method and then successfully allocates an IP. In this case the second process that run this method would insert stale data. I will take care of that. Thanks!","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"5880da54c161b5aa95abb09cb88a86626b521fda","unresolved":false,"context_lines":[{"line_number":322,"context_line":"                            first_ip\u003dstr(netaddr.IPAddress(ip_range.first)),"},{"line_number":323,"context_line":"                            last_ip\u003dstr(netaddr.IPAddress(ip_range.last)))"},{"line_number":324,"context_line":"                        context.session.add(available_range)"},{"line_number":325,"context_line":"                except db_exc.DBDuplicateEntry:"},{"line_number":326,"context_line":"                    LOG.info(_LI(\"A concurrent _rebuild_availability_ranges\""},{"line_number":327,"context_line":"                             \" had already added this range\"))"},{"line_number":328,"context_line":""}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_f4a962de","line":325,"in_reply_to":"fa98f980_a4d03df8","updated":"2014-09-16 22:41:02.000000000","message":"Yamamoto.  You make a good point.  Let me think about this.","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"187fc8f3647cd99e5e5a3a7e418c15a4ee3c4214","unresolved":false,"context_lines":[{"line_number":322,"context_line":"                            first_ip\u003dstr(netaddr.IPAddress(ip_range.first)),"},{"line_number":323,"context_line":"                            last_ip\u003dstr(netaddr.IPAddress(ip_range.last)))"},{"line_number":324,"context_line":"                        context.session.add(available_range)"},{"line_number":325,"context_line":"                except db_exc.DBDuplicateEntry:"},{"line_number":326,"context_line":"                    LOG.info(_LI(\"A concurrent _rebuild_availability_ranges\""},{"line_number":327,"context_line":"                             \" had already added this range\"))"},{"line_number":328,"context_line":""}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_215fea76","line":325,"in_reply_to":"fa98f980_b9596337","updated":"2014-09-18 20:39:04.000000000","message":"I don\u0027t have a better idea yet.  I will give this some more thought.","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"87dea8f1391bdff91185318d8a51011f89d0cb49","unresolved":false,"context_lines":[{"line_number":322,"context_line":"                            first_ip\u003dstr(netaddr.IPAddress(ip_range.first)),"},{"line_number":323,"context_line":"                            last_ip\u003dstr(netaddr.IPAddress(ip_range.last)))"},{"line_number":324,"context_line":"                        context.session.add(available_range)"},{"line_number":325,"context_line":"                except db_exc.DBDuplicateEntry:"},{"line_number":326,"context_line":"                    LOG.info(_LI(\"A concurrent _rebuild_availability_ranges\""},{"line_number":327,"context_line":"                             \" had already added this range\"))"},{"line_number":328,"context_line":""}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_10bed2d4","line":325,"in_reply_to":"fa98f980_e4a99791","updated":"2014-09-17 21:00:56.000000000","message":"I\u0027m not yet convinced that they will try to write the same data in to the DB.  I will think about this some more.  Say another process finishes rebuilding and allocates a new IP address before a new process gets around to computing the new ranges as part of the rebuild.  It may be inserting a different range.  If there happens to be only one range, then there may be no collision here.","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"9b5d2e53e71c5a51e60147e497e2d3a85653e18f","unresolved":false,"context_lines":[{"line_number":322,"context_line":"                            first_ip\u003dstr(netaddr.IPAddress(ip_range.first)),"},{"line_number":323,"context_line":"                            last_ip\u003dstr(netaddr.IPAddress(ip_range.last)))"},{"line_number":324,"context_line":"                        context.session.add(available_range)"},{"line_number":325,"context_line":"                except db_exc.DBDuplicateEntry:"},{"line_number":326,"context_line":"                    LOG.info(_LI(\"A concurrent _rebuild_availability_ranges\""},{"line_number":327,"context_line":"                             \" had already added this range\"))"},{"line_number":328,"context_line":""}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_35ecc4f3","line":325,"in_reply_to":"fa98f980_f4a962de","updated":"2014-09-16 23:08:17.000000000","message":"I think this is something to understand.  I haven\u0027t wrapped my head around it yet.","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":1653,"name":"garyk","email":"gkotton@vmware.com","username":"garyk"},"change_message_id":"91972ed502b3647027ecf1c0aa3e590791088fe9","unresolved":false,"context_lines":[{"line_number":324,"context_line":"                        context.session.add(available_range)"},{"line_number":325,"context_line":"                except db_exc.DBDuplicateEntry:"},{"line_number":326,"context_line":"                    LOG.info(_LI(\"A concurrent _rebuild_availability_ranges\""},{"line_number":327,"context_line":"                             \" had already added this range\"))"},{"line_number":328,"context_line":""},{"line_number":329,"context_line":"    @staticmethod"},{"line_number":330,"context_line":"    def _allocate_specific_ip(context, subnet_id, ip_address, network_id,"}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_c7b399e7","line":327,"updated":"2014-09-09 14:13:58.000000000","message":"identation","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"9b5d2e53e71c5a51e60147e497e2d3a85653e18f","unresolved":false,"context_lines":[{"line_number":350,"context_line":"                    if first \u003d\u003d last:"},{"line_number":351,"context_line":"                        count \u003d check_update_query.delete()"},{"line_number":352,"context_line":"                        if count \u003d\u003d 0:"},{"line_number":353,"context_line":"                            continue"},{"line_number":354,"context_line":"                    elif first \u003d\u003d ip:"},{"line_number":355,"context_line":"                        new_first_ip \u003d str(netaddr.IPAddress(ip_address) + 1)"},{"line_number":356,"context_line":"                        count \u003d (check_update_query.update("}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_950d70eb","line":353,"updated":"2014-09-16 23:08:17.000000000","message":"Similar concern as L249.  I think we may be continuing the wrong loop.","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"1a717823cd4c3b906e7e428f6380bb79d9fd1cfa","unresolved":false,"context_lines":[{"line_number":350,"context_line":"                    if first \u003d\u003d last:"},{"line_number":351,"context_line":"                        count \u003d check_update_query.delete()"},{"line_number":352,"context_line":"                        if count \u003d\u003d 0:"},{"line_number":353,"context_line":"                            continue"},{"line_number":354,"context_line":"                    elif first \u003d\u003d ip:"},{"line_number":355,"context_line":"                        new_first_ip \u003d str(netaddr.IPAddress(ip_address) + 1)"},{"line_number":356,"context_line":"                        count \u003d (check_update_query.update("}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_a486af14","line":353,"in_reply_to":"fa98f980_950d70eb","updated":"2014-09-17 16:29:50.000000000","message":"ditto","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"9b5d2e53e71c5a51e60147e497e2d3a85653e18f","unresolved":false,"context_lines":[{"line_number":356,"context_line":"                        count \u003d (check_update_query.update("},{"line_number":357,"context_line":"                            {\"first_ip\": new_first_ip}))"},{"line_number":358,"context_line":"                        if count \u003d\u003d 0:"},{"line_number":359,"context_line":"                            continue"},{"line_number":360,"context_line":"                    elif last \u003d\u003d ip:"},{"line_number":361,"context_line":"                        new_last_ip \u003d str(netaddr.IPAddress(ip_address) - 1)"},{"line_number":362,"context_line":"                        count \u003d (check_update_query.update("}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_b5127407","line":359,"updated":"2014-09-16 23:08:17.000000000","message":"ditto","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"9b5d2e53e71c5a51e60147e497e2d3a85653e18f","unresolved":false,"context_lines":[{"line_number":362,"context_line":"                        count \u003d (check_update_query.update("},{"line_number":363,"context_line":"                            {\"last_ip\": new_last_ip}))"},{"line_number":364,"context_line":"                        if count \u003d\u003d 0:"},{"line_number":365,"context_line":"                            continue"},{"line_number":366,"context_line":"                    else:"},{"line_number":367,"context_line":"                        # Split into two ranges"},{"line_number":368,"context_line":"                        new_first \u003d str(netaddr.IPAddress(ip_address) + 1)"}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_f5f31ce5","line":365,"updated":"2014-09-16 23:08:17.000000000","message":"ditto","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"5880da54c161b5aa95abb09cb88a86626b521fda","unresolved":false,"context_lines":[{"line_number":369,"context_line":"                        new_last \u003d ip_range[\u0027last_ip\u0027]"},{"line_number":370,"context_line":"                        count \u003d (check_update_query.update("},{"line_number":371,"context_line":"                            {\"last_ip\": str(netaddr.IPAddress("},{"line_number":372,"context_line":"                                ip_address) - 1)}))"},{"line_number":373,"context_line":"                        if count \u003d\u003d 0:"},{"line_number":374,"context_line":"                            continue"},{"line_number":375,"context_line":"                        new_ip_range \u003d models_v2.IPAvailabilityRange("}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_d46ffe91","line":372,"updated":"2014-09-16 22:41:02.000000000","message":"Could you keep \"new_last_ip\" here?  Not inline it.  It is more consistent with the rest of the code.","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"1a717823cd4c3b906e7e428f6380bb79d9fd1cfa","unresolved":false,"context_lines":[{"line_number":369,"context_line":"                        new_last \u003d ip_range[\u0027last_ip\u0027]"},{"line_number":370,"context_line":"                        count \u003d (check_update_query.update("},{"line_number":371,"context_line":"                            {\"last_ip\": str(netaddr.IPAddress("},{"line_number":372,"context_line":"                                ip_address) - 1)}))"},{"line_number":373,"context_line":"                        if count \u003d\u003d 0:"},{"line_number":374,"context_line":"                            continue"},{"line_number":375,"context_line":"                        new_ip_range \u003d models_v2.IPAvailabilityRange("}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_4477c33b","line":372,"in_reply_to":"fa98f980_d46ffe91","updated":"2014-09-17 16:29:50.000000000","message":"ok","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"9b5d2e53e71c5a51e60147e497e2d3a85653e18f","unresolved":false,"context_lines":[{"line_number":371,"context_line":"                            {\"last_ip\": str(netaddr.IPAddress("},{"line_number":372,"context_line":"                                ip_address) - 1)}))"},{"line_number":373,"context_line":"                        if count \u003d\u003d 0:"},{"line_number":374,"context_line":"                            continue"},{"line_number":375,"context_line":"                        new_ip_range \u003d models_v2.IPAvailabilityRange("},{"line_number":376,"context_line":"                            allocation_pool_id\u003dip_range["},{"line_number":377,"context_line":"                                \u0027allocation_pool_id\u0027],"}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_552a2830","line":374,"updated":"2014-09-16 23:08:17.000000000","message":"ditto for continue","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"5880da54c161b5aa95abb09cb88a86626b521fda","unresolved":false,"context_lines":[{"line_number":379,"context_line":"                            last_ip\u003dnew_last)"},{"line_number":380,"context_line":"                        context.session.add(new_ip_range)"},{"line_number":381,"context_line":""},{"line_number":382,"context_line":"                NeutronDbPluginV2._store_ip_allocation("},{"line_number":383,"context_line":"                    context, ip_address, network_id,"},{"line_number":384,"context_line":"                    subnet_id, port_id)"},{"line_number":385,"context_line":"                return"}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_af0f8387","line":382,"updated":"2014-09-16 22:41:02.000000000","message":"See comment L263","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"5880da54c161b5aa95abb09cb88a86626b521fda","unresolved":false,"context_lines":[{"line_number":566,"context_line":"                                           port_id)"},{"line_number":567,"context_line":"        return ips, prev_ips"},{"line_number":568,"context_line":""},{"line_number":569,"context_line":"    def _allocate_ips_for_port(self, context, port, port_id):"},{"line_number":570,"context_line":"        \"\"\"Allocate IP addresses for the port."},{"line_number":571,"context_line":""},{"line_number":572,"context_line":"        If port[\u0027fixed_ips\u0027] is set to \u0027ATTR_NOT_SPECIFIED\u0027, allocate IP"}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_8ffc7f74","line":569,"updated":"2014-09-16 22:41:02.000000000","message":"Note: port_id is not necessarily available as p[\u0027id\u0027] here.","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"5880da54c161b5aa95abb09cb88a86626b521fda","unresolved":false,"context_lines":[{"line_number":947,"context_line":"                subnet[\u0027shared\u0027] \u003d network[\u0027shared\u0027]"},{"line_number":948,"context_line":"        return self._make_network_dict(network)"},{"line_number":949,"context_line":""},{"line_number":950,"context_line":"    def delete_network(self, context, id):"},{"line_number":951,"context_line":"        with context.session.begin(subtransactions\u003dTrue):"},{"line_number":952,"context_line":"            network \u003d self._get_network(context, id)"},{"line_number":953,"context_line":""}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_29747335","line":950,"updated":"2014-09-16 22:41:02.000000000","message":"Could the delete_network and delete_subnet changes be broken out in to a different patch?  Am I correct in thinking that this is an independent theme?","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"1a717823cd4c3b906e7e428f6380bb79d9fd1cfa","unresolved":false,"context_lines":[{"line_number":947,"context_line":"                subnet[\u0027shared\u0027] \u003d network[\u0027shared\u0027]"},{"line_number":948,"context_line":"        return self._make_network_dict(network)"},{"line_number":949,"context_line":""},{"line_number":950,"context_line":"    def delete_network(self, context, id):"},{"line_number":951,"context_line":"        with context.session.begin(subtransactions\u003dTrue):"},{"line_number":952,"context_line":"            network \u003d self._get_network(context, id)"},{"line_number":953,"context_line":""}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_84bfeba9","line":950,"in_reply_to":"fa98f980_29747335","updated":"2014-09-17 16:29:50.000000000","message":"yes I can create 2 patches","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"5880da54c161b5aa95abb09cb88a86626b521fda","unresolved":false,"context_lines":[{"line_number":953,"context_line":""},{"line_number":954,"context_line":"            context.session.query(models_v2.Port).filter_by("},{"line_number":955,"context_line":"                network_id\u003did,"},{"line_number":956,"context_line":"                device_owner\u003dconstants.DEVICE_OWNER_DHCP).delete()"},{"line_number":957,"context_line":"            ports_in_use \u003d context.session.query(models_v2.Port).filter_by("},{"line_number":958,"context_line":"                network_id\u003did).all()"},{"line_number":959,"context_line":""}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_34edaab8","line":956,"updated":"2014-09-16 22:41:02.000000000","message":"Can we still use an \"in\" operator here and not abandon the AUTO_DELETE_PORT_OWNERS constant?","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"1a717823cd4c3b906e7e428f6380bb79d9fd1cfa","unresolved":false,"context_lines":[{"line_number":953,"context_line":""},{"line_number":954,"context_line":"            context.session.query(models_v2.Port).filter_by("},{"line_number":955,"context_line":"                network_id\u003did,"},{"line_number":956,"context_line":"                device_owner\u003dconstants.DEVICE_OWNER_DHCP).delete()"},{"line_number":957,"context_line":"            ports_in_use \u003d context.session.query(models_v2.Port).filter_by("},{"line_number":958,"context_line":"                network_id\u003did).all()"},{"line_number":959,"context_line":""}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_c4e013cf","line":956,"in_reply_to":"fa98f980_34edaab8","updated":"2014-09-17 16:29:50.000000000","message":"yes :)","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"5880da54c161b5aa95abb09cb88a86626b521fda","unresolved":false,"context_lines":[{"line_number":1279,"context_line":"                             join(models_v2.Port)."},{"line_number":1280,"context_line":"                             filter_by(network_id\u003dsubnet[\u0027network_id\u0027])."},{"line_number":1281,"context_line":"                             filter_by("},{"line_number":1282,"context_line":"                                 device_owner\u003dconstants.DEVICE_OWNER_DHCP)."},{"line_number":1283,"context_line":"                             all())"},{"line_number":1284,"context_line":"            if network_ports:"},{"line_number":1285,"context_line":"                map(context.session.delete, network_ports)"}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_94fc9674","line":1282,"updated":"2014-09-16 22:41:02.000000000","message":"See comment L956","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"1a717823cd4c3b906e7e428f6380bb79d9fd1cfa","unresolved":false,"context_lines":[{"line_number":1279,"context_line":"                             join(models_v2.Port)."},{"line_number":1280,"context_line":"                             filter_by(network_id\u003dsubnet[\u0027network_id\u0027])."},{"line_number":1281,"context_line":"                             filter_by("},{"line_number":1282,"context_line":"                                 device_owner\u003dconstants.DEVICE_OWNER_DHCP)."},{"line_number":1283,"context_line":"                             all())"},{"line_number":1284,"context_line":"            if network_ports:"},{"line_number":1285,"context_line":"                map(context.session.delete, network_ports)"}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_84d60bf0","line":1282,"in_reply_to":"fa98f980_94fc9674","updated":"2014-09-17 16:29:50.000000000","message":"ok","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"5880da54c161b5aa95abb09cb88a86626b521fda","unresolved":false,"context_lines":[{"line_number":1280,"context_line":"                             filter_by(network_id\u003dsubnet[\u0027network_id\u0027])."},{"line_number":1281,"context_line":"                             filter_by("},{"line_number":1282,"context_line":"                                 device_owner\u003dconstants.DEVICE_OWNER_DHCP)."},{"line_number":1283,"context_line":"                             all())"},{"line_number":1284,"context_line":"            if network_ports:"},{"line_number":1285,"context_line":"                map(context.session.delete, network_ports)"},{"line_number":1286,"context_line":"            # Check if there are tenant owned ports"}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_8f6c7fd2","line":1283,"updated":"2014-09-16 22:41:02.000000000","message":"Could you just call delete instead of the next two lines?","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"187fc8f3647cd99e5e5a3a7e418c15a4ee3c4214","unresolved":false,"context_lines":[{"line_number":1280,"context_line":"                             filter_by(network_id\u003dsubnet[\u0027network_id\u0027])."},{"line_number":1281,"context_line":"                             filter_by("},{"line_number":1282,"context_line":"                                 device_owner\u003dconstants.DEVICE_OWNER_DHCP)."},{"line_number":1283,"context_line":"                             all())"},{"line_number":1284,"context_line":"            if network_ports:"},{"line_number":1285,"context_line":"                map(context.session.delete, network_ports)"},{"line_number":1286,"context_line":"            # Check if there are tenant owned ports"}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_6159f28d","line":1283,"in_reply_to":"fa98f980_07fcc13e","updated":"2014-09-18 20:39:04.000000000","message":"Fair enough.","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"a76897293d3197318de3c8703ec52d08dfecd230","unresolved":false,"context_lines":[{"line_number":1280,"context_line":"                             filter_by(network_id\u003dsubnet[\u0027network_id\u0027])."},{"line_number":1281,"context_line":"                             filter_by("},{"line_number":1282,"context_line":"                                 device_owner\u003dconstants.DEVICE_OWNER_DHCP)."},{"line_number":1283,"context_line":"                             all())"},{"line_number":1284,"context_line":"            if network_ports:"},{"line_number":1285,"context_line":"                map(context.session.delete, network_ports)"},{"line_number":1286,"context_line":"            # Check if there are tenant owned ports"}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_07fcc13e","line":1283,"in_reply_to":"fa98f980_84ed2bba","updated":"2014-09-18 15:16:22.000000000","message":"Reading my comment again...it doesn\u0027t make any sense. Anyway in this case delete() is not working, I think it\u0027s because of the join","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"1a717823cd4c3b906e7e428f6380bb79d9fd1cfa","unresolved":false,"context_lines":[{"line_number":1280,"context_line":"                             filter_by(network_id\u003dsubnet[\u0027network_id\u0027])."},{"line_number":1281,"context_line":"                             filter_by("},{"line_number":1282,"context_line":"                                 device_owner\u003dconstants.DEVICE_OWNER_DHCP)."},{"line_number":1283,"context_line":"                             all())"},{"line_number":1284,"context_line":"            if network_ports:"},{"line_number":1285,"context_line":"                map(context.session.delete, network_ports)"},{"line_number":1286,"context_line":"            # Check if there are tenant owned ports"}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_84ed2bba","line":1283,"in_reply_to":"fa98f980_8f6c7fd2","updated":"2014-09-17 16:29:50.000000000","message":"no I can\u0027t. delete() doesn\u0027t work with collections","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"5880da54c161b5aa95abb09cb88a86626b521fda","unresolved":false,"context_lines":[{"line_number":1281,"context_line":"                             filter_by("},{"line_number":1282,"context_line":"                                 device_owner\u003dconstants.DEVICE_OWNER_DHCP)."},{"line_number":1283,"context_line":"                             all())"},{"line_number":1284,"context_line":"            if network_ports:"},{"line_number":1285,"context_line":"                map(context.session.delete, network_ports)"},{"line_number":1286,"context_line":"            # Check if there are tenant owned ports"},{"line_number":1287,"context_line":"            tenant_ports \u003d (context.session.query(models_v2.IPAllocation)."}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_ef342be1","line":1284,"updated":"2014-09-16 22:41:02.000000000","message":"Why not just a regular old for loop?  I don\u0027t see an advantage of using map.  It feels a bit too clever.","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"187fc8f3647cd99e5e5a3a7e418c15a4ee3c4214","unresolved":false,"context_lines":[{"line_number":1281,"context_line":"                             filter_by("},{"line_number":1282,"context_line":"                                 device_owner\u003dconstants.DEVICE_OWNER_DHCP)."},{"line_number":1283,"context_line":"                             all())"},{"line_number":1284,"context_line":"            if network_ports:"},{"line_number":1285,"context_line":"                map(context.session.delete, network_ports)"},{"line_number":1286,"context_line":"            # Check if there are tenant owned ports"},{"line_number":1287,"context_line":"            tenant_ports \u003d (context.session.query(models_v2.IPAllocation)."}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_014826b2","line":1284,"in_reply_to":"fa98f980_e4335760","updated":"2014-09-18 20:39:04.000000000","message":"I don\u0027t think it achieves that.  I think that map is just implemented in python with a loop.","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"1a717823cd4c3b906e7e428f6380bb79d9fd1cfa","unresolved":false,"context_lines":[{"line_number":1281,"context_line":"                             filter_by("},{"line_number":1282,"context_line":"                                 device_owner\u003dconstants.DEVICE_OWNER_DHCP)."},{"line_number":1283,"context_line":"                             all())"},{"line_number":1284,"context_line":"            if network_ports:"},{"line_number":1285,"context_line":"                map(context.session.delete, network_ports)"},{"line_number":1286,"context_line":"            # Check if there are tenant owned ports"},{"line_number":1287,"context_line":"            tenant_ports \u003d (context.session.query(models_v2.IPAllocation)."}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_e4335760","line":1284,"in_reply_to":"fa98f980_ef342be1","updated":"2014-09-17 16:29:50.000000000","message":"The idea is to do all the deletion in one shot. I am not a super expert but that\u0027s what I expect from map","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"5880da54c161b5aa95abb09cb88a86626b521fda","unresolved":false,"context_lines":[{"line_number":1283,"context_line":"                             all())"},{"line_number":1284,"context_line":"            if network_ports:"},{"line_number":1285,"context_line":"                map(context.session.delete, network_ports)"},{"line_number":1286,"context_line":"            # Check if there are tenant owned ports"},{"line_number":1287,"context_line":"            tenant_ports \u003d (context.session.query(models_v2.IPAllocation)."},{"line_number":1288,"context_line":"                            filter_by(subnet_id\u003dsubnet[\u0027id\u0027])."},{"line_number":1289,"context_line":"                            join(models_v2.Port)."}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_4f80d749","line":1286,"updated":"2014-09-16 22:41:02.000000000","message":"This could be moved before L1276 to fail faster.","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"187fc8f3647cd99e5e5a3a7e418c15a4ee3c4214","unresolved":false,"context_lines":[{"line_number":1283,"context_line":"                             all())"},{"line_number":1284,"context_line":"            if network_ports:"},{"line_number":1285,"context_line":"                map(context.session.delete, network_ports)"},{"line_number":1286,"context_line":"            # Check if there are tenant owned ports"},{"line_number":1287,"context_line":"            tenant_ports \u003d (context.session.query(models_v2.IPAllocation)."},{"line_number":1288,"context_line":"                            filter_by(subnet_id\u003dsubnet[\u0027id\u0027])."},{"line_number":1289,"context_line":"                            join(models_v2.Port)."}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_a1d91af6","line":1286,"in_reply_to":"fa98f980_246b9f20","updated":"2014-09-18 20:39:04.000000000","message":"I did miss that.  You\u0027re right.","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"1a717823cd4c3b906e7e428f6380bb79d9fd1cfa","unresolved":false,"context_lines":[{"line_number":1283,"context_line":"                             all())"},{"line_number":1284,"context_line":"            if network_ports:"},{"line_number":1285,"context_line":"                map(context.session.delete, network_ports)"},{"line_number":1286,"context_line":"            # Check if there are tenant owned ports"},{"line_number":1287,"context_line":"            tenant_ports \u003d (context.session.query(models_v2.IPAllocation)."},{"line_number":1288,"context_line":"                            filter_by(subnet_id\u003dsubnet[\u0027id\u0027])."},{"line_number":1289,"context_line":"                            join(models_v2.Port)."}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_246b9f20","line":1286,"in_reply_to":"fa98f980_4f80d749","updated":"2014-09-17 16:29:50.000000000","message":"Not really, this need to happen after the deletion of all auto-deletable ports. There\u0027s no filtering here based on the owner so if I place it at L1276 will get also auto-deletable ports","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"ba29e18183dba81b5ef3e236d2dbf7aa6be08571","unresolved":false,"context_lines":[{"line_number":223,"context_line":"            models_v2.IPAllocationPool)"},{"line_number":224,"context_line":""},{"line_number":225,"context_line":"        for subnet in subnets:"},{"line_number":226,"context_line":"            for _ in range(constants.DB_MAX_RETRIES):"},{"line_number":227,"context_line":"                ip_range \u003d range_qry.filter_by(subnet_id\u003dsubnet[\u0027id\u0027]).first()"},{"line_number":228,"context_line":"                if not ip_range:"},{"line_number":229,"context_line":"                    LOG.debug(\"All IPs from subnet %(subnet_id)s (%(cidr)s) \""}],"source_content_type":"text/x-python","patch_set":19,"id":"fa98f980_7ead139b","line":226,"updated":"2014-09-18 20:33:06.000000000","message":"I see that this patch goes back to retrying 10 times for each subnet.  I might be okay with that but it does feel a little funny.  I\u0027m wondering if we should move the retry loop back out to the outer loop and raise an exception from this code (everywhere you find a continue below) to signal that a retry is needed.\n\nAt that point, making this a decorator as Gary suggested previously might be worth it to avoid extra indentation and having too much code in a try/catch.\n\nAdvantages:\n\nTo me, \"raise RetryIPAllocation()\" says a lot more to me than \"continue\" in the code below.","commit_id":"e4968d82eca39293f7ee8fd511c4bf5a9c50e660"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"ba29e18183dba81b5ef3e236d2dbf7aa6be08571","unresolved":false,"context_lines":[{"line_number":230,"context_line":"                              \"allocated\","},{"line_number":231,"context_line":"                              {\u0027subnet_id\u0027: subnet[\u0027id\u0027],"},{"line_number":232,"context_line":"                               \u0027cidr\u0027: subnet[\u0027cidr\u0027]})"},{"line_number":233,"context_line":"                    break"},{"line_number":234,"context_line":"                # Update the database record only if the existing record"},{"line_number":235,"context_line":"                # matches exactly what it\u0027s expected, that is only if no other"},{"line_number":236,"context_line":"                # process has modified the same record"}],"source_content_type":"text/x-python","patch_set":19,"id":"fa98f980_a13f5ab4","line":233,"updated":"2014-09-18 20:33:06.000000000","message":"With comment on L226 this would change back to continue.","commit_id":"e4968d82eca39293f7ee8fd511c4bf5a9c50e660"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"ba29e18183dba81b5ef3e236d2dbf7aa6be08571","unresolved":false,"context_lines":[{"line_number":347,"context_line":"                    if first \u003d\u003d last:"},{"line_number":348,"context_line":"                        count \u003d check_update_query.delete()"},{"line_number":349,"context_line":"                        if count \u003d\u003d 0:"},{"line_number":350,"context_line":"                            continue"},{"line_number":351,"context_line":"                    elif first \u003d\u003d ip:"},{"line_number":352,"context_line":"                        new_first_ip \u003d str(netaddr.IPAddress(ip_address) + 1)"},{"line_number":353,"context_line":"                        count \u003d (check_update_query.update("}],"source_content_type":"text/x-python","patch_set":19,"id":"fa98f980_e13242f1","line":350,"updated":"2014-09-18 20:33:06.000000000","message":"I think these continues are still hitting the wrong loop.  They should be hitting the outer loop.  See comment L226.","commit_id":"e4968d82eca39293f7ee8fd511c4bf5a9c50e660"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"ba29e18183dba81b5ef3e236d2dbf7aa6be08571","unresolved":false,"context_lines":[{"line_number":354,"context_line":"                            {\"first_ip\": new_first_ip}))"},{"line_number":355,"context_line":"                        if count \u003d\u003d 0:"},{"line_number":356,"context_line":"                            continue"},{"line_number":357,"context_line":"                    elif last \u003d\u003d ip:"},{"line_number":358,"context_line":"                        new_last_ip \u003d str(netaddr.IPAddress(ip_address) - 1)"},{"line_number":359,"context_line":"                        count \u003d (check_update_query.update("},{"line_number":360,"context_line":"                            {\"last_ip\": new_last_ip}))"}],"source_content_type":"text/x-python","patch_set":19,"id":"fa98f980_e1f08293","line":357,"updated":"2014-09-18 20:33:06.000000000","message":"ditto","commit_id":"e4968d82eca39293f7ee8fd511c4bf5a9c50e660"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"ba29e18183dba81b5ef3e236d2dbf7aa6be08571","unresolved":false,"context_lines":[{"line_number":359,"context_line":"                        count \u003d (check_update_query.update("},{"line_number":360,"context_line":"                            {\"last_ip\": new_last_ip}))"},{"line_number":361,"context_line":"                        if count \u003d\u003d 0:"},{"line_number":362,"context_line":"                            continue"},{"line_number":363,"context_line":"                    else:"},{"line_number":364,"context_line":"                        # Split into two ranges"},{"line_number":365,"context_line":"                        new_first \u003d str(netaddr.IPAddress(ip_address) + 1)"}],"source_content_type":"text/x-python","patch_set":19,"id":"fa98f980_01eca6ba","line":362,"updated":"2014-09-18 20:33:06.000000000","message":"ditto","commit_id":"e4968d82eca39293f7ee8fd511c4bf5a9c50e660"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"ba29e18183dba81b5ef3e236d2dbf7aa6be08571","unresolved":false,"context_lines":[{"line_number":365,"context_line":"                        new_first \u003d str(netaddr.IPAddress(ip_address) + 1)"},{"line_number":366,"context_line":"                        new_last \u003d ip_range[\u0027last_ip\u0027]"},{"line_number":367,"context_line":"                        count \u003d (check_update_query.update("},{"line_number":368,"context_line":"                            {\"last_ip\": str(netaddr.IPAddress("},{"line_number":369,"context_line":"                                ip_address) - 1)}))"},{"line_number":370,"context_line":"                        if count \u003d\u003d 0:"},{"line_number":371,"context_line":"                            continue"}],"source_content_type":"text/x-python","patch_set":19,"id":"fa98f980_7e28b333","line":368,"updated":"2014-09-18 20:33:06.000000000","message":"nit:  Could you leave new_last_ip here rather than inlining it.  It is more consistent with similar code in this patch which is moving toward adding a temporary.","commit_id":"e4968d82eca39293f7ee8fd511c4bf5a9c50e660"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"ba29e18183dba81b5ef3e236d2dbf7aa6be08571","unresolved":false,"context_lines":[{"line_number":368,"context_line":"                            {\"last_ip\": str(netaddr.IPAddress("},{"line_number":369,"context_line":"                                ip_address) - 1)}))"},{"line_number":370,"context_line":"                        if count \u003d\u003d 0:"},{"line_number":371,"context_line":"                            continue"},{"line_number":372,"context_line":"                        new_ip_range \u003d models_v2.IPAvailabilityRange("},{"line_number":373,"context_line":"                            allocation_pool_id\u003dip_range["},{"line_number":374,"context_line":"                                \u0027allocation_pool_id\u0027],"}],"source_content_type":"text/x-python","patch_set":19,"id":"fa98f980_8137b64c","line":371,"updated":"2014-09-18 20:33:06.000000000","message":"ditto (L362)","commit_id":"e4968d82eca39293f7ee8fd511c4bf5a9c50e660"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"c2f8445eef750e8dccd8c5b7d19311a26167c3bb","unresolved":false,"context_lines":[{"line_number":223,"context_line":"            models_v2.IPAllocationPool)"},{"line_number":224,"context_line":""},{"line_number":225,"context_line":"        for subnet in subnets:"},{"line_number":226,"context_line":"            for _ in range(constants.DB_MAX_RETRIES):"},{"line_number":227,"context_line":"                ip_range \u003d range_qry.filter_by(subnet_id\u003dsubnet[\u0027id\u0027]).first()"},{"line_number":228,"context_line":"                if not ip_range:"},{"line_number":229,"context_line":"                    LOG.debug(\"All IPs from subnet %(subnet_id)s (%(cidr)s) \""}],"source_content_type":"text/x-python","patch_set":20,"id":"fa98f980_f270520a","line":226,"updated":"2014-09-19 03:52:22.000000000","message":"See PS19 comment","commit_id":"8c4776170fcead56db5a42f22c7afca3a4444e77"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"c2f8445eef750e8dccd8c5b7d19311a26167c3bb","unresolved":false,"context_lines":[{"line_number":230,"context_line":"                              \"allocated\","},{"line_number":231,"context_line":"                              {\u0027subnet_id\u0027: subnet[\u0027id\u0027],"},{"line_number":232,"context_line":"                               \u0027cidr\u0027: subnet[\u0027cidr\u0027]})"},{"line_number":233,"context_line":"                    break"},{"line_number":234,"context_line":"                # Update the database record only if the existing record"},{"line_number":235,"context_line":"                # matches exactly what it\u0027s expected, that is only if no other"},{"line_number":236,"context_line":"                # process has modified the same record"}],"source_content_type":"text/x-python","patch_set":20,"id":"fa98f980_3262da3d","line":233,"updated":"2014-09-19 03:52:22.000000000","message":"See PS19 comment","commit_id":"8c4776170fcead56db5a42f22c7afca3a4444e77"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"c2f8445eef750e8dccd8c5b7d19311a26167c3bb","unresolved":false,"context_lines":[{"line_number":347,"context_line":"                    if first \u003d\u003d last:"},{"line_number":348,"context_line":"                        count \u003d check_update_query.delete()"},{"line_number":349,"context_line":"                        if count \u003d\u003d 0:"},{"line_number":350,"context_line":"                            continue"},{"line_number":351,"context_line":"                    elif first \u003d\u003d ip:"},{"line_number":352,"context_line":"                        new_first_ip \u003d str(netaddr.IPAddress(ip_address) + 1)"},{"line_number":353,"context_line":"                        count \u003d (check_update_query.update("}],"source_content_type":"text/x-python","patch_set":20,"id":"fa98f980_b266ca53","line":350,"updated":"2014-09-19 03:52:22.000000000","message":"See PS19 comments on these continues","commit_id":"8c4776170fcead56db5a42f22c7afca3a4444e77"},{"author":{"_account_id":261,"name":"Salvatore Orlando","email":"salv.orlando@gmail.com","username":"salvatore-orlando"},"change_message_id":"68f44a1cbe6876f1c68ae29ff7c52095a819cd8a","unresolved":false,"context_lines":[{"line_number":54,"context_line":"AUTO_DELETE_PORT_OWNERS \u003d [constants.DEVICE_OWNER_DHCP]"},{"line_number":55,"context_line":""},{"line_number":56,"context_line":""},{"line_number":57,"context_line":"def _retry_ip_allocation(f):"},{"line_number":58,"context_line":"    @functools.wraps(f)"},{"line_number":59,"context_line":"    def wrapper(*args, **kwargs):"},{"line_number":60,"context_line":"        remaining \u003d constants.DB_MAX_RETRIES - 1"}],"source_content_type":"text/x-python","patch_set":21,"id":"da9df570_f724fdc7","line":57,"updated":"2014-09-22 13:04:19.000000000","message":"curiosity: was the prepending underscore asked by some other reviewer?","commit_id":"83dc06a441a8c2101a7f007b7610054bb4826058"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"51a89d8a21832954384457d46d3aef820f61b71e","unresolved":false,"context_lines":[{"line_number":54,"context_line":"AUTO_DELETE_PORT_OWNERS \u003d [constants.DEVICE_OWNER_DHCP]"},{"line_number":55,"context_line":""},{"line_number":56,"context_line":""},{"line_number":57,"context_line":"def _retry_ip_allocation(f):"},{"line_number":58,"context_line":"    @functools.wraps(f)"},{"line_number":59,"context_line":"    def wrapper(*args, **kwargs):"},{"line_number":60,"context_line":"        remaining \u003d constants.DB_MAX_RETRIES - 1"}],"source_content_type":"text/x-python","patch_set":21,"id":"da9df570_ede8a97e","line":57,"in_reply_to":"da9df570_f724fdc7","updated":"2014-09-22 14:30:22.000000000","message":"No. Shall I remove it or you like it?","commit_id":"83dc06a441a8c2101a7f007b7610054bb4826058"},{"author":{"_account_id":261,"name":"Salvatore Orlando","email":"salv.orlando@gmail.com","username":"salvatore-orlando"},"change_message_id":"68f44a1cbe6876f1c68ae29ff7c52095a819cd8a","unresolved":false,"context_lines":[{"line_number":68,"context_line":"                    # FIXME(rossella_s) find a  way to pass the network_id"},{"line_number":69,"context_line":"                    # or use another exception"},{"line_number":70,"context_line":"                    raise n_exc.IpAddressGenerationFailure(net_id\u003d\u0027\u0027)"},{"line_number":71,"context_line":"                if remaining !\u003d -1:"},{"line_number":72,"context_line":"                    remaining -\u003d 1"},{"line_number":73,"context_line":"    return wrapper"},{"line_number":74,"context_line":""}],"source_content_type":"text/x-python","patch_set":21,"id":"da9df570_9252df11","line":71,"updated":"2014-09-22 13:04:19.000000000","message":"if you raise when remaining is 0, the only chance when it can get to -1 is when it is initialized to 0, which is obviously wrong.\n\nIs there any other reason for the check above?","commit_id":"83dc06a441a8c2101a7f007b7610054bb4826058"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"51a89d8a21832954384457d46d3aef820f61b71e","unresolved":false,"context_lines":[{"line_number":68,"context_line":"                    # FIXME(rossella_s) find a  way to pass the network_id"},{"line_number":69,"context_line":"                    # or use another exception"},{"line_number":70,"context_line":"                    raise n_exc.IpAddressGenerationFailure(net_id\u003d\u0027\u0027)"},{"line_number":71,"context_line":"                if remaining !\u003d -1:"},{"line_number":72,"context_line":"                    remaining -\u003d 1"},{"line_number":73,"context_line":"    return wrapper"},{"line_number":74,"context_line":""}],"source_content_type":"text/x-python","patch_set":21,"id":"da9df570_0da5ed52","line":71,"in_reply_to":"da9df570_9252df11","updated":"2014-09-22 14:30:22.000000000","message":"You are totally right, my bad, it\u0027s a copy/paste error...I used a similar wrapper somewhere else and forgot to remove these lines that don\u0027t apply here","commit_id":"83dc06a441a8c2101a7f007b7610054bb4826058"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"043e3585d574d7075eb65571340cf81ad287e110","unresolved":false,"context_lines":[{"line_number":57,"context_line":"def _retry_ip_allocation(f):"},{"line_number":58,"context_line":"    @functools.wraps(f)"},{"line_number":59,"context_line":"    def wrapper(*args, **kwargs):"},{"line_number":60,"context_line":"        remaining \u003d constants.DB_MAX_RETRIES - 1"},{"line_number":61,"context_line":"        while True:"},{"line_number":62,"context_line":"            try:"},{"line_number":63,"context_line":"                return f(*args, **kwargs)"}],"source_content_type":"text/x-python","patch_set":23,"id":"da9df570_026e9401","line":60,"updated":"2014-09-22 18:31:31.000000000","message":"nit:\n\n  for x in range(constants.DB_MAX_RETRIES):\n      try:\n          return f(*args, **kwargs)\n      except n_exc.IPAllocationFailure:\n          continue\n  LOG.exception(...)\n  raise n_exc.IPAllocationFailure\n\nThis looks a little easier on the eyes to me.","commit_id":"208b726c8397f64241390857cca39ff3cc4dd05f"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"49e83b3a223cce13ffa82963c3507f09ca600aab","unresolved":false,"context_lines":[{"line_number":57,"context_line":"def _retry_ip_allocation(f):"},{"line_number":58,"context_line":"    @functools.wraps(f)"},{"line_number":59,"context_line":"    def wrapper(*args, **kwargs):"},{"line_number":60,"context_line":"        remaining \u003d constants.DB_MAX_RETRIES - 1"},{"line_number":61,"context_line":"        while True:"},{"line_number":62,"context_line":"            try:"},{"line_number":63,"context_line":"                return f(*args, **kwargs)"}],"source_content_type":"text/x-python","patch_set":23,"id":"da9df570_d3ee0d8b","line":60,"in_reply_to":"da9df570_026e9401","updated":"2014-09-23 14:16:14.000000000","message":"Thanks Carl, done!","commit_id":"208b726c8397f64241390857cca39ff3cc4dd05f"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"043e3585d574d7075eb65571340cf81ad287e110","unresolved":false,"context_lines":[{"line_number":237,"context_line":"        if f(*args, **kwargs) \u003d\u003d 0:"},{"line_number":238,"context_line":"            raise n_exc.IPAllocationFailure"},{"line_number":239,"context_line":""},{"line_number":240,"context_line":"    @staticmethod"},{"line_number":241,"context_line":"    @_retry_ip_allocation"},{"line_number":242,"context_line":"    def _try_generate_ip(context, subnets, port_id):"},{"line_number":243,"context_line":"        \"\"\"Generate an IP address."}],"source_content_type":"text/x-python","patch_set":23,"id":"da9df570_820364b7","line":240,"updated":"2014-09-22 18:31:31.000000000","message":"nit:  Maybe make this a @classmethod if you have a reason to crack this patch again.  That would avoid hard-coding the class name below.","commit_id":"208b726c8397f64241390857cca39ff3cc4dd05f"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"49e83b3a223cce13ffa82963c3507f09ca600aab","unresolved":false,"context_lines":[{"line_number":237,"context_line":"        if f(*args, **kwargs) \u003d\u003d 0:"},{"line_number":238,"context_line":"            raise n_exc.IPAllocationFailure"},{"line_number":239,"context_line":""},{"line_number":240,"context_line":"    @staticmethod"},{"line_number":241,"context_line":"    @_retry_ip_allocation"},{"line_number":242,"context_line":"    def _try_generate_ip(context, subnets, port_id):"},{"line_number":243,"context_line":"        \"\"\"Generate an IP address."}],"source_content_type":"text/x-python","patch_set":23,"id":"da9df570_b355091f","line":240,"in_reply_to":"da9df570_820364b7","updated":"2014-09-23 14:16:14.000000000","message":"do you mind if I don\u0027t apply this suggestion? I\u0027d prefer avoiding adding another change, just to minimize the diff","commit_id":"208b726c8397f64241390857cca39ff3cc4dd05f"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"1581e46b727d0d3e44c6bdef81cabac94ea7c2b5","unresolved":false,"context_lines":[{"line_number":237,"context_line":"        if f(*args, **kwargs) \u003d\u003d 0:"},{"line_number":238,"context_line":"            raise n_exc.IPAllocationFailure"},{"line_number":239,"context_line":""},{"line_number":240,"context_line":"    @staticmethod"},{"line_number":241,"context_line":"    @_retry_ip_allocation"},{"line_number":242,"context_line":"    def _try_generate_ip(context, subnets, port_id):"},{"line_number":243,"context_line":"        \"\"\"Generate an IP address."}],"source_content_type":"text/x-python","patch_set":23,"id":"da9df570_f84f65bc","line":240,"in_reply_to":"da9df570_b355091f","updated":"2014-09-23 14:37:11.000000000","message":"My nits are always optional.  I am a fan of minimizing diffs.","commit_id":"208b726c8397f64241390857cca39ff3cc4dd05f"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"043e3585d574d7075eb65571340cf81ad287e110","unresolved":false,"context_lines":[{"line_number":287,"context_line":"                subnet[\u0027id\u0027], port_id)"},{"line_number":288,"context_line":"            return {\u0027ip_address\u0027: ip_address,"},{"line_number":289,"context_line":"                    \u0027subnet_id\u0027: subnet[\u0027id\u0027]}"},{"line_number":290,"context_line":"        raise n_exc.IPAllocationFailure"},{"line_number":291,"context_line":""},{"line_number":292,"context_line":"    @staticmethod"},{"line_number":293,"context_line":"    def _rebuild_availability_ranges(context, subnets):"}],"source_content_type":"text/x-python","patch_set":23,"id":"da9df570_a246a8bd","line":290,"updated":"2014-09-22 18:31:31.000000000","message":"I think you can keep this logic the same.  Raise IpAddressGenerationFailure here and avoid the changes to _generate_ip above.  I\u0027m pretty sure if we get to this point then we\u0027ve iterated over all of the subnets and not found any availability and we need to run the rebuild method and try again.  This raise should not trigger the retry in the decorator.","commit_id":"208b726c8397f64241390857cca39ff3cc4dd05f"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"49e83b3a223cce13ffa82963c3507f09ca600aab","unresolved":false,"context_lines":[{"line_number":287,"context_line":"                subnet[\u0027id\u0027], port_id)"},{"line_number":288,"context_line":"            return {\u0027ip_address\u0027: ip_address,"},{"line_number":289,"context_line":"                    \u0027subnet_id\u0027: subnet[\u0027id\u0027]}"},{"line_number":290,"context_line":"        raise n_exc.IPAllocationFailure"},{"line_number":291,"context_line":""},{"line_number":292,"context_line":"    @staticmethod"},{"line_number":293,"context_line":"    def _rebuild_availability_ranges(context, subnets):"}],"source_content_type":"text/x-python","patch_set":23,"id":"da9df570_530cdd42","line":290,"in_reply_to":"da9df570_a246a8bd","updated":"2014-09-23 14:16:14.000000000","message":"very good point! This makes me think that I should probably add another unit test to catch this.","commit_id":"208b726c8397f64241390857cca39ff3cc4dd05f"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"043e3585d574d7075eb65571340cf81ad287e110","unresolved":false,"context_lines":[{"line_number":342,"context_line":"                            first_ip\u003dstr(netaddr.IPAddress(ip_range.first)),"},{"line_number":343,"context_line":"                            last_ip\u003dstr(netaddr.IPAddress(ip_range.last)))"},{"line_number":344,"context_line":"                        context.session.add(available_range)"},{"line_number":345,"context_line":"                except db_exc.DBDuplicateEntry:"},{"line_number":346,"context_line":"                    LOG.info(_LI(\"A concurrent _rebuild_availability_ranges\""},{"line_number":347,"context_line":"                             \" had already added this range\"))"},{"line_number":348,"context_line":""}],"source_content_type":"text/x-python","patch_set":23,"id":"da9df570_b6042d16","line":345,"updated":"2014-09-22 18:31:31.000000000","message":"Any more thoughts on the corner case here?  I haven\u0027t come up with anything new.  The new constraints that you suggested in PS17 comments are the best idea we have at the moment.  The constraints make sense for the particular table.  There is no reason those constraints should be violated.","commit_id":"208b726c8397f64241390857cca39ff3cc4dd05f"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"49e83b3a223cce13ffa82963c3507f09ca600aab","unresolved":false,"context_lines":[{"line_number":342,"context_line":"                            first_ip\u003dstr(netaddr.IPAddress(ip_range.first)),"},{"line_number":343,"context_line":"                            last_ip\u003dstr(netaddr.IPAddress(ip_range.last)))"},{"line_number":344,"context_line":"                        context.session.add(available_range)"},{"line_number":345,"context_line":"                except db_exc.DBDuplicateEntry:"},{"line_number":346,"context_line":"                    LOG.info(_LI(\"A concurrent _rebuild_availability_ranges\""},{"line_number":347,"context_line":"                             \" had already added this range\"))"},{"line_number":348,"context_line":""}],"source_content_type":"text/x-python","patch_set":23,"id":"da9df570_327d8eb2","line":345,"in_reply_to":"da9df570_b6042d16","updated":"2014-09-23 14:16:14.000000000","message":"I will go with the constraint then","commit_id":"208b726c8397f64241390857cca39ff3cc4dd05f"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"043e3585d574d7075eb65571340cf81ad287e110","unresolved":false,"context_lines":[{"line_number":374,"context_line":"                elif first \u003d\u003d ip:"},{"line_number":375,"context_line":"                    new_first_ip \u003d str(netaddr.IPAddress(ip_address) + 1)"},{"line_number":376,"context_line":"                    NeutronDbPluginV2._check_update_is_successful("},{"line_number":377,"context_line":"                        check_update_query.update, {\"first_ip\": new_first_ip})"},{"line_number":378,"context_line":"                elif last \u003d\u003d ip:"},{"line_number":379,"context_line":"                    new_last_ip \u003d str(netaddr.IPAddress(ip_address) - 1)"},{"line_number":380,"context_line":"                    NeutronDbPluginV2._check_update_is_successful("}],"source_content_type":"text/x-python","patch_set":23,"id":"da9df570_02acd49f","line":377,"updated":"2014-09-22 18:31:31.000000000","message":"(just talking out loud)  I can\u0027t get these updates out of my head.  Are you sure that concurrent updates will be caught here?  So, say one process successfully updates the row.  Is the second process to try to update the same row guaranteed to fail?  I guess if sqlalchemy generates something equivalent to the below then it should work:\n\n  UPDATE ipavailabilityrange SET first_ip \u003d :new_first_ip\n  WHERE first_ip \u003d ... AND last_ip \u003d ...;\n\nSo, I guess I\u0027ve talked myself in to believing that this will work as intended.  Does this match your understanding here?","commit_id":"208b726c8397f64241390857cca39ff3cc4dd05f"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"49e83b3a223cce13ffa82963c3507f09ca600aab","unresolved":false,"context_lines":[{"line_number":374,"context_line":"                elif first \u003d\u003d ip:"},{"line_number":375,"context_line":"                    new_first_ip \u003d str(netaddr.IPAddress(ip_address) + 1)"},{"line_number":376,"context_line":"                    NeutronDbPluginV2._check_update_is_successful("},{"line_number":377,"context_line":"                        check_update_query.update, {\"first_ip\": new_first_ip})"},{"line_number":378,"context_line":"                elif last \u003d\u003d ip:"},{"line_number":379,"context_line":"                    new_last_ip \u003d str(netaddr.IPAddress(ip_address) - 1)"},{"line_number":380,"context_line":"                    NeutronDbPluginV2._check_update_is_successful("}],"source_content_type":"text/x-python","patch_set":23,"id":"da9df570_d22522c3","line":377,"in_reply_to":"da9df570_02acd49f","updated":"2014-09-23 14:16:14.000000000","message":"Yes exactly. Anyway I am writing a functional test as suggested by Maru. If there\u0027s any problem we are gonna catch that in the test I hope.","commit_id":"208b726c8397f64241390857cca39ff3cc4dd05f"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"043e3585d574d7075eb65571340cf81ad287e110","unresolved":false,"context_lines":[{"line_number":623,"context_line":"                        raise n_exc.IpAddressInUse("},{"line_number":624,"context_line":"                            net_id\u003dp[\u0027network_id\u0027],"},{"line_number":625,"context_line":"                            ip_address\u003dip_address.format())"},{"line_number":626,"context_line":"                    NeutronDbPluginV2._store_ip_allocation("},{"line_number":627,"context_line":"                        context, ip_address.format(), p[\u0027network_id\u0027],"},{"line_number":628,"context_line":"                        subnet[\u0027id\u0027], port_id)"},{"line_number":629,"context_line":"                    v6.remove(subnet)"}],"source_content_type":"text/x-python","patch_set":23,"id":"da9df570_e28d1033","line":626,"updated":"2014-09-22 18:31:31.000000000","message":"nit:  I think self._store_ip_allocation should work.","commit_id":"208b726c8397f64241390857cca39ff3cc4dd05f"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"49e83b3a223cce13ffa82963c3507f09ca600aab","unresolved":false,"context_lines":[{"line_number":623,"context_line":"                        raise n_exc.IpAddressInUse("},{"line_number":624,"context_line":"                            net_id\u003dp[\u0027network_id\u0027],"},{"line_number":625,"context_line":"                            ip_address\u003dip_address.format())"},{"line_number":626,"context_line":"                    NeutronDbPluginV2._store_ip_allocation("},{"line_number":627,"context_line":"                        context, ip_address.format(), p[\u0027network_id\u0027],"},{"line_number":628,"context_line":"                        subnet[\u0027id\u0027], port_id)"},{"line_number":629,"context_line":"                    v6.remove(subnet)"}],"source_content_type":"text/x-python","patch_set":23,"id":"da9df570_721c7678","line":626,"in_reply_to":"da9df570_e28d1033","updated":"2014-09-23 14:16:14.000000000","message":"Done","commit_id":"208b726c8397f64241390857cca39ff3cc4dd05f"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"3af6194a829462d711b511b5d8ad0c3632b9e995","unresolved":false,"context_lines":[{"line_number":216,"context_line":"        context.session.add(allocated)"},{"line_number":217,"context_line":""},{"line_number":218,"context_line":"    @staticmethod"},{"line_number":219,"context_line":"    def _generate_ip(context, subnets, port_id):"},{"line_number":220,"context_line":"        for x in range(0, 2):"},{"line_number":221,"context_line":"            try:"},{"line_number":222,"context_line":"                return NeutronDbPluginV2._try_generate_ip("}],"source_content_type":"text/x-python","patch_set":24,"id":"da9df570_231e1e64","line":219,"updated":"2014-09-23 14:49:46.000000000","message":"I think all of the change to this method can be reverted.  The original should work now that IpAddressGenerationFailure !\u003d IPAllocationFailure.  Sorry I didn\u0027t make that clear in the last patch.\n\nSpecifically, I don\u0027t think we should rebuild availability ranges if IPAllocationFailure is raised and we shouldn\u0027t catch it here.","commit_id":"82d197c1d948999c991a33497ad89fce919ca5de"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"3481e43f04aaa17ffacb189465b3a4d1b07833ad","unresolved":false,"context_lines":[{"line_number":216,"context_line":"        context.session.add(allocated)"},{"line_number":217,"context_line":""},{"line_number":218,"context_line":"    @staticmethod"},{"line_number":219,"context_line":"    def _generate_ip(context, subnets, port_id):"},{"line_number":220,"context_line":"        for x in range(0, 2):"},{"line_number":221,"context_line":"            try:"},{"line_number":222,"context_line":"                return NeutronDbPluginV2._try_generate_ip("}],"source_content_type":"text/x-python","patch_set":24,"id":"da9df570_8878c290","line":219,"in_reply_to":"da9df570_231e1e64","updated":"2014-09-23 16:27:36.000000000","message":"Agreed, thanks!","commit_id":"82d197c1d948999c991a33497ad89fce919ca5de"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"64574cc394cbc013d2b877fd38e8b0f792beae2b","unresolved":false,"context_lines":[{"line_number":62,"context_line":"                return f(*args, **kwargs)"},{"line_number":63,"context_line":"            except n_exc.IPAllocationFailure:"},{"line_number":64,"context_line":"                continue"},{"line_number":65,"context_line":"        LOG.exception(_LE(\u0027IP allocation failed, attempts exceeded\u0027))"},{"line_number":66,"context_line":"        raise n_exc.IPAllocationFailure"},{"line_number":67,"context_line":"    return wrapper"},{"line_number":68,"context_line":""}],"source_content_type":"text/x-python","patch_set":25,"id":"da9df570_9c62c4ab","line":65,"updated":"2014-09-23 18:18:35.000000000","message":"Translated string at error level","commit_id":"4001992431297804b011c969e6ec5f55e2bb75b5"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"3941357e4855b35f2ea0b6f4d19e7832c3763893","unresolved":false,"context_lines":[{"line_number":62,"context_line":"                return f(*args, **kwargs)"},{"line_number":63,"context_line":"            except n_exc.IPAllocationFailure:"},{"line_number":64,"context_line":"                continue"},{"line_number":65,"context_line":"        LOG.exception(_LE(\u0027IP allocation failed, attempts exceeded\u0027))"},{"line_number":66,"context_line":"        raise n_exc.IPAllocationFailure"},{"line_number":67,"context_line":"    return wrapper"},{"line_number":68,"context_line":""}],"source_content_type":"text/x-python","patch_set":25,"id":"baa201ad_511e20bc","line":65,"in_reply_to":"da9df570_9c62c4ab","updated":"2014-10-06 23:04:21.000000000","message":"Actually, a translated string in a log wouldn\u0027t have been subject to string freeze.  That wasn\u0027t the reason this was excluded from Juno, just saying.","commit_id":"4001992431297804b011c969e6ec5f55e2bb75b5"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"3941357e4855b35f2ea0b6f4d19e7832c3763893","unresolved":false,"context_lines":[{"line_number":200,"context_line":""},{"line_number":201,"context_line":"    @staticmethod"},{"line_number":202,"context_line":"    def _store_ip_allocation(context, ip_address, network_id, subnet_id,"},{"line_number":203,"context_line":"                             port_id):"},{"line_number":204,"context_line":"        LOG.debug(\"Allocated IP %(ip_address)s \""},{"line_number":205,"context_line":"                  \"(%(network_id)s/%(subnet_id)s/%(port_id)s)\","},{"line_number":206,"context_line":"                  {\u0027ip_address\u0027: ip_address,"}],"source_content_type":"text/x-python","patch_set":25,"id":"baa201ad_54d9ae20","line":203,"updated":"2014-10-06 23:04:21.000000000","message":"This may or may not be relevant to this patch.  I noticed it while looking at code in the context of the discussion on L330.\n\nThis log should probably go after context.session.add(...) since storing the IPAllocation could raise a duplicate entry.","commit_id":"4001992431297804b011c969e6ec5f55e2bb75b5"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"a0ba53f09625218b4d8e1c767d6097f72ec58823","unresolved":false,"context_lines":[{"line_number":200,"context_line":""},{"line_number":201,"context_line":"    @staticmethod"},{"line_number":202,"context_line":"    def _store_ip_allocation(context, ip_address, network_id, subnet_id,"},{"line_number":203,"context_line":"                             port_id):"},{"line_number":204,"context_line":"        LOG.debug(\"Allocated IP %(ip_address)s \""},{"line_number":205,"context_line":"                  \"(%(network_id)s/%(subnet_id)s/%(port_id)s)\","},{"line_number":206,"context_line":"                  {\u0027ip_address\u0027: ip_address,"}],"source_content_type":"text/x-python","patch_set":25,"id":"baa201ad_4d3f7c87","line":203,"in_reply_to":"baa201ad_54d9ae20","updated":"2014-10-16 16:17:54.000000000","message":"Yes, I wiil move it","commit_id":"4001992431297804b011c969e6ec5f55e2bb75b5"},{"author":{"_account_id":8686,"name":"Wang Bo","email":"bo.wang@easystack.cn","username":"wangbo"},"change_message_id":"c145c5f7f61b176727e10aa4cb6f99b746b2542e","unresolved":false,"context_lines":[{"line_number":327,"context_line":"                    if first:"},{"line_number":328,"context_line":"                        yield netaddr.IPRange(first, last)"},{"line_number":329,"context_line":""},{"line_number":330,"context_line":"                # Write the ranges to the db"},{"line_number":331,"context_line":"                try:"},{"line_number":332,"context_line":"                    for ip_range in ipset_to_ranges(available):"},{"line_number":333,"context_line":"                        available_range \u003d models_v2.IPAvailabilityRange("}],"source_content_type":"text/x-python","patch_set":25,"id":"da9df570_0ed84352","line":330,"updated":"2014-09-24 11:47:01.000000000","message":"One question here, how could the code ensure that table IPAllocation hasn\u0027t been updated between line 298(query the allocated ips) and line 337(insert new records into table IPAVAILABILITYRANGES)?  \nAssume the scenario like that ip \"10.16.1.10\" hasn\u0027t been allocated when quering in line 298 so it will be added into new available ranges in line 337. However, coincidentally another process got \"10.16.1.10\" as the allocated ip between the lines that result in error happened. \n\nI ask this question because I found table IPAVAILABILITYRANGES has wrong records(available ranges containing the allocated ip in table IPAllocation) in my performance test. I use DB2, set api_workers\u003d16 in neutron.conf and run \"neutron port-create\" in large number concurrently.\n\nIs this caused of neutron db operation codes? Hope for your comments. Thanks!","commit_id":"4001992431297804b011c969e6ec5f55e2bb75b5"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"c7a0ea1ebf1a0f4dd60470c762caab8d8e8ac988","unresolved":false,"context_lines":[{"line_number":327,"context_line":"                    if first:"},{"line_number":328,"context_line":"                        yield netaddr.IPRange(first, last)"},{"line_number":329,"context_line":""},{"line_number":330,"context_line":"                # Write the ranges to the db"},{"line_number":331,"context_line":"                try:"},{"line_number":332,"context_line":"                    for ip_range in ipset_to_ranges(available):"},{"line_number":333,"context_line":"                        available_range \u003d models_v2.IPAvailabilityRange("}],"source_content_type":"text/x-python","patch_set":25,"id":"9aa7fdbe_4f6d4d04","line":330,"in_reply_to":"baa201ad_4d569ccf","updated":"2014-10-17 22:24:59.000000000","message":"To avoid the endless loop, we\u0027d need to adjust the availability range table to exclude the IP in conflict.","commit_id":"4001992431297804b011c969e6ec5f55e2bb75b5"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"5a7ce2aea0e44ec60256d53a7a93a8a8f5bf8929","unresolved":false,"context_lines":[{"line_number":327,"context_line":"                    if first:"},{"line_number":328,"context_line":"                        yield netaddr.IPRange(first, last)"},{"line_number":329,"context_line":""},{"line_number":330,"context_line":"                # Write the ranges to the db"},{"line_number":331,"context_line":"                try:"},{"line_number":332,"context_line":"                    for ip_range in ipset_to_ranges(available):"},{"line_number":333,"context_line":"                        available_range \u003d models_v2.IPAvailabilityRange("}],"source_content_type":"text/x-python","patch_set":25,"id":"baa201ad_765d0f15","line":330,"in_reply_to":"baa201ad_5d202ef7","updated":"2014-10-14 16:42:26.000000000","message":"The duplicate entry/retry idea is still the only solution that I can think of too.  It means that we can\u0027t totally trust the availability range table.  I may be okay with this as long as we can always trust the allocations table.  I think we can.","commit_id":"4001992431297804b011c969e6ec5f55e2bb75b5"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"1171ab32699354549f8e6990410195ef2b9b794e","unresolved":false,"context_lines":[{"line_number":327,"context_line":"                    if first:"},{"line_number":328,"context_line":"                        yield netaddr.IPRange(first, last)"},{"line_number":329,"context_line":""},{"line_number":330,"context_line":"                # Write the ranges to the db"},{"line_number":331,"context_line":"                try:"},{"line_number":332,"context_line":"                    for ip_range in ipset_to_ranges(available):"},{"line_number":333,"context_line":"                        available_range \u003d models_v2.IPAvailabilityRange("}],"source_content_type":"text/x-python","patch_set":25,"id":"baa201ad_5d202ef7","line":330,"in_reply_to":"baa201ad_74715243","updated":"2014-10-14 15:37:22.000000000","message":"Sorry for the late reply, very good point Wang Bo! Carl I don\u0027t have many ideas. I was thinking of adding a check before line 337 to make sure that nothing has changed in the IPAllocation table but that doesn\u0027t solve the race. So checking for a Duplicate entry and retrying seems the only viable solution to me","commit_id":"4001992431297804b011c969e6ec5f55e2bb75b5"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"a0ba53f09625218b4d8e1c767d6097f72ec58823","unresolved":false,"context_lines":[{"line_number":327,"context_line":"                    if first:"},{"line_number":328,"context_line":"                        yield netaddr.IPRange(first, last)"},{"line_number":329,"context_line":""},{"line_number":330,"context_line":"                # Write the ranges to the db"},{"line_number":331,"context_line":"                try:"},{"line_number":332,"context_line":"                    for ip_range in ipset_to_ranges(available):"},{"line_number":333,"context_line":"                        available_range \u003d models_v2.IPAvailabilityRange("}],"source_content_type":"text/x-python","patch_set":25,"id":"baa201ad_4d569ccf","line":330,"in_reply_to":"baa201ad_765d0f15","updated":"2014-10-16 16:17:54.000000000","message":"OK I had another idea. See my next patch. I added a check to verify that we have the same number of allocation after line 337 as we had in line 308. Line 337 requires to have the lock  on the IPAvailabilityRange table, so we are sure no other process can allocate an IP in the meanwhile. If the check fails the rebuild availability ranges is retried.","commit_id":"4001992431297804b011c969e6ec5f55e2bb75b5"},{"author":{"_account_id":7183,"name":"Xu Han Peng","email":"xuhanp@linux.vnet.ibm.com","username":"xuhanp"},"change_message_id":"4a4c1e1bd4549e9c3221178968093443cab61c19","unresolved":false,"context_lines":[{"line_number":327,"context_line":"                    if first:"},{"line_number":328,"context_line":"                        yield netaddr.IPRange(first, last)"},{"line_number":329,"context_line":""},{"line_number":330,"context_line":"                # Write the ranges to the db"},{"line_number":331,"context_line":"                try:"},{"line_number":332,"context_line":"                    for ip_range in ipset_to_ranges(available):"},{"line_number":333,"context_line":"                        available_range \u003d models_v2.IPAvailabilityRange("}],"source_content_type":"text/x-python","patch_set":25,"id":"baa201ad_88a7800a","line":330,"in_reply_to":"baa201ad_765d0f15","updated":"2014-10-16 06:01:20.000000000","message":"Say we can detect the duplicate entry by trying to catch the exception, then we still need to rebuild the availability range again to make the next allocation correct. During the second time of rebuild, the same problem could happen again, which leads to an endless loop. I don\u0027t know if doing this can really the problem.","commit_id":"4001992431297804b011c969e6ec5f55e2bb75b5"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"3941357e4855b35f2ea0b6f4d19e7832c3763893","unresolved":false,"context_lines":[{"line_number":327,"context_line":"                    if first:"},{"line_number":328,"context_line":"                        yield netaddr.IPRange(first, last)"},{"line_number":329,"context_line":""},{"line_number":330,"context_line":"                # Write the ranges to the db"},{"line_number":331,"context_line":"                try:"},{"line_number":332,"context_line":"                    for ip_range in ipset_to_ranges(available):"},{"line_number":333,"context_line":"                        available_range \u003d models_v2.IPAvailabilityRange("}],"source_content_type":"text/x-python","patch_set":25,"id":"baa201ad_74715243","line":330,"in_reply_to":"da9df570_0ed84352","updated":"2014-10-06 23:04:21.000000000","message":"The following could happen:\n\n 1) Process 1 finds \"10.16.1.10\" and it removes this from availability ranges table.\n 2) Process 2 checks for availability and sees there is none.\n 3) Process 2 starts _rebuild_availability_ranges which queries on L307\n 4) Process 1 calls _store_ip_allocation on L278\n\nThis could lead to the problem that you describe.  Good find and thank you for pointing this out.\n\nThe penalty for this is that a process may think it can allocate this IP again.  it will try to assert its allocation in the IPAllocation table and there will be an error.  The IP cannot be allocated twice.  I think that L216 would raise a duplicate entry.\n\nI guess we could handle the duplicate entry exception and try again.  That feels a bit like a hack.  I\u0027d be open to entertaining this other ideas.","commit_id":"4001992431297804b011c969e6ec5f55e2bb75b5"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"64574cc394cbc013d2b877fd38e8b0f792beae2b","unresolved":false,"context_lines":[{"line_number":336,"context_line":"                            last_ip\u003dstr(netaddr.IPAddress(ip_range.last)))"},{"line_number":337,"context_line":"                        context.session.add(available_range)"},{"line_number":338,"context_line":"                except db_exc.DBDuplicateEntry:"},{"line_number":339,"context_line":"                    LOG.info(_LI(\"A concurrent _rebuild_availability_ranges\""},{"line_number":340,"context_line":"                             \" had already added this range\"))"},{"line_number":341,"context_line":""},{"line_number":342,"context_line":"    @staticmethod"}],"source_content_type":"text/x-python","patch_set":25,"id":"da9df570_3ce8f80f","line":339,"updated":"2014-09-23 18:18:35.000000000","message":"This could be a debug statement (and hence not be translated).  This condition should not be of concern to the operator.","commit_id":"4001992431297804b011c969e6ec5f55e2bb75b5"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"a0ba53f09625218b4d8e1c767d6097f72ec58823","unresolved":false,"context_lines":[{"line_number":336,"context_line":"                            last_ip\u003dstr(netaddr.IPAddress(ip_range.last)))"},{"line_number":337,"context_line":"                        context.session.add(available_range)"},{"line_number":338,"context_line":"                except db_exc.DBDuplicateEntry:"},{"line_number":339,"context_line":"                    LOG.info(_LI(\"A concurrent _rebuild_availability_ranges\""},{"line_number":340,"context_line":"                             \" had already added this range\"))"},{"line_number":341,"context_line":""},{"line_number":342,"context_line":"    @staticmethod"}],"source_content_type":"text/x-python","patch_set":25,"id":"baa201ad_6d5b60f6","line":339,"in_reply_to":"da9df570_3ce8f80f","updated":"2014-10-16 16:17:54.000000000","message":"OK","commit_id":"4001992431297804b011c969e6ec5f55e2bb75b5"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"b0d141c9c7441c47615bc7960667811295b2029a","unresolved":false,"context_lines":[{"line_number":54,"context_line":"AUTO_DELETE_PORT_OWNERS \u003d [constants.DEVICE_OWNER_DHCP]"},{"line_number":55,"context_line":""},{"line_number":56,"context_line":""},{"line_number":57,"context_line":"def _retry_ip_allocation(f):"},{"line_number":58,"context_line":"    @functools.wraps(f)"},{"line_number":59,"context_line":"    def wrapper(*args, **kwargs):"},{"line_number":60,"context_line":"        for x in range(constants.DB_MAX_RETRIES):"}],"source_content_type":"text/x-python","patch_set":26,"id":"9aa7fdbe_491cf713","line":57,"updated":"2014-10-22 20:57:04.000000000","message":"These two wrappers are almost exactly the same. Can you just make a general retry wrapper?\n\ndef _retry_function(f, maxretries):\n    @functools.wraps(f)\n    def wrapped(*args, **kwargs):\n        for x in range(maxretries):\n            try:\n                return f(*args, **kwargs)\n            except Exception:\n                pass\n        return f(*args, **kwargs)\n    return wrapped","commit_id":"da0221f6ff49562775bb864c8e6605be12785fc0"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"b6559a3ecbe38a15ea7d859891e3ccb8bda939c0","unresolved":false,"context_lines":[{"line_number":54,"context_line":"AUTO_DELETE_PORT_OWNERS \u003d [constants.DEVICE_OWNER_DHCP]"},{"line_number":55,"context_line":""},{"line_number":56,"context_line":""},{"line_number":57,"context_line":"def _retry_ip_allocation(f):"},{"line_number":58,"context_line":"    @functools.wraps(f)"},{"line_number":59,"context_line":"    def wrapper(*args, **kwargs):"},{"line_number":60,"context_line":"        for x in range(constants.DB_MAX_RETRIES):"}],"source_content_type":"text/x-python","patch_set":26,"id":"9aa7fdbe_f37e3fae","line":57,"in_reply_to":"9aa7fdbe_1ebf55ab","updated":"2014-10-24 17:59:10.000000000","message":"@Kevin  Notice the third method in the middle called \"wrap\".  My naming maybe could use some work.  There is no typo, my version was copy/pasted from a working example.\n\nThe middle level of wrapping is needed because the decorator is now called with (...) in order to pass it arguments.  Notice, a decorator without arguments is usually used like this:\n\n  @_retry_function               \u003c- Look, no parens\n  def wrapped_function():\n\nNow that I want it to take arguments, I call the outer function with them inside () turning it in to a function call.  It returns the next method which is actually the method that wraps the function.  It creates a closure which captures the arguments to the outer function.\n\n  @_retry_function(...)\n  def wrapped_function():","commit_id":"da0221f6ff49562775bb864c8e6605be12785fc0"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"8271ef1f8c22a7796ee9c0d2437341a3f03a069a","unresolved":false,"context_lines":[{"line_number":54,"context_line":"AUTO_DELETE_PORT_OWNERS \u003d [constants.DEVICE_OWNER_DHCP]"},{"line_number":55,"context_line":""},{"line_number":56,"context_line":""},{"line_number":57,"context_line":"def _retry_ip_allocation(f):"},{"line_number":58,"context_line":"    @functools.wraps(f)"},{"line_number":59,"context_line":"    def wrapper(*args, **kwargs):"},{"line_number":60,"context_line":"        for x in range(constants.DB_MAX_RETRIES):"}],"source_content_type":"text/x-python","patch_set":26,"id":"9aa7fdbe_747ed41a","line":57,"in_reply_to":"9aa7fdbe_491cf713","updated":"2014-10-23 17:50:36.000000000","message":"A good idea.  Building on this...\n\nI\u0027d rather not catch Exception generically.  Also, this version would try maxretries + 1 times.  Depending on how you interpret \"maxretries\" you could argue this is correct.  But, I\u0027d rather avoid the ambiguity.  This version should maintain exception context which resolves my minor concern below.\n\nAlso, I couldn\u0027t get your version to work the way it is written.  I morphed it in to this which works for me in local testing:\n\ndef _retry_function(ExceptionType, maxtries):\n    def wrap(f):\n        @functools.wraps(f)\n        def wrapped(*args, **kwargs):\n            for x in range(maxtries - 1):\n                try:\n                    return f(*args, **kwargs)\n                except ExceptionType:\n                    pass\n            return f(*args, **kwargs)\n        return wrapped\n    return wrap\n\nI use it like this:\n\n@_my_retry_function(MyExceptionType, 3)","commit_id":"da0221f6ff49562775bb864c8e6605be12785fc0"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"318e9a639013aa87bbdc13530d2a01d999ec5782","unresolved":false,"context_lines":[{"line_number":54,"context_line":"AUTO_DELETE_PORT_OWNERS \u003d [constants.DEVICE_OWNER_DHCP]"},{"line_number":55,"context_line":""},{"line_number":56,"context_line":""},{"line_number":57,"context_line":"def _retry_ip_allocation(f):"},{"line_number":58,"context_line":"    @functools.wraps(f)"},{"line_number":59,"context_line":"    def wrapper(*args, **kwargs):"},{"line_number":60,"context_line":"        for x in range(constants.DB_MAX_RETRIES):"}],"source_content_type":"text/x-python","patch_set":26,"id":"9aa7fdbe_5e7b9d8b","line":57,"in_reply_to":"9aa7fdbe_747ed41a","updated":"2014-10-24 10:11:30.000000000","message":"Right, if you change the name to maxtries from maxretries, you have to reduce by 1. ;-)  https://review.openstack.org/#/c/130205/\n\n\nGood idea on avoiding general exception catching. I notice your function definition doesn\u0027t have the function as an arg. Is that just a typo or am I missing something?","commit_id":"da0221f6ff49562775bb864c8e6605be12785fc0"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"99ecde68dc5c19a36412b027f017e0672877c0ba","unresolved":false,"context_lines":[{"line_number":54,"context_line":"AUTO_DELETE_PORT_OWNERS \u003d [constants.DEVICE_OWNER_DHCP]"},{"line_number":55,"context_line":""},{"line_number":56,"context_line":""},{"line_number":57,"context_line":"def _retry_ip_allocation(f):"},{"line_number":58,"context_line":"    @functools.wraps(f)"},{"line_number":59,"context_line":"    def wrapper(*args, **kwargs):"},{"line_number":60,"context_line":"        for x in range(constants.DB_MAX_RETRIES):"}],"source_content_type":"text/x-python","patch_set":26,"id":"9aa7fdbe_1ebf55ab","line":57,"in_reply_to":"9aa7fdbe_747ed41a","updated":"2014-10-24 17:00:47.000000000","message":"thanks for the suggestion, done!","commit_id":"da0221f6ff49562775bb864c8e6605be12785fc0"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"cdb5a38fbb53999c015f331a51fe53a2fd8ddabe","unresolved":false,"context_lines":[{"line_number":58,"context_line":"    @functools.wraps(f)"},{"line_number":59,"context_line":"    def wrapper(*args, **kwargs):"},{"line_number":60,"context_line":"        for x in range(constants.DB_MAX_RETRIES):"},{"line_number":61,"context_line":"            try:"},{"line_number":62,"context_line":"                return f(*args, **kwargs)"},{"line_number":63,"context_line":"            except n_exc.IPAllocationFailure:"},{"line_number":64,"context_line":"                continue"}],"source_content_type":"text/x-python","patch_set":26,"id":"9aa7fdbe_613822a1","line":61,"updated":"2014-10-21 16:31:36.000000000","message":"see bug https://bugs.launchpad.net/neutron/+bug/1382064 , a transaction needs to be started before retrying otherwise with mysql backend, repeatable read transaction isolation level _try_generate_ip will fetch the same row over and over again","commit_id":"da0221f6ff49562775bb864c8e6605be12785fc0"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"efa89e6ff6637e555e5fc2168fd7077dd550518a","unresolved":false,"context_lines":[{"line_number":58,"context_line":"    @functools.wraps(f)"},{"line_number":59,"context_line":"    def wrapper(*args, **kwargs):"},{"line_number":60,"context_line":"        for x in range(constants.DB_MAX_RETRIES):"},{"line_number":61,"context_line":"            try:"},{"line_number":62,"context_line":"                return f(*args, **kwargs)"},{"line_number":63,"context_line":"            except n_exc.IPAllocationFailure:"},{"line_number":64,"context_line":"                continue"}],"source_content_type":"text/x-python","patch_set":26,"id":"9aa7fdbe_ee48165e","line":61,"in_reply_to":"9aa7fdbe_613822a1","updated":"2014-10-24 17:43:47.000000000","message":"To avoid this bug, in the next patch I start a transaction in every method affected","commit_id":"da0221f6ff49562775bb864c8e6605be12785fc0"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"d72dcb23b48778279f37f77145b64b172dd55134","unresolved":false,"context_lines":[{"line_number":75,"context_line":"                return f(*args, **kwargs)"},{"line_number":76,"context_line":"            except n_exc.RebuildAvailRangesFailure:"},{"line_number":77,"context_line":"                continue"},{"line_number":78,"context_line":"        raise n_exc.RebuildAvailRangesFailure"},{"line_number":79,"context_line":"    return wrapper"},{"line_number":80,"context_line":""},{"line_number":81,"context_line":""}],"source_content_type":"text/x-python","patch_set":26,"id":"9aa7fdbe_cf921df6","line":78,"updated":"2014-10-17 22:24:49.000000000","message":"I have a minor concern about losing exception context here.  I\u0027m just wondering if seeing this exception is going to cause some head scratching.  Just thinking out loud...\n\n  retry_times \u003d 3\n  for x in range(retry_times):\n      try:\n          return f(*args, **kwargs)\n      except n_exc.RebuildAvailRangesFailure:\n          with save_and_reraise_exception(reraise\u003dFalse) as ctxt:\n              ctxt.reraise \u003d (x \u003d\u003d retry_times - 1)\n\nMine doesn\u0027t look much better.  :|\n\nIf you\u0027re going to try only twice (as suggested below) you could write the wrapper method like this:\n\n  try:\n      return f(*args, **kwargs)\n  except n_exc.RebuildAvailRangesFailure:\n      # Tolerate one failure to avoid a race.\n      return f(*args, **kwargs)","commit_id":"da0221f6ff49562775bb864c8e6605be12785fc0"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"b6559a3ecbe38a15ea7d859891e3ccb8bda939c0","unresolved":false,"context_lines":[{"line_number":75,"context_line":"                return f(*args, **kwargs)"},{"line_number":76,"context_line":"            except n_exc.RebuildAvailRangesFailure:"},{"line_number":77,"context_line":"                continue"},{"line_number":78,"context_line":"        raise n_exc.RebuildAvailRangesFailure"},{"line_number":79,"context_line":"    return wrapper"},{"line_number":80,"context_line":""},{"line_number":81,"context_line":""}],"source_content_type":"text/x-python","patch_set":26,"id":"9aa7fdbe_0e8b9a68","line":78,"in_reply_to":"9aa7fdbe_9eea65aa","updated":"2014-10-24 17:59:10.000000000","message":"Great!","commit_id":"da0221f6ff49562775bb864c8e6605be12785fc0"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"99ecde68dc5c19a36412b027f017e0672877c0ba","unresolved":false,"context_lines":[{"line_number":75,"context_line":"                return f(*args, **kwargs)"},{"line_number":76,"context_line":"            except n_exc.RebuildAvailRangesFailure:"},{"line_number":77,"context_line":"                continue"},{"line_number":78,"context_line":"        raise n_exc.RebuildAvailRangesFailure"},{"line_number":79,"context_line":"    return wrapper"},{"line_number":80,"context_line":""},{"line_number":81,"context_line":""}],"source_content_type":"text/x-python","patch_set":26,"id":"9aa7fdbe_9eea65aa","line":78,"in_reply_to":"9aa7fdbe_cf921df6","updated":"2014-10-24 17:00:47.000000000","message":"I will apply your second suggestion, not this one","commit_id":"da0221f6ff49562775bb864c8e6605be12785fc0"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"d72dcb23b48778279f37f77145b64b172dd55134","unresolved":false,"context_lines":[{"line_number":317,"context_line":"        2) Process 2 checks for availability and sees there is none"},{"line_number":318,"context_line":"        3) Process 2 starts _rebuild_availability_ranges which queries the"},{"line_number":319,"context_line":"        IPAllocation table to calculate the new ranges. Since process 1 has not"},{"line_number":320,"context_line":"        stored the allocation, the IP that it got it\u0027s not taken into"},{"line_number":321,"context_line":"        consideration"},{"line_number":322,"context_line":"        4) Process 1 calls _store_ip_allocation"},{"line_number":323,"context_line":"        5) Process 2 store the available ranges calculated with stale data"}],"source_content_type":"text/x-python","patch_set":26,"id":"9aa7fdbe_b2361ee6","line":320,"updated":"2014-10-17 22:24:49.000000000","message":"nit:  s/it\u0027s/it/","commit_id":"da0221f6ff49562775bb864c8e6605be12785fc0"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"b6559a3ecbe38a15ea7d859891e3ccb8bda939c0","unresolved":false,"context_lines":[{"line_number":317,"context_line":"        2) Process 2 checks for availability and sees there is none"},{"line_number":318,"context_line":"        3) Process 2 starts _rebuild_availability_ranges which queries the"},{"line_number":319,"context_line":"        IPAllocation table to calculate the new ranges. Since process 1 has not"},{"line_number":320,"context_line":"        stored the allocation, the IP that it got it\u0027s not taken into"},{"line_number":321,"context_line":"        consideration"},{"line_number":322,"context_line":"        4) Process 1 calls _store_ip_allocation"},{"line_number":323,"context_line":"        5) Process 2 store the available ranges calculated with stale data"}],"source_content_type":"text/x-python","patch_set":26,"id":"9aa7fdbe_aede0e6b","line":320,"in_reply_to":"9aa7fdbe_1ed675f1","updated":"2014-10-24 17:59:10.000000000","message":"You\u0027re right.  My correction needed correction.  \u0027is\u0027 is correct.","commit_id":"da0221f6ff49562775bb864c8e6605be12785fc0"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"99ecde68dc5c19a36412b027f017e0672877c0ba","unresolved":false,"context_lines":[{"line_number":317,"context_line":"        2) Process 2 checks for availability and sees there is none"},{"line_number":318,"context_line":"        3) Process 2 starts _rebuild_availability_ranges which queries the"},{"line_number":319,"context_line":"        IPAllocation table to calculate the new ranges. Since process 1 has not"},{"line_number":320,"context_line":"        stored the allocation, the IP that it got it\u0027s not taken into"},{"line_number":321,"context_line":"        consideration"},{"line_number":322,"context_line":"        4) Process 1 calls _store_ip_allocation"},{"line_number":323,"context_line":"        5) Process 2 store the available ranges calculated with stale data"}],"source_content_type":"text/x-python","patch_set":26,"id":"9aa7fdbe_1ed675f1","line":320,"in_reply_to":"9aa7fdbe_b2361ee6","updated":"2014-10-24 17:00:47.000000000","message":"I guess you meant \u0027is\u0027...feel free to correct me again","commit_id":"da0221f6ff49562775bb864c8e6605be12785fc0"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"b0d141c9c7441c47615bc7960667811295b2029a","unresolved":false,"context_lines":[{"line_number":362,"context_line":"                        yield netaddr.IPRange(first, last)"},{"line_number":363,"context_line":""},{"line_number":364,"context_line":"                # Write the ranges to the db"},{"line_number":365,"context_line":"                context.session.begin(subtransactions\u003dTrue)"},{"line_number":366,"context_line":"                try:"},{"line_number":367,"context_line":"                    for ip_range in ipset_to_ranges(available):"},{"line_number":368,"context_line":"                        available_range \u003d models_v2.IPAvailabilityRange("}],"source_content_type":"text/x-python","patch_set":26,"id":"9aa7fdbe_691b7b1b","line":365,"updated":"2014-10-22 20:57:04.000000000","message":"the context manager handles what you are doing manually with the rollback and commit logic\n\nwith context.session.begin(subtransactions\u003dTrue):\n\nremove L366, L376, L378, and L379","commit_id":"da0221f6ff49562775bb864c8e6605be12785fc0"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"99ecde68dc5c19a36412b027f017e0672877c0ba","unresolved":false,"context_lines":[{"line_number":362,"context_line":"                        yield netaddr.IPRange(first, last)"},{"line_number":363,"context_line":""},{"line_number":364,"context_line":"                # Write the ranges to the db"},{"line_number":365,"context_line":"                context.session.begin(subtransactions\u003dTrue)"},{"line_number":366,"context_line":"                try:"},{"line_number":367,"context_line":"                    for ip_range in ipset_to_ranges(available):"},{"line_number":368,"context_line":"                        available_range \u003d models_v2.IPAvailabilityRange("}],"source_content_type":"text/x-python","patch_set":26,"id":"9aa7fdbe_cf26f9cd","line":365,"in_reply_to":"9aa7fdbe_691b7b1b","updated":"2014-10-24 17:00:47.000000000","message":"Even if I use a context manager, it wouldn\u0027t rollback the session after line 379 since DBDuplicateEntry is caught and it¡s not re-thrown. That\u0027s why I preferred to call session.commit() and session.rollback() explicitly in this function and  I avoided using the context manager, it seemed more clear to me. What do you think?","commit_id":"da0221f6ff49562775bb864c8e6605be12785fc0"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"b6559a3ecbe38a15ea7d859891e3ccb8bda939c0","unresolved":false,"context_lines":[{"line_number":362,"context_line":"                        yield netaddr.IPRange(first, last)"},{"line_number":363,"context_line":""},{"line_number":364,"context_line":"                # Write the ranges to the db"},{"line_number":365,"context_line":"                context.session.begin(subtransactions\u003dTrue)"},{"line_number":366,"context_line":"                try:"},{"line_number":367,"context_line":"                    for ip_range in ipset_to_ranges(available):"},{"line_number":368,"context_line":"                        available_range \u003d models_v2.IPAvailabilityRange("}],"source_content_type":"text/x-python","patch_set":26,"id":"9aa7fdbe_8eb78af4","line":365,"in_reply_to":"9aa7fdbe_cf26f9cd","updated":"2014-10-24 17:59:10.000000000","message":"Hmmm.  I didn\u0027t notice this.  Thanks for pointing it out, Kevin.  I\u0027m concerned that the lack of a context manager may leave us vulnerable to situations where the session is not properly handled/closed due to an unforeseen exception.\n\nI think I\u0027d lean toward using the context manager and ensuring that an exception is thrown in any situation where a rollback should occur.  That might mean refactoring this code in to a method that you surround with try/except.\n\nThe rollback on L376 should be correctly handled with the raise of RebuildAvailRangesFailure within a context manager.  However, the rollback on L380 probably needs to be changed to an exception raised and caught outside of the context manager (hence the refactoring in to a new method so that you don\u0027t have to surround the entire block of code with try/except).","commit_id":"da0221f6ff49562775bb864c8e6605be12785fc0"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"efa89e6ff6637e555e5fc2168fd7077dd550518a","unresolved":false,"context_lines":[{"line_number":362,"context_line":"                        yield netaddr.IPRange(first, last)"},{"line_number":363,"context_line":""},{"line_number":364,"context_line":"                # Write the ranges to the db"},{"line_number":365,"context_line":"                context.session.begin(subtransactions\u003dTrue)"},{"line_number":366,"context_line":"                try:"},{"line_number":367,"context_line":"                    for ip_range in ipset_to_ranges(available):"},{"line_number":368,"context_line":"                        available_range \u003d models_v2.IPAvailabilityRange("}],"source_content_type":"text/x-python","patch_set":26,"id":"9aa7fdbe_4e7be28b","line":365,"in_reply_to":"9aa7fdbe_cf26f9cd","updated":"2014-10-24 17:43:47.000000000","message":"Kevin I decided to add the context manager, the rollback call at line 380 should stay for the reason explained in my previous comment","commit_id":"da0221f6ff49562775bb864c8e6605be12785fc0"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"d72dcb23b48778279f37f77145b64b172dd55134","unresolved":false,"context_lines":[{"line_number":372,"context_line":"                        context.session.add(available_range)"},{"line_number":373,"context_line":"                    new_allocations_count \u003d ip_qry.filter_by("},{"line_number":374,"context_line":"                        subnet_id\u003dsubnet[\u0027id\u0027]).count()"},{"line_number":375,"context_line":"                    if allocations_count !\u003d new_allocations_count:"},{"line_number":376,"context_line":"                        context.session.rollback()"},{"line_number":377,"context_line":"                        raise n_exc.RebuildAvailRangesFailure"},{"line_number":378,"context_line":"                    context.session.commit()"}],"source_content_type":"text/x-python","patch_set":26,"id":"9aa7fdbe_f230a6ea","line":375,"updated":"2014-10-17 22:24:49.000000000","message":"nit:  Maybe call these allocations_before and allocations_after.","commit_id":"da0221f6ff49562775bb864c8e6605be12785fc0"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"99ecde68dc5c19a36412b027f017e0672877c0ba","unresolved":false,"context_lines":[{"line_number":372,"context_line":"                        context.session.add(available_range)"},{"line_number":373,"context_line":"                    new_allocations_count \u003d ip_qry.filter_by("},{"line_number":374,"context_line":"                        subnet_id\u003dsubnet[\u0027id\u0027]).count()"},{"line_number":375,"context_line":"                    if allocations_count !\u003d new_allocations_count:"},{"line_number":376,"context_line":"                        context.session.rollback()"},{"line_number":377,"context_line":"                        raise n_exc.RebuildAvailRangesFailure"},{"line_number":378,"context_line":"                    context.session.commit()"}],"source_content_type":"text/x-python","patch_set":26,"id":"9aa7fdbe_cf0d1940","line":375,"in_reply_to":"9aa7fdbe_f230a6ea","updated":"2014-10-24 17:00:47.000000000","message":"Done","commit_id":"da0221f6ff49562775bb864c8e6605be12785fc0"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"d72dcb23b48778279f37f77145b64b172dd55134","unresolved":false,"context_lines":[{"line_number":373,"context_line":"                    new_allocations_count \u003d ip_qry.filter_by("},{"line_number":374,"context_line":"                        subnet_id\u003dsubnet[\u0027id\u0027]).count()"},{"line_number":375,"context_line":"                    if allocations_count !\u003d new_allocations_count:"},{"line_number":376,"context_line":"                        context.session.rollback()"},{"line_number":377,"context_line":"                        raise n_exc.RebuildAvailRangesFailure"},{"line_number":378,"context_line":"                    context.session.commit()"},{"line_number":379,"context_line":"                except db_exc.DBDuplicateEntry:"}],"source_content_type":"text/x-python","patch_set":26,"id":"9aa7fdbe_cf9e9d63","line":376,"updated":"2014-10-17 22:24:49.000000000","message":"Is this necessary here?","commit_id":"da0221f6ff49562775bb864c8e6605be12785fc0"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"efa89e6ff6637e555e5fc2168fd7077dd550518a","unresolved":false,"context_lines":[{"line_number":373,"context_line":"                    new_allocations_count \u003d ip_qry.filter_by("},{"line_number":374,"context_line":"                        subnet_id\u003dsubnet[\u0027id\u0027]).count()"},{"line_number":375,"context_line":"                    if allocations_count !\u003d new_allocations_count:"},{"line_number":376,"context_line":"                        context.session.rollback()"},{"line_number":377,"context_line":"                        raise n_exc.RebuildAvailRangesFailure"},{"line_number":378,"context_line":"                    context.session.commit()"},{"line_number":379,"context_line":"                except db_exc.DBDuplicateEntry:"}],"source_content_type":"text/x-python","patch_set":26,"id":"9aa7fdbe_ae97ee8e","line":376,"in_reply_to":"9aa7fdbe_6a2dfb94","updated":"2014-10-24 17:43:47.000000000","message":"Anyway I removed it in the next patch since I added the \"with context.session.begin(subtransactions\u003dTrue)\"","commit_id":"da0221f6ff49562775bb864c8e6605be12785fc0"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"b6559a3ecbe38a15ea7d859891e3ccb8bda939c0","unresolved":false,"context_lines":[{"line_number":373,"context_line":"                    new_allocations_count \u003d ip_qry.filter_by("},{"line_number":374,"context_line":"                        subnet_id\u003dsubnet[\u0027id\u0027]).count()"},{"line_number":375,"context_line":"                    if allocations_count !\u003d new_allocations_count:"},{"line_number":376,"context_line":"                        context.session.rollback()"},{"line_number":377,"context_line":"                        raise n_exc.RebuildAvailRangesFailure"},{"line_number":378,"context_line":"                    context.session.commit()"},{"line_number":379,"context_line":"                except db_exc.DBDuplicateEntry:"}],"source_content_type":"text/x-python","patch_set":26,"id":"9aa7fdbe_cecc328c","line":376,"in_reply_to":"9aa7fdbe_6a2dfb94","updated":"2014-10-24 17:59:10.000000000","message":"The discussion of the context manager clears this up for me.","commit_id":"da0221f6ff49562775bb864c8e6605be12785fc0"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"99ecde68dc5c19a36412b027f017e0672877c0ba","unresolved":false,"context_lines":[{"line_number":373,"context_line":"                    new_allocations_count \u003d ip_qry.filter_by("},{"line_number":374,"context_line":"                        subnet_id\u003dsubnet[\u0027id\u0027]).count()"},{"line_number":375,"context_line":"                    if allocations_count !\u003d new_allocations_count:"},{"line_number":376,"context_line":"                        context.session.rollback()"},{"line_number":377,"context_line":"                        raise n_exc.RebuildAvailRangesFailure"},{"line_number":378,"context_line":"                    context.session.commit()"},{"line_number":379,"context_line":"                except db_exc.DBDuplicateEntry:"}],"source_content_type":"text/x-python","patch_set":26,"id":"9aa7fdbe_6a2dfb94","line":376,"in_reply_to":"9aa7fdbe_cf9e9d63","updated":"2014-10-24 17:00:47.000000000","message":"I think so, if it\u0027s the first trial @_retry_rebuild_ranges will trigger this function again and there would be no call to session.rollback() in between the 2 trials.","commit_id":"da0221f6ff49562775bb864c8e6605be12785fc0"},{"author":{"_account_id":7183,"name":"Xu Han Peng","email":"xuhanp@linux.vnet.ibm.com","username":"xuhanp"},"change_message_id":"ae99094c1427294eab01327332831e297d665cbb","unresolved":false,"context_lines":[{"line_number":374,"context_line":"                        subnet_id\u003dsubnet[\u0027id\u0027]).count()"},{"line_number":375,"context_line":"                    if allocations_count !\u003d new_allocations_count:"},{"line_number":376,"context_line":"                        context.session.rollback()"},{"line_number":377,"context_line":"                        raise n_exc.RebuildAvailRangesFailure"},{"line_number":378,"context_line":"                    context.session.commit()"},{"line_number":379,"context_line":"                except db_exc.DBDuplicateEntry:"},{"line_number":380,"context_line":"                    context.session.rollback()"}],"source_content_type":"text/x-python","patch_set":26,"id":"baa201ad_ca3cfd95","line":377,"updated":"2014-10-17 07:45:06.000000000","message":"Looks like we only will retry 3 times when RebuildAvailRangesFailure happens here. Does it mean we only allow 3 times of process conflicts at maximum and Neutron will stop working after that? This looks a little risky too me.","commit_id":"da0221f6ff49562775bb864c8e6605be12785fc0"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"99ecde68dc5c19a36412b027f017e0672877c0ba","unresolved":false,"context_lines":[{"line_number":374,"context_line":"                        subnet_id\u003dsubnet[\u0027id\u0027]).count()"},{"line_number":375,"context_line":"                    if allocations_count !\u003d new_allocations_count:"},{"line_number":376,"context_line":"                        context.session.rollback()"},{"line_number":377,"context_line":"                        raise n_exc.RebuildAvailRangesFailure"},{"line_number":378,"context_line":"                    context.session.commit()"},{"line_number":379,"context_line":"                except db_exc.DBDuplicateEntry:"},{"line_number":380,"context_line":"                    context.session.rollback()"}],"source_content_type":"text/x-python","patch_set":26,"id":"9aa7fdbe_5ece3d2f","line":377,"in_reply_to":"9aa7fdbe_5d6336b1","updated":"2014-10-24 17:00:47.000000000","message":"i don\u0027t think it\u0027s needed, the exception message will be printed anyway","commit_id":"da0221f6ff49562775bb864c8e6605be12785fc0"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"b6559a3ecbe38a15ea7d859891e3ccb8bda939c0","unresolved":false,"context_lines":[{"line_number":374,"context_line":"                        subnet_id\u003dsubnet[\u0027id\u0027]).count()"},{"line_number":375,"context_line":"                    if allocations_count !\u003d new_allocations_count:"},{"line_number":376,"context_line":"                        context.session.rollback()"},{"line_number":377,"context_line":"                        raise n_exc.RebuildAvailRangesFailure"},{"line_number":378,"context_line":"                    context.session.commit()"},{"line_number":379,"context_line":"                except db_exc.DBDuplicateEntry:"},{"line_number":380,"context_line":"                    context.session.rollback()"}],"source_content_type":"text/x-python","patch_set":26,"id":"9aa7fdbe_8e85ca08","line":377,"in_reply_to":"9aa7fdbe_5ece3d2f","updated":"2014-10-24 17:59:10.000000000","message":"+1 Rossella","commit_id":"da0221f6ff49562775bb864c8e6605be12785fc0"},{"author":{"_account_id":7183,"name":"Xu Han Peng","email":"xuhanp@linux.vnet.ibm.com","username":"xuhanp"},"change_message_id":"8cf624bcb3e244eaeb1a8176abda490d60e4be8e","unresolved":false,"context_lines":[{"line_number":374,"context_line":"                        subnet_id\u003dsubnet[\u0027id\u0027]).count()"},{"line_number":375,"context_line":"                    if allocations_count !\u003d new_allocations_count:"},{"line_number":376,"context_line":"                        context.session.rollback()"},{"line_number":377,"context_line":"                        raise n_exc.RebuildAvailRangesFailure"},{"line_number":378,"context_line":"                    context.session.commit()"},{"line_number":379,"context_line":"                except db_exc.DBDuplicateEntry:"},{"line_number":380,"context_line":"                    context.session.rollback()"}],"source_content_type":"text/x-python","patch_set":26,"id":"9aa7fdbe_5d6336b1","line":377,"in_reply_to":"9aa7fdbe_6fb051f5","updated":"2014-10-20 05:48:22.000000000","message":"Rossella, I didn\u0027t see RebuildAvailRangesFailure being caught other than _retry_rebuild_ranges. Should this be taken care by create_port, and prompt clear error message?","commit_id":"da0221f6ff49562775bb864c8e6605be12785fc0"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"d72dcb23b48778279f37f77145b64b172dd55134","unresolved":false,"context_lines":[{"line_number":374,"context_line":"                        subnet_id\u003dsubnet[\u0027id\u0027]).count()"},{"line_number":375,"context_line":"                    if allocations_count !\u003d new_allocations_count:"},{"line_number":376,"context_line":"                        context.session.rollback()"},{"line_number":377,"context_line":"                        raise n_exc.RebuildAvailRangesFailure"},{"line_number":378,"context_line":"                    context.session.commit()"},{"line_number":379,"context_line":"                except db_exc.DBDuplicateEntry:"},{"line_number":380,"context_line":"                    context.session.rollback()"}],"source_content_type":"text/x-python","patch_set":26,"id":"9aa7fdbe_6fb051f5","line":377,"in_reply_to":"baa201ad_5fb7e539","updated":"2014-10-17 22:24:49.000000000","message":"Agree with Rossella\u0027s assessment here.","commit_id":"da0221f6ff49562775bb864c8e6605be12785fc0"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"815f0a6a9ede6fd9a87d1b825b915b74c5e69f56","unresolved":false,"context_lines":[{"line_number":374,"context_line":"                        subnet_id\u003dsubnet[\u0027id\u0027]).count()"},{"line_number":375,"context_line":"                    if allocations_count !\u003d new_allocations_count:"},{"line_number":376,"context_line":"                        context.session.rollback()"},{"line_number":377,"context_line":"                        raise n_exc.RebuildAvailRangesFailure"},{"line_number":378,"context_line":"                    context.session.commit()"},{"line_number":379,"context_line":"                except db_exc.DBDuplicateEntry:"},{"line_number":380,"context_line":"                    context.session.rollback()"}],"source_content_type":"text/x-python","patch_set":26,"id":"baa201ad_5fb7e539","line":377,"in_reply_to":"baa201ad_ca3cfd95","updated":"2014-10-17 12:38:14.000000000","message":"Thanks for your comment. Locking at it again, 3 time is even too much. Here I wouldn\u0027t say it\u0027s a conflict, it\u0027s a race and a very specific one, see lines 309-328 for more details. This race can happen only when the last IP of the range is allocated, cannot be allocated twice. So TBH retrying one time should be already enough. Neutron won\u0027t stop working, at worse the create port that triggered this method will fail but it shouldn\u0027t happen.","commit_id":"da0221f6ff49562775bb864c8e6605be12785fc0"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"d72dcb23b48778279f37f77145b64b172dd55134","unresolved":false,"context_lines":[{"line_number":425,"context_line":"                    new_first_ip \u003d str(netaddr.IPAddress(ip_address) + 1)"},{"line_number":426,"context_line":"                    new_ip_range \u003d models_v2.IPAvailabilityRange("},{"line_number":427,"context_line":"                        allocation_pool_id\u003dip_range["},{"line_number":428,"context_line":"                            \u0027allocation_pool_id\u0027],"},{"line_number":429,"context_line":"                        first_ip\u003dnew_first_ip,"},{"line_number":430,"context_line":"                        last_ip\u003dold_last_ip)"},{"line_number":431,"context_line":"                    context.session.add(new_ip_range)"}],"source_content_type":"text/x-python","patch_set":26,"id":"9aa7fdbe_b23d3ebe","line":428,"updated":"2014-10-17 22:24:49.000000000","message":"nit:  doesn\u0027t need to be wrapped here.","commit_id":"da0221f6ff49562775bb864c8e6605be12785fc0"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"99ecde68dc5c19a36412b027f017e0672877c0ba","unresolved":false,"context_lines":[{"line_number":425,"context_line":"                    new_first_ip \u003d str(netaddr.IPAddress(ip_address) + 1)"},{"line_number":426,"context_line":"                    new_ip_range \u003d models_v2.IPAvailabilityRange("},{"line_number":427,"context_line":"                        allocation_pool_id\u003dip_range["},{"line_number":428,"context_line":"                            \u0027allocation_pool_id\u0027],"},{"line_number":429,"context_line":"                        first_ip\u003dnew_first_ip,"},{"line_number":430,"context_line":"                        last_ip\u003dold_last_ip)"},{"line_number":431,"context_line":"                    context.session.add(new_ip_range)"}],"source_content_type":"text/x-python","patch_set":26,"id":"9aa7fdbe_fee2919e","line":428,"in_reply_to":"9aa7fdbe_b23d3ebe","updated":"2014-10-24 17:00:47.000000000","message":"Done","commit_id":"da0221f6ff49562775bb864c8e6605be12785fc0"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"bfabdf0b0a09d355257c45731fc9a837fb70387b","unresolved":false,"context_lines":[{"line_number":57,"context_line":"    def wrap(f):"},{"line_number":58,"context_line":"        @functools.wraps(f)"},{"line_number":59,"context_line":"        def wrapper(*args, **kwargs):"},{"line_number":60,"context_line":"            for x in range(maxtries - 1):"},{"line_number":61,"context_line":"                try:"},{"line_number":62,"context_line":"                    return f(*args, **kwargs)"},{"line_number":63,"context_line":"                except exception_type:"}],"source_content_type":"text/x-python","patch_set":27,"id":"9aa7fdbe_7e3f1dd7","line":60,"updated":"2014-10-29 05:34:17.000000000","message":"Just call the parameter maxretries and then make this range(maxretries) to match the constant name.","commit_id":"abdb26cb94d79a8f750034efd8f460f24900f316"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"2e4a295bef6fd78f451723a06cc7bd09088ddf1d","unresolved":false,"context_lines":[{"line_number":57,"context_line":"    def wrap(f):"},{"line_number":58,"context_line":"        @functools.wraps(f)"},{"line_number":59,"context_line":"        def wrapper(*args, **kwargs):"},{"line_number":60,"context_line":"            for x in range(maxtries - 1):"},{"line_number":61,"context_line":"                try:"},{"line_number":62,"context_line":"                    return f(*args, **kwargs)"},{"line_number":63,"context_line":"                except exception_type:"}],"source_content_type":"text/x-python","patch_set":27,"id":"9aa7fdbe_4af1a494","line":60,"in_reply_to":"9aa7fdbe_7e3f1dd7","updated":"2014-10-29 17:54:02.000000000","message":"renamed but range(maxtries - 1) is ok since it\u0027s retried once more at line 65 or maybe I am misunderstanding your comment here","commit_id":"abdb26cb94d79a8f750034efd8f460f24900f316"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"bfabdf0b0a09d355257c45731fc9a837fb70387b","unresolved":false,"context_lines":[{"line_number":286,"context_line":"        raise n_exc.IpAddressGenerationFailure(net_id\u003dsubnets[0][\u0027network_id\u0027])"},{"line_number":287,"context_line":""},{"line_number":288,"context_line":"    @staticmethod"},{"line_number":289,"context_line":"    @_retry_function(n_exc.RebuildAvailRangesFailure, 2)"},{"line_number":290,"context_line":"    def _rebuild_availability_ranges(context, subnets):"},{"line_number":291,"context_line":"        \"\"\"Rebuild availability ranges."},{"line_number":292,"context_line":""}],"source_content_type":"text/x-python","patch_set":27,"id":"9aa7fdbe_9e23e1bd","line":289,"updated":"2014-10-29 05:34:17.000000000","message":"Can you make it a constant at the top or a named parameter so it\u0027s easy to see what the number does?","commit_id":"abdb26cb94d79a8f750034efd8f460f24900f316"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"2e4a295bef6fd78f451723a06cc7bd09088ddf1d","unresolved":false,"context_lines":[{"line_number":286,"context_line":"        raise n_exc.IpAddressGenerationFailure(net_id\u003dsubnets[0][\u0027network_id\u0027])"},{"line_number":287,"context_line":""},{"line_number":288,"context_line":"    @staticmethod"},{"line_number":289,"context_line":"    @_retry_function(n_exc.RebuildAvailRangesFailure, 2)"},{"line_number":290,"context_line":"    def _rebuild_availability_ranges(context, subnets):"},{"line_number":291,"context_line":"        \"\"\"Rebuild availability ranges."},{"line_number":292,"context_line":""}],"source_content_type":"text/x-python","patch_set":27,"id":"9aa7fdbe_6aee68b6","line":289,"in_reply_to":"9aa7fdbe_9e23e1bd","updated":"2014-10-29 17:54:02.000000000","message":"Done","commit_id":"abdb26cb94d79a8f750034efd8f460f24900f316"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"cb03a103a76bda9182f8d160ef625a26c85eba91","unresolved":false,"context_lines":[{"line_number":367,"context_line":"                        if allocations_before !\u003d allocations_after:"},{"line_number":368,"context_line":"                            raise n_exc.RebuildAvailRangesFailure"},{"line_number":369,"context_line":"                    except db_exc.DBDuplicateEntry:"},{"line_number":370,"context_line":"                        context.session.rollback()"},{"line_number":371,"context_line":"                        LOG.debug(\"A concurrent _rebuild_availability_ranges\""},{"line_number":372,"context_line":"                                \" had already added this range\")"},{"line_number":373,"context_line":""}],"source_content_type":"text/x-python","patch_set":27,"id":"9aa7fdbe_4e0cc2ed","line":370,"updated":"2014-10-24 17:52:44.000000000","message":"I am noticing only now that should skip checking the other subnets at this point. return should be added at line 373","commit_id":"abdb26cb94d79a8f750034efd8f460f24900f316"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"7556cd8e79f8a12b8d014b81e2b8a8c9c6a77be2","unresolved":false,"context_lines":[{"line_number":367,"context_line":"                        if allocations_before !\u003d allocations_after:"},{"line_number":368,"context_line":"                            raise n_exc.RebuildAvailRangesFailure"},{"line_number":369,"context_line":"                    except db_exc.DBDuplicateEntry:"},{"line_number":370,"context_line":"                        context.session.rollback()"},{"line_number":371,"context_line":"                        LOG.debug(\"A concurrent _rebuild_availability_ranges\""},{"line_number":372,"context_line":"                                \" had already added this range\")"},{"line_number":373,"context_line":""}],"source_content_type":"text/x-python","patch_set":27,"id":"9aa7fdbe_9c7f8ddf","line":370,"in_reply_to":"9aa7fdbe_4e0cc2ed","updated":"2014-10-28 05:48:12.000000000","message":"What happens if you call rollback here and then return?  The context manager will call commit immediately after you called rollback, right?  Will that be a problem?\n\nI was thinking that this exception would unwind past the context manager on L320 instead of calling rollback explicitly here.  You could move this try/except to surround L224 and I think all would be well.","commit_id":"abdb26cb94d79a8f750034efd8f460f24900f316"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"2e4a295bef6fd78f451723a06cc7bd09088ddf1d","unresolved":false,"context_lines":[{"line_number":367,"context_line":"                        if allocations_before !\u003d allocations_after:"},{"line_number":368,"context_line":"                            raise n_exc.RebuildAvailRangesFailure"},{"line_number":369,"context_line":"                    except db_exc.DBDuplicateEntry:"},{"line_number":370,"context_line":"                        context.session.rollback()"},{"line_number":371,"context_line":"                        LOG.debug(\"A concurrent _rebuild_availability_ranges\""},{"line_number":372,"context_line":"                                \" had already added this range\")"},{"line_number":373,"context_line":""}],"source_content_type":"text/x-python","patch_set":27,"id":"9aa7fdbe_6a1ca8c2","line":370,"in_reply_to":"9aa7fdbe_9c7f8ddf","updated":"2014-10-29 17:54:02.000000000","message":"I agree with you, thanks. I will move the try/catch outside the transaction","commit_id":"abdb26cb94d79a8f750034efd8f460f24900f316"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"5141d5d30eecfc086eb8d79cc3db5f3fd925b3fc","unresolved":false,"context_lines":[{"line_number":239,"context_line":"        The IP address will be generated from one of the subnets defined on"},{"line_number":240,"context_line":"        the network."},{"line_number":241,"context_line":"        \"\"\""},{"line_number":242,"context_line":"        with context.session.begin(subtransactions\u003dTrue):"},{"line_number":243,"context_line":"            range_qry \u003d context.session.query("},{"line_number":244,"context_line":"                models_v2.IPAvailabilityRange).join("},{"line_number":245,"context_line":"                models_v2.IPAllocationPool)"}],"source_content_type":"text/x-python","patch_set":29,"id":"5a890539_f426b267","line":242,"updated":"2014-11-10 22:55:22.000000000","message":"no real need of the context manager here, will remove it","commit_id":"83ea055f374af183fd39f4fafedde384e78dd7e7"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"5141d5d30eecfc086eb8d79cc3db5f3fd925b3fc","unresolved":false,"context_lines":[{"line_number":378,"context_line":"                              port_id):"},{"line_number":379,"context_line":"        \"\"\"Allocate a specific IP address on the subnet.\"\"\""},{"line_number":380,"context_line":"        ip \u003d int(netaddr.IPAddress(ip_address))"},{"line_number":381,"context_line":"        with context.session.begin(subtransactions\u003dTrue):"},{"line_number":382,"context_line":"            range_qry \u003d context.session.query("},{"line_number":383,"context_line":"                models_v2.IPAvailabilityRange).join("},{"line_number":384,"context_line":"                    models_v2.IPAllocationPool)"}],"source_content_type":"text/x-python","patch_set":29,"id":"5a890539_54f6a6d8","line":381,"updated":"2014-11-10 22:55:22.000000000","message":"no real need of the context manager here, will remove it","commit_id":"83ea055f374af183fd39f4fafedde384e78dd7e7"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"501b77bec3f4ce1f228599f16c1fc5a90b524130","unresolved":false,"context_lines":[{"line_number":241,"context_line":"            ip_range \u003d range_qry.filter_by(subnet_id\u003dsubnet[\u0027id\u0027]).first()"},{"line_number":242,"context_line":"            if not ip_range:"},{"line_number":243,"context_line":"                LOG.debug(\"All IPs from subnet %(subnet_id)s (%(cidr)s) \""},{"line_number":244,"context_line":"                    \"allocated\","},{"line_number":245,"context_line":"                    {\u0027subnet_id\u0027: subnet[\u0027id\u0027],"},{"line_number":246,"context_line":"                        \u0027cidr\u0027: subnet[\u0027cidr\u0027]})"},{"line_number":247,"context_line":"                continue"}],"source_content_type":"text/x-python","patch_set":31,"id":"5a890539_ff80e2f8","line":244,"updated":"2014-11-14 00:26:27.000000000","message":"nit:  This indentation now looks wrong.","commit_id":"bc5e7adb6ef75cc4a457d1f2ebad3c7e49ef7499"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"501b77bec3f4ce1f228599f16c1fc5a90b524130","unresolved":false,"context_lines":[{"line_number":256,"context_line":"            if ip_range[\u0027first_ip\u0027] \u003d\u003d ip_range[\u0027last_ip\u0027]:"},{"line_number":257,"context_line":"                # No more free indices on subnet \u003d\u003e delete"},{"line_number":258,"context_line":"                LOG.debug(\"No more free IP\u0027s in slice. Deleting \""},{"line_number":259,"context_line":"                        \"allocation pool.\")"},{"line_number":260,"context_line":"                NeutronDbPluginV2._check_update_is_successful("},{"line_number":261,"context_line":"                    check_update_query.delete)"},{"line_number":262,"context_line":"            else:"}],"source_content_type":"text/x-python","patch_set":31,"id":"5a890539_7f74f235","line":259,"updated":"2014-11-14 00:26:27.000000000","message":"ditto","commit_id":"bc5e7adb6ef75cc4a457d1f2ebad3c7e49ef7499"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"501b77bec3f4ce1f228599f16c1fc5a90b524130","unresolved":false,"context_lines":[{"line_number":266,"context_line":"                    check_update_query.update, {\"first_ip\": new_first_ip})"},{"line_number":267,"context_line":""},{"line_number":268,"context_line":"            LOG.debug(\"Allocated IP - %(ip_address)s from %(first_ip)s \""},{"line_number":269,"context_line":"                    \"to %(last_ip)s\","},{"line_number":270,"context_line":"                    {\u0027ip_address\u0027: ip_address,"},{"line_number":271,"context_line":"                    \u0027first_ip\u0027: ip_address,"},{"line_number":272,"context_line":"                    \u0027last_ip\u0027: ip_range[\u0027last_ip\u0027]})"}],"source_content_type":"text/x-python","patch_set":31,"id":"5a890539_bf91fa48","line":269,"updated":"2014-11-14 00:26:27.000000000","message":"ditto","commit_id":"bc5e7adb6ef75cc4a457d1f2ebad3c7e49ef7499"}],"neutron/tests/unit/test_db_plugin.py":[{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"6d423794bea30109d0651405bd6510e3bbfd8a15","unresolved":false,"context_lines":[{"line_number":3941,"context_line":"                context, [subnet], port_id)"},{"line_number":3942,"context_line":"        self.assertEqual(constants.DB_MAX_RETRIES,"},{"line_number":3943,"context_line":"                         len(check_update_query.mock_calls))"},{"line_number":3944,"context_line":"        self.assertEqual(0, store_ip.call_count)"},{"line_number":3945,"context_line":""},{"line_number":3946,"context_line":"    def _test_allocated_specific_ip(self, raises\u003dFalse):"},{"line_number":3947,"context_line":"        ip \u003d \"10.10.10.3\""}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_f10d34e9","line":3944,"updated":"2014-09-14 09:25:47.000000000","message":"self.assertFalse(store_ip.called)","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"ec9893b7c990d151abbf9d70d5ee0ce1551c87e3","unresolved":false,"context_lines":[{"line_number":3941,"context_line":"                context, [subnet], port_id)"},{"line_number":3942,"context_line":"        self.assertEqual(constants.DB_MAX_RETRIES,"},{"line_number":3943,"context_line":"                         len(check_update_query.mock_calls))"},{"line_number":3944,"context_line":"        self.assertEqual(0, store_ip.call_count)"},{"line_number":3945,"context_line":""},{"line_number":3946,"context_line":"    def _test_allocated_specific_ip(self, raises\u003dFalse):"},{"line_number":3947,"context_line":"        ip \u003d \"10.10.10.3\""}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_85cfc9b2","line":3944,"in_reply_to":"fa98f980_f10d34e9","updated":"2014-09-18 16:09:58.000000000","message":"Thanks","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"6d423794bea30109d0651405bd6510e3bbfd8a15","unresolved":false,"context_lines":[{"line_number":3973,"context_line":"                    context, subnet[\u0027id\u0027], ip, subnet[\u0027network_id\u0027], port_id)"},{"line_number":3974,"context_line":"                self.assertEqual(constants.DB_MAX_RETRIES,"},{"line_number":3975,"context_line":"                                 len(check_update_query.mock_calls))"},{"line_number":3976,"context_line":"                self.assertEqual(0, store_ip.call_count)"},{"line_number":3977,"context_line":"            else:"},{"line_number":3978,"context_line":"                db_base_plugin_v2.NeutronDbPluginV2._allocate_specific_ip("},{"line_number":3979,"context_line":"                    context, subnet[\u0027id\u0027], ip, subnet[\u0027network_id\u0027], port_id)"}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_d13110a3","line":3976,"updated":"2014-09-14 09:25:47.000000000","message":"self.assertFalse(store_ip.called)","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"ec9893b7c990d151abbf9d70d5ee0ce1551c87e3","unresolved":false,"context_lines":[{"line_number":3973,"context_line":"                    context, subnet[\u0027id\u0027], ip, subnet[\u0027network_id\u0027], port_id)"},{"line_number":3974,"context_line":"                self.assertEqual(constants.DB_MAX_RETRIES,"},{"line_number":3975,"context_line":"                                 len(check_update_query.mock_calls))"},{"line_number":3976,"context_line":"                self.assertEqual(0, store_ip.call_count)"},{"line_number":3977,"context_line":"            else:"},{"line_number":3978,"context_line":"                db_base_plugin_v2.NeutronDbPluginV2._allocate_specific_ip("},{"line_number":3979,"context_line":"                    context, subnet[\u0027id\u0027], ip, subnet[\u0027network_id\u0027], port_id)"}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_054af926","line":3976,"in_reply_to":"fa98f980_d13110a3","updated":"2014-09-18 16:09:58.000000000","message":"Done","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"6d423794bea30109d0651405bd6510e3bbfd8a15","unresolved":false,"context_lines":[{"line_number":3985,"context_line":"                self.assertEqual(2, len(check_update_query.mock_calls))"},{"line_number":3986,"context_line":""},{"line_number":3987,"context_line":"    def test_allocated_specific_ip_table_modified_by_another_thread(self):"},{"line_number":3988,"context_line":"        self._test_allocated_specific_ip"},{"line_number":3989,"context_line":""},{"line_number":3990,"context_line":"    def test_allocated_specific_ip_throws_exception_after_max_db_retries(self):"},{"line_number":3991,"context_line":"        self._test_allocated_specific_ip(raises\u003dTrue)"}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_f1245461","line":3988,"updated":"2014-09-14 09:25:47.000000000","message":"This is just a bare function reference. I suspect you forgot \u0027()\u0027","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"ec9893b7c990d151abbf9d70d5ee0ce1551c87e3","unresolved":false,"context_lines":[{"line_number":3985,"context_line":"                self.assertEqual(2, len(check_update_query.mock_calls))"},{"line_number":3986,"context_line":""},{"line_number":3987,"context_line":"    def test_allocated_specific_ip_table_modified_by_another_thread(self):"},{"line_number":3988,"context_line":"        self._test_allocated_specific_ip"},{"line_number":3989,"context_line":""},{"line_number":3990,"context_line":"    def test_allocated_specific_ip_throws_exception_after_max_db_retries(self):"},{"line_number":3991,"context_line":"        self._test_allocated_specific_ip(raises\u003dTrue)"}],"source_content_type":"text/x-python","patch_set":17,"id":"fa98f980_c5b39108","line":3988,"in_reply_to":"fa98f980_f1245461","updated":"2014-09-18 16:09:58.000000000","message":"thanks!","commit_id":"824dd3155af63e9c8a60dfbb5bab537e4f64d3b9"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"b0d141c9c7441c47615bc7960667811295b2029a","unresolved":false,"context_lines":[{"line_number":4006,"context_line":"        range_qry.filter_by.return_value.first.return_value \u003d ip_range"},{"line_number":4007,"context_line":""},{"line_number":4008,"context_line":"        check_update_query \u003d mock.Mock()"},{"line_number":4009,"context_line":"        check_update_query.update.side_effect \u003d [0]"},{"line_number":4010,"context_line":""},{"line_number":4011,"context_line":"        qry \u003d mock.Mock()"},{"line_number":4012,"context_line":"        qry.join.return_value \u003d range_qry"}],"source_content_type":"text/x-python","patch_set":26,"id":"9aa7fdbe_8916dfef","line":4009,"updated":"2014-10-22 20:57:04.000000000","message":"check_update_query.update.return_value \u003d 0\n\nif you are using side_effect to make sure it\u0027s not called more than once, just be explicit about it and do and assert on the call_count","commit_id":"da0221f6ff49562775bb864c8e6605be12785fc0"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"99ecde68dc5c19a36412b027f017e0672877c0ba","unresolved":false,"context_lines":[{"line_number":4006,"context_line":"        range_qry.filter_by.return_value.first.return_value \u003d ip_range"},{"line_number":4007,"context_line":""},{"line_number":4008,"context_line":"        check_update_query \u003d mock.Mock()"},{"line_number":4009,"context_line":"        check_update_query.update.side_effect \u003d [0]"},{"line_number":4010,"context_line":""},{"line_number":4011,"context_line":"        qry \u003d mock.Mock()"},{"line_number":4012,"context_line":"        qry.join.return_value \u003d range_qry"}],"source_content_type":"text/x-python","patch_set":26,"id":"9aa7fdbe_334fe76c","line":4009,"in_reply_to":"9aa7fdbe_8916dfef","updated":"2014-10-24 17:00:47.000000000","message":"Done","commit_id":"da0221f6ff49562775bb864c8e6605be12785fc0"}]}
