)]}'
{"nova/objects/resource_provider.py":[{"author":{"_account_id":4393,"name":"Dan Smith","email":"dms@danplanet.com","username":"danms"},"change_message_id":"aebdbe722d074e26e0f042a3581100fcbdac878a","unresolved":false,"context_lines":[{"line_number":674,"context_line":"        # translate this to that SQL so that we can have a tighter"},{"line_number":675,"context_line":"        # view over the transaction handling, but I needed to write"},{"line_number":676,"context_line":"        # it out in this way to first figure out what needs to"},{"line_number":677,"context_line":"        # happen."},{"line_number":678,"context_line":"        for rp_uuid, allocations in allocations_by_rp.items():"},{"line_number":679,"context_line":"            usages \u003d UsageList.get_all_by_resource_provider_uuid("},{"line_number":680,"context_line":"                context, rp_uuid)"}],"source_content_type":"text/x-python","patch_set":2,"id":"fa7ab95a_003fd025","line":677,"updated":"2016-08-31 15:54:54.000000000","message":"Right, I thought the way this was supposed to work is that we do this as one single insert. I think we need to basically fail and retry if the generation on the RP changes during our transaction commit, right?\n\nIf we don\u0027t have that, I think we will have a view of a RP\u0027s inventory here, which could change after we open our transaction, such that we commit and end up with negative capacity.","commit_id":"ecdb9aa80d8c731dbc93cf00eb4bba789f72d558"},{"author":{"_account_id":4393,"name":"Dan Smith","email":"dms@danplanet.com","username":"danms"},"change_message_id":"aebdbe722d074e26e0f042a3581100fcbdac878a","unresolved":false,"context_lines":[{"line_number":707,"context_line":"                        (resource_class, rp_uuid))"},{"line_number":708,"context_line":""},{"line_number":709,"context_line":"                allocation._context \u003d context"},{"line_number":710,"context_line":"                allocation.create()"},{"line_number":711,"context_line":""},{"line_number":712,"context_line":"    @base.remotable_classmethod"},{"line_number":713,"context_line":"    def get_all_by_resource_provider_uuid(cls, context, rp_uuid):"}],"source_content_type":"text/x-python","patch_set":2,"id":"fa7ab95a_e0866c12","line":710,"updated":"2016-08-31 15:54:54.000000000","message":"Isn\u0027t this an Allocation object (not a model)? Seems weird to be in a DB-write handler and be making object calls. Like a layering violation or something.\n\nI guess this is to ensure that they all commit or don\u0027t. Seems unideal.","commit_id":"ecdb9aa80d8c731dbc93cf00eb4bba789f72d558"},{"author":{"_account_id":7,"name":"Jay Pipes","email":"jaypipes@gmail.com","username":"jaypipes"},"change_message_id":"20cb8ce80bb3bf2d2a572cab43cef7327311f7e9","unresolved":false,"context_lines":[{"line_number":150,"context_line":"    :param rp: `ResourceProvider` whose generation should be updated."},{"line_number":151,"context_line":"    :param inc: When set to 0 we don\u0027t want to increment. Instead we want"},{"line_number":152,"context_line":"                confirm that it hasn\u0027t changed out from under us. Default"},{"line_number":153,"context_line":"                is 1."},{"line_number":154,"context_line":"    :returns: The new resource provider generation value if successful."},{"line_number":155,"context_line":"    :raises nova.exception.ConcurrentUpdateDetected: if another thread updated"},{"line_number":156,"context_line":"            the same resource provider\u0027s view of its inventory or allocations"}],"source_content_type":"text/x-python","patch_set":3,"id":"fa7ab95a_baf72958","line":153,"updated":"2016-08-31 19:22:08.000000000","message":"See below. There\u0027s no reason to make this change.","commit_id":"088c84d8b523c01e3fe7c85b14bf5e734a5d10b5"},{"author":{"_account_id":11564,"name":"Chris Dent","email":"cdent@anticdent.org","username":"chdent"},"change_message_id":"0cc6ce4f245bd104ac10d376aa314510fca79e49","unresolved":false,"context_lines":[{"line_number":150,"context_line":"    :param rp: `ResourceProvider` whose generation should be updated."},{"line_number":151,"context_line":"    :param inc: When set to 0 we don\u0027t want to increment. Instead we want"},{"line_number":152,"context_line":"                confirm that it hasn\u0027t changed out from under us. Default"},{"line_number":153,"context_line":"                is 1."},{"line_number":154,"context_line":"    :returns: The new resource provider generation value if successful."},{"line_number":155,"context_line":"    :raises nova.exception.ConcurrentUpdateDetected: if another thread updated"},{"line_number":156,"context_line":"            the same resource provider\u0027s view of its inventory or allocations"}],"source_content_type":"text/x-python","patch_set":3,"id":"fa7ab95a_e0b57ed0","line":153,"in_reply_to":"fa7ab95a_baf72958","updated":"2016-08-31 19:31:58.000000000","message":"Cool, good. I didn\u0027t like it.","commit_id":"088c84d8b523c01e3fe7c85b14bf5e734a5d10b5"},{"author":{"_account_id":7,"name":"Jay Pipes","email":"jaypipes@gmail.com","username":"jaypipes"},"change_message_id":"20cb8ce80bb3bf2d2a572cab43cef7327311f7e9","unresolved":false,"context_lines":[{"line_number":596,"context_line":"        context.session.add(db_allocation)"},{"line_number":597,"context_line":"        # We may be in a nested context manager so must flush so the"},{"line_number":598,"context_line":"        # caller receives an id."},{"line_number":599,"context_line":"        context.session.flush()"},{"line_number":600,"context_line":"        return db_allocation"},{"line_number":601,"context_line":""},{"line_number":602,"context_line":"    @staticmethod"}],"source_content_type":"text/x-python","patch_set":3,"id":"fa7ab95a_9a2fc5a0","line":599,"updated":"2016-08-31 19:22:08.000000000","message":"Callers shouldn\u0027t need to know the internal autoinc IDs of allocations table records. If they do, then something is wrong.","commit_id":"088c84d8b523c01e3fe7c85b14bf5e734a5d10b5"},{"author":{"_account_id":11564,"name":"Chris Dent","email":"cdent@anticdent.org","username":"chdent"},"change_message_id":"0cc6ce4f245bd104ac10d376aa314510fca79e49","unresolved":false,"context_lines":[{"line_number":596,"context_line":"        context.session.add(db_allocation)"},{"line_number":597,"context_line":"        # We may be in a nested context manager so must flush so the"},{"line_number":598,"context_line":"        # caller receives an id."},{"line_number":599,"context_line":"        context.session.flush()"},{"line_number":600,"context_line":"        return db_allocation"},{"line_number":601,"context_line":""},{"line_number":602,"context_line":"    @staticmethod"}],"source_content_type":"text/x-python","patch_set":3,"id":"fa7ab95a_804f52bd","line":599,"in_reply_to":"fa7ab95a_9a2fc5a0","updated":"2016-08-31 19:31:58.000000000","message":"It is because the AllocationList code is doing an allocation.create(), without this flush somewhere in the ovo stack there is an error due to a missing id. So it\u0027s not the external callers, just those here.\n\nWhen you change it to be less of a mess it won\u0027t be an issue.","commit_id":"088c84d8b523c01e3fe7c85b14bf5e734a5d10b5"},{"author":{"_account_id":7,"name":"Jay Pipes","email":"jaypipes@gmail.com","username":"jaypipes"},"change_message_id":"20cb8ce80bb3bf2d2a572cab43cef7327311f7e9","unresolved":false,"context_lines":[{"line_number":624,"context_line":"@base.NovaObjectRegistry.register"},{"line_number":625,"context_line":"class AllocationList(base.ObjectListBase, base.NovaObject):"},{"line_number":626,"context_line":"    # Version 1.0: Initial Version"},{"line_number":627,"context_line":"    # Version 1.1: Add create_all() and delete_all()"},{"line_number":628,"context_line":"    VERSION \u003d \u00271.1\u0027"},{"line_number":629,"context_line":""},{"line_number":630,"context_line":"    fields \u003d {"}],"source_content_type":"text/x-python","patch_set":3,"id":"fa7ab95a_5a0c5d42","line":627,"updated":"2016-08-31 19:22:08.000000000","message":"s/create/set/ if you want to be consistent with the new name of the method which is set_all().","commit_id":"088c84d8b523c01e3fe7c85b14bf5e734a5d10b5"},{"author":{"_account_id":11564,"name":"Chris Dent","email":"cdent@anticdent.org","username":"chdent"},"change_message_id":"0cc6ce4f245bd104ac10d376aa314510fca79e49","unresolved":false,"context_lines":[{"line_number":624,"context_line":"@base.NovaObjectRegistry.register"},{"line_number":625,"context_line":"class AllocationList(base.ObjectListBase, base.NovaObject):"},{"line_number":626,"context_line":"    # Version 1.0: Initial Version"},{"line_number":627,"context_line":"    # Version 1.1: Add create_all() and delete_all()"},{"line_number":628,"context_line":"    VERSION \u003d \u00271.1\u0027"},{"line_number":629,"context_line":""},{"line_number":630,"context_line":"    fields \u003d {"}],"source_content_type":"text/x-python","patch_set":3,"id":"fa7ab95a_00ca621a","line":627,"in_reply_to":"fa7ab95a_5a0c5d42","updated":"2016-08-31 19:31:58.000000000","message":"ah, missed that one, thanks","commit_id":"088c84d8b523c01e3fe7c85b14bf5e734a5d10b5"},{"author":{"_account_id":7,"name":"Jay Pipes","email":"jaypipes@gmail.com","username":"jaypipes"},"change_message_id":"20cb8ce80bb3bf2d2a572cab43cef7327311f7e9","unresolved":false,"context_lines":[{"line_number":746,"context_line":"            # this resource provider changed out from under us,"},{"line_number":747,"context_line":"            # this will raise a ConcurrentUpdateDetected which can"},{"line_number":748,"context_line":"            # by the caller to choose to try again."},{"line_number":749,"context_line":"            # NOTE(cdent): Can\u0027t decide if it is right to burn a"},{"line_number":750,"context_line":"            # generation here (since allocations happen more often"},{"line_number":751,"context_line":"            # than inventory changes) so we don\u0027t actually"},{"line_number":752,"context_line":"            # increment, we just check that it hasn\u0027t changed since"}],"source_content_type":"text/x-python","patch_set":3,"id":"fa7ab95a_9d4edfbf","line":749,"updated":"2016-08-31 19:22:08.000000000","message":"generations are cheap and there\u0027s no reason not to increment the resource provider generation for those providers involved in the allocation transaction. the generation indicates the number of changes made to the capacity of a resource provider and should be incremented when either inventory or usage changes.","commit_id":"088c84d8b523c01e3fe7c85b14bf5e734a5d10b5"},{"author":{"_account_id":11564,"name":"Chris Dent","email":"cdent@anticdent.org","username":"chdent"},"change_message_id":"0cc6ce4f245bd104ac10d376aa314510fca79e49","unresolved":false,"context_lines":[{"line_number":746,"context_line":"            # this resource provider changed out from under us,"},{"line_number":747,"context_line":"            # this will raise a ConcurrentUpdateDetected which can"},{"line_number":748,"context_line":"            # by the caller to choose to try again."},{"line_number":749,"context_line":"            # NOTE(cdent): Can\u0027t decide if it is right to burn a"},{"line_number":750,"context_line":"            # generation here (since allocations happen more often"},{"line_number":751,"context_line":"            # than inventory changes) so we don\u0027t actually"},{"line_number":752,"context_line":"            # increment, we just check that it hasn\u0027t changed since"}],"source_content_type":"text/x-python","patch_set":3,"id":"fa7ab95a_60024e40","line":749,"in_reply_to":"fa7ab95a_9d4edfbf","updated":"2016-08-31 19:31:58.000000000","message":"Yeah, as I said in IRC right after I committed: \"Now that I\u0027ve commited it, I think that\u0027s wrong. We should burn a generation\"","commit_id":"088c84d8b523c01e3fe7c85b14bf5e734a5d10b5"},{"author":{"_account_id":5754,"name":"Alex Xu","email":"hejie.xu@intel.com","username":"xuhj"},"change_message_id":"2c85d812fd295f249d17e6ceb63ce97bee01842a","unresolved":false,"context_lines":[{"line_number":751,"context_line":"            # than inventory changes) so we don\u0027t actually"},{"line_number":752,"context_line":"            # increment, we just check that it hasn\u0027t changed since"},{"line_number":753,"context_line":"            # we started by incrementing what\u0027s there by zero."},{"line_number":754,"context_line":"            _increment_provider_generation(conn, resource_provider, inc\u003d0)"},{"line_number":755,"context_line":""},{"line_number":756,"context_line":"    @base.remotable_classmethod"},{"line_number":757,"context_line":"    def get_all_by_resource_provider_uuid(cls, context, rp_uuid):"}],"source_content_type":"text/x-python","patch_set":3,"id":"fa7ab95a_737cc3eb","line":754,"range":{"start_line":754,"start_character":12,"end_line":754,"end_character":74},"updated":"2016-09-01 11:33:13.000000000","message":"Should we retry until there is no more resources? The allocation happen frequently. Just like user may boot many instances, and there are some of them schedule to same host.  Then may trigger the \u0027ConcurrentUpdateDetected\u0027, if we let the client to trigger the retry, that sounds waste.","commit_id":"088c84d8b523c01e3fe7c85b14bf5e734a5d10b5"},{"author":{"_account_id":5754,"name":"Alex Xu","email":"hejie.xu@intel.com","username":"xuhj"},"change_message_id":"30e0960e575f4eb29831ec7f973e16fa231a095f","unresolved":false,"context_lines":[{"line_number":751,"context_line":"            # than inventory changes) so we don\u0027t actually"},{"line_number":752,"context_line":"            # increment, we just check that it hasn\u0027t changed since"},{"line_number":753,"context_line":"            # we started by incrementing what\u0027s there by zero."},{"line_number":754,"context_line":"            _increment_provider_generation(conn, resource_provider, inc\u003d0)"},{"line_number":755,"context_line":""},{"line_number":756,"context_line":"    @base.remotable_classmethod"},{"line_number":757,"context_line":"    def get_all_by_resource_provider_uuid(cls, context, rp_uuid):"}],"source_content_type":"text/x-python","patch_set":3,"id":"fa7ab95a_76ecb129","line":754,"range":{"start_line":754,"start_character":12,"end_line":754,"end_character":74},"in_reply_to":"fa7ab95a_737cc3eb","updated":"2016-09-01 11:39:56.000000000","message":"I change mind, see the comment at patchset5","commit_id":"088c84d8b523c01e3fe7c85b14bf5e734a5d10b5"},{"author":{"_account_id":4393,"name":"Dan Smith","email":"dms@danplanet.com","username":"danms"},"change_message_id":"db6ca8340b37152af51f5bbfb76e2cbc2332cd9d","unresolved":false,"context_lines":[{"line_number":591,"context_line":"        context.session.add(db_allocation)"},{"line_number":592,"context_line":"        # We may be in a nested context manager so must flush so the"},{"line_number":593,"context_line":"        # caller receives an id."},{"line_number":594,"context_line":"        context.session.flush()"},{"line_number":595,"context_line":"        return db_allocation"},{"line_number":596,"context_line":""},{"line_number":597,"context_line":"    @staticmethod"}],"source_content_type":"text/x-python","patch_set":4,"id":"fa7ab95a_7795af3e","line":594,"updated":"2016-08-31 22:43:35.000000000","message":"Is this still needed?","commit_id":"eb2dccebde0e3a52f5fcc7823ff123676663f0b9"},{"author":{"_account_id":11564,"name":"Chris Dent","email":"cdent@anticdent.org","username":"chdent"},"change_message_id":"c734fefd5314b0aae481e62a99fe6f5f3fb52772","unresolved":false,"context_lines":[{"line_number":698,"context_line":"        res_class \u003d fields.ResourceClass.index(alloc.resource_class)"},{"line_number":699,"context_line":"        rp_uuid \u003d alloc.resource_provider.uuid"},{"line_number":700,"context_line":"        key \u003d (rp_uuid, res_class)"},{"line_number":701,"context_line":"        usage \u003d usage_map[key]"},{"line_number":702,"context_line":"        amount_needed \u003d alloc.used"},{"line_number":703,"context_line":"        allocation_ratio \u003d usage[\u0027allocation_ratio\u0027]"},{"line_number":704,"context_line":"        used \u003d usage[\u0027used\u0027]"}],"source_content_type":"text/x-python","patch_set":4,"id":"fa7ab95a_152c5b49","line":701,"updated":"2016-08-31 23:21:19.000000000","message":"If there\u0027s currently no inventory (for this class on this resource provider), perhaps because it hasn\u0027t been created yet, this will raise a KeyError, which we should turn into some other exception, I\u0027m not sure what.\n\nThere\u0027s a functional test that hits this but will need to be changed to reflect whatever the exception is.","commit_id":"eb2dccebde0e3a52f5fcc7823ff123676663f0b9"},{"author":{"_account_id":1063,"name":"Ed Leafe","email":"ed@leafe.com","username":"ed-leafe"},"change_message_id":"22a509262731e240ec9307d834b4fdbd697178b9","unresolved":false,"context_lines":[{"line_number":698,"context_line":"        res_class \u003d fields.ResourceClass.index(alloc.resource_class)"},{"line_number":699,"context_line":"        rp_uuid \u003d alloc.resource_provider.uuid"},{"line_number":700,"context_line":"        key \u003d (rp_uuid, res_class)"},{"line_number":701,"context_line":"        usage \u003d usage_map[key]"},{"line_number":702,"context_line":"        amount_needed \u003d alloc.used"},{"line_number":703,"context_line":"        allocation_ratio \u003d usage[\u0027allocation_ratio\u0027]"},{"line_number":704,"context_line":"        used \u003d usage[\u0027used\u0027]"}],"source_content_type":"text/x-python","patch_set":4,"id":"fa7ab95a_f0b9c516","line":701,"in_reply_to":"fa7ab95a_152c5b49","updated":"2016-08-31 23:40:29.000000000","message":"Already fixed this to raise an InvalidInventory if there are no inventory records.","commit_id":"eb2dccebde0e3a52f5fcc7823ff123676663f0b9"},{"author":{"_account_id":11564,"name":"Chris Dent","email":"cdent@anticdent.org","username":"chdent"},"change_message_id":"c734fefd5314b0aae481e62a99fe6f5f3fb52772","unresolved":false,"context_lines":[{"line_number":703,"context_line":"        allocation_ratio \u003d usage[\u0027allocation_ratio\u0027]"},{"line_number":704,"context_line":"        used \u003d usage[\u0027used\u0027]"},{"line_number":705,"context_line":"        capacity \u003d (usage[\u0027total\u0027] - usage[\u0027reserved\u0027]) * allocation_ratio"},{"line_number":706,"context_line":"        if capacity \u003c (used + amount_needed):"},{"line_number":707,"context_line":"            raise exception.InvalidAllocationCapacityExceeded("},{"line_number":708,"context_line":"                resource_class\u003dfields.ResourceClass.from_index(res_class),"},{"line_number":709,"context_line":"                resource_provider\u003drp_uuid)"}],"source_content_type":"text/x-python","patch_set":4,"id":"fa7ab95a_55ab4389","line":706,"updated":"2016-08-31 23:21:19.000000000","message":"The functional tests are showing that used can be \"None\" here which will cause a TypeError, so probably the func.sum above needs to be wrapped in a coalesce to 0? Or something like that. I\u0027m too tired to be sure. Just noting it so it is clear how things need to be fixed.","commit_id":"eb2dccebde0e3a52f5fcc7823ff123676663f0b9"},{"author":{"_account_id":1063,"name":"Ed Leafe","email":"ed@leafe.com","username":"ed-leafe"},"change_message_id":"22a509262731e240ec9307d834b4fdbd697178b9","unresolved":false,"context_lines":[{"line_number":703,"context_line":"        allocation_ratio \u003d usage[\u0027allocation_ratio\u0027]"},{"line_number":704,"context_line":"        used \u003d usage[\u0027used\u0027]"},{"line_number":705,"context_line":"        capacity \u003d (usage[\u0027total\u0027] - usage[\u0027reserved\u0027]) * allocation_ratio"},{"line_number":706,"context_line":"        if capacity \u003c (used + amount_needed):"},{"line_number":707,"context_line":"            raise exception.InvalidAllocationCapacityExceeded("},{"line_number":708,"context_line":"                resource_class\u003dfields.ResourceClass.from_index(res_class),"},{"line_number":709,"context_line":"                resource_provider\u003drp_uuid)"}],"source_content_type":"text/x-python","patch_set":4,"id":"fa7ab95a_d055a1c6","line":706,"in_reply_to":"fa7ab95a_55ab4389","updated":"2016-08-31 23:40:29.000000000","message":"Also fixed. I think it\u0027s easier to simply change 704 to read:\n\n   used \u003d usage[\u0027used\u0027] or 0\n\nto handle the None case.","commit_id":"eb2dccebde0e3a52f5fcc7823ff123676663f0b9"},{"author":{"_account_id":11564,"name":"Chris Dent","email":"cdent@anticdent.org","username":"chdent"},"change_message_id":"c734fefd5314b0aae481e62a99fe6f5f3fb52772","unresolved":false,"context_lines":[{"line_number":771,"context_line":"            for alloc in allocs:"},{"line_number":772,"context_line":"                rp \u003d alloc.resource_provider"},{"line_number":773,"context_line":"                res_class \u003d fields.ResourceClass.index(alloc.resource_class)"},{"line_number":774,"context_line":"                ins_stmt \u003d _ALLOC_TBL.insert().values("},{"line_number":775,"context_line":"                        resource_provider_id\u003drp.id,"},{"line_number":776,"context_line":"                        resource_class_id\u003dres_class,"},{"line_number":777,"context_line":"                        consumer_id\u003dalloc.consumer_id,"}],"source_content_type":"text/x-python","patch_set":4,"id":"fa7ab95a_95d14bfe","line":774,"updated":"2016-08-31 23:21:19.000000000","message":"You\u0027ve renamed this back to create and in fact it does do that: everything is created as an insert and since there is no uniqueconstraint on the rp_uuid, consumer_id pair, we won\u0027t get any protection about their being two simultaneous allocations from the same consumer on the same resource provider. My code, in it\u0027s sloppy way, protected against this, but it did it by destroying any existing allocations before updating.\n\nIn IRC and the hangouts we decided that it was necessary to be able to update or replace an existing allocation for both the same-host resize and situations where we want to do allocation healing.","commit_id":"eb2dccebde0e3a52f5fcc7823ff123676663f0b9"},{"author":{"_account_id":1063,"name":"Ed Leafe","email":"ed@leafe.com","username":"ed-leafe"},"change_message_id":"22a509262731e240ec9307d834b4fdbd697178b9","unresolved":false,"context_lines":[{"line_number":771,"context_line":"            for alloc in allocs:"},{"line_number":772,"context_line":"                rp \u003d alloc.resource_provider"},{"line_number":773,"context_line":"                res_class \u003d fields.ResourceClass.index(alloc.resource_class)"},{"line_number":774,"context_line":"                ins_stmt \u003d _ALLOC_TBL.insert().values("},{"line_number":775,"context_line":"                        resource_provider_id\u003drp.id,"},{"line_number":776,"context_line":"                        resource_class_id\u003dres_class,"},{"line_number":777,"context_line":"                        consumer_id\u003dalloc.consumer_id,"}],"source_content_type":"text/x-python","patch_set":4,"id":"fa7ab95a_102c6949","line":774,"in_reply_to":"fa7ab95a_95d14bfe","updated":"2016-08-31 23:40:29.000000000","message":"This was my concern too when I saw the name changed back to create. I\u0027ll look for alternatives.","commit_id":"eb2dccebde0e3a52f5fcc7823ff123676663f0b9"},{"author":{"_account_id":4393,"name":"Dan Smith","email":"dms@danplanet.com","username":"danms"},"change_message_id":"db6ca8340b37152af51f5bbfb76e2cbc2332cd9d","unresolved":false,"context_lines":[{"line_number":781,"context_line":"            # Generation checking happens here. If the inventory for"},{"line_number":782,"context_line":"            # this resource provider changed out from under us,"},{"line_number":783,"context_line":"            # this will raise a ConcurrentUpdateDetected which"},{"line_number":784,"context_line":"            # by the caller to choose to try again."},{"line_number":785,"context_line":"            for rp in before_gens:"},{"line_number":786,"context_line":"                _increment_provider_generation(conn, rp)"},{"line_number":787,"context_line":""}],"source_content_type":"text/x-python","patch_set":4,"id":"fa7ab95a_1715439a","line":784,"updated":"2016-08-31 22:43:35.000000000","message":"This makes sense to me.","commit_id":"eb2dccebde0e3a52f5fcc7823ff123676663f0b9"},{"author":{"_account_id":11564,"name":"Chris Dent","email":"cdent@anticdent.org","username":"chdent"},"change_message_id":"81d75a28e5a8b8cec86e7a17b61d4e61d14b3f56","unresolved":false,"context_lines":[{"line_number":591,"context_line":"        context.session.add(db_allocation)"},{"line_number":592,"context_line":"        # We may be in a nested context manager so must flush so the"},{"line_number":593,"context_line":"        # caller receives an id."},{"line_number":594,"context_line":"        context.session.flush()"},{"line_number":595,"context_line":"        return db_allocation"},{"line_number":596,"context_line":""},{"line_number":597,"context_line":"    @staticmethod"}],"source_content_type":"text/x-python","patch_set":5,"id":"fa7ab95a_bfb61788","line":594,"updated":"2016-09-01 09:50:26.000000000","message":"This can go now.","commit_id":"900cd7d7c997164be12f82381e6a4e9d48ce5c70"},{"author":{"_account_id":11564,"name":"Chris Dent","email":"cdent@anticdent.org","username":"chdent"},"change_message_id":"81d75a28e5a8b8cec86e7a17b61d4e61d14b3f56","unresolved":false,"context_lines":[{"line_number":702,"context_line":"        # No records"},{"line_number":703,"context_line":"        rp_uuids \u003d str([provid for provid in provider_uuids])"},{"line_number":704,"context_line":"        raise exception.InvalidInventory(resource_class\u003dstr(res_classes),"},{"line_number":705,"context_line":"                resource_provider\u003drp_uuids)"},{"line_number":706,"context_line":""},{"line_number":707,"context_line":"    res_providers \u003d {}"},{"line_number":708,"context_line":"    for alloc in allocs:"}],"source_content_type":"text/x-python","patch_set":5,"id":"fa7ab95a_dfb75bf3","line":705,"updated":"2016-09-01 09:50:26.000000000","message":"This will raise the error if there is no inventory at all for any of the resource providers mentioned in the collection of allocations. That\u0027s not sufficient, right? We need to raise the error if there\u0027s inventory missing for any resource provider or resource class, even if there is inventory for something else.","commit_id":"900cd7d7c997164be12f82381e6a4e9d48ce5c70"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"c94d55314dbefb9ddb9ec73758a97d1b2ed770d4","unresolved":false,"context_lines":[{"line_number":702,"context_line":"        # No records"},{"line_number":703,"context_line":"        rp_uuids \u003d str([provid for provid in provider_uuids])"},{"line_number":704,"context_line":"        raise exception.InvalidInventory(resource_class\u003dstr(res_classes),"},{"line_number":705,"context_line":"                resource_provider\u003drp_uuids)"},{"line_number":706,"context_line":""},{"line_number":707,"context_line":"    res_providers \u003d {}"},{"line_number":708,"context_line":"    for alloc in allocs:"}],"source_content_type":"text/x-python","patch_set":5,"id":"fa7ab95a_cd3a43cd","line":705,"in_reply_to":"fa7ab95a_dfb75bf3","updated":"2016-09-01 16:21:16.000000000","message":"I think currently we would hit a key error below on ln712, but aggreed we should raise something sensible for that case.","commit_id":"900cd7d7c997164be12f82381e6a4e9d48ce5c70"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"c94d55314dbefb9ddb9ec73758a97d1b2ed770d4","unresolved":false,"context_lines":[{"line_number":709,"context_line":"        res_class \u003d fields.ResourceClass.index(alloc.resource_class)"},{"line_number":710,"context_line":"        rp_uuid \u003d alloc.resource_provider.uuid"},{"line_number":711,"context_line":"        key \u003d (rp_uuid, res_class)"},{"line_number":712,"context_line":"        usage \u003d usage_map[key]"},{"line_number":713,"context_line":"        amount_needed \u003d alloc.used"},{"line_number":714,"context_line":"        allocation_ratio \u003d usage[\u0027allocation_ratio\u0027]"},{"line_number":715,"context_line":"        # usage[\"used\"] can be returned as None"}],"source_content_type":"text/x-python","patch_set":5,"id":"fa7ab95a_cd41633b","line":712,"updated":"2016-09-01 16:21:16.000000000","message":"see above, it feels like this key *might* not be present.","commit_id":"900cd7d7c997164be12f82381e6a4e9d48ce5c70"},{"author":{"_account_id":11564,"name":"Chris Dent","email":"cdent@anticdent.org","username":"chdent"},"change_message_id":"81d75a28e5a8b8cec86e7a17b61d4e61d14b3f56","unresolved":false,"context_lines":[{"line_number":788,"context_line":"        # name for that method."},{"line_number":789,"context_line":"        before_gens, existing_allocs \u003d _check_capacity_exceeded(conn, allocs)"},{"line_number":790,"context_line":"        with conn.begin():"},{"line_number":791,"context_line":"            # First delete any existing allocations for that rp/consumer combo."},{"line_number":792,"context_line":"            new_allocs \u003d [(alloc.resource_provider.id, alloc.consumer_id)"},{"line_number":793,"context_line":"                           for alloc in allocs]"},{"line_number":794,"context_line":"            for existing_alloc in existing_allocs:"}],"source_content_type":"text/x-python","patch_set":5,"id":"fa7ab95a_ffdb3feb","line":791,"updated":"2016-09-01 09:50:26.000000000","message":"The semantics of updating an existing allocation are befuddling. As written we are checking the capacity of inventory with the existing allocation in it, making sure there is room for the update, removing the existing, then adding the update.\n\nIs that right, or do we want to check capacity after deleting?\n\nWithout knowing what update means (in the real world) it is hard to say.\n\nI guess the way things are currently is the most safe, but it limits the opportunity for an in-place change against a space constrained resource provider. Is that something that\u0027s even possible? I don\u0027t know because this is all really an abstraction to me...","commit_id":"900cd7d7c997164be12f82381e6a4e9d48ce5c70"},{"author":{"_account_id":11564,"name":"Chris Dent","email":"cdent@anticdent.org","username":"chdent"},"change_message_id":"81d75a28e5a8b8cec86e7a17b61d4e61d14b3f56","unresolved":false,"context_lines":[{"line_number":835,"context_line":"    def create_all(self):"},{"line_number":836,"context_line":"        \"\"\"Create the supplied allocations.\"\"\""},{"line_number":837,"context_line":"        # TODO(jaypipes): Retry the allocation writes on"},{"line_number":838,"context_line":"        # ConcurrentUpdateDetected"},{"line_number":839,"context_line":"        self._set_allocations(self._context, self.objects)"},{"line_number":840,"context_line":""},{"line_number":841,"context_line":"    @base.remotable"}],"source_content_type":"text/x-python","patch_set":5,"id":"fa7ab95a_dfa2fb4a","line":838,"updated":"2016-09-01 09:50:26.000000000","message":"Do we want retries here or in the caller, or both? I\u0027ve always assumed they would be in the caller.","commit_id":"900cd7d7c997164be12f82381e6a4e9d48ce5c70"},{"author":{"_account_id":5754,"name":"Alex Xu","email":"hejie.xu@intel.com","username":"xuhj"},"change_message_id":"ac9b8f21c529cede3aac5eee3c10019a27f644c3","unresolved":false,"context_lines":[{"line_number":835,"context_line":"    def create_all(self):"},{"line_number":836,"context_line":"        \"\"\"Create the supplied allocations.\"\"\""},{"line_number":837,"context_line":"        # TODO(jaypipes): Retry the allocation writes on"},{"line_number":838,"context_line":"        # ConcurrentUpdateDetected"},{"line_number":839,"context_line":"        self._set_allocations(self._context, self.objects)"},{"line_number":840,"context_line":""},{"line_number":841,"context_line":"    @base.remotable"}],"source_content_type":"text/x-python","patch_set":5,"id":"fa7ab95a_d6af3de1","line":838,"in_reply_to":"fa7ab95a_dfa2fb4a","updated":"2016-09-01 11:38:57.000000000","message":"same question, I wrote that in patchset 3... But after rethinking, this happened when many instances schedule to the same host by multiple schedulers. So after that, the condition may be changed. The scheduler may want to choice another host.","commit_id":"900cd7d7c997164be12f82381e6a4e9d48ce5c70"}]}
