)]}'
{"/COMMIT_MSG":[{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"c8e40098802f73d35d3f4276a7f90cf243824839","unresolved":false,"context_lines":[{"line_number":11,"context_line":""},{"line_number":12,"context_line":"An alternative is to do that in deeper layer using SQL in"},{"line_number":13,"context_line":"_get_providers_with_resource(), but we don\u0027t do that so as to leave it"},{"line_number":14,"context_line":"as premitive as possible so that we can get the useful log for debug."},{"line_number":15,"context_line":""},{"line_number":16,"context_line":"Change-Id: I374b906e8084b6c432a22023154bef0c896767c3"},{"line_number":17,"context_line":"Blueprint: alloc-candidates-in-tree"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":2,"id":"9fdfeff1_22dbae4f","line":14,"range":{"start_line":14,"start_character":3,"end_line":14,"end_character":12},"updated":"2019-02-21 21:30:33.000000000","message":"primitive?","commit_id":"a4954b190ee21e80a18cd8a22d1cf27ca11e33f8"}],"placement/objects/resource_provider.py":[{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"6f60366c8b0662bbc54ea9f63abe951960674d81","unresolved":false,"context_lines":[{"line_number":2978,"context_line":""},{"line_number":2979,"context_line":"@db_api.placement_context_manager.reader"},{"line_number":2980,"context_line":"def _get_provider_ids_matching(ctx, resources, required_traits,"},{"line_number":2981,"context_line":"        forbidden_traits, member_of, tree_id):"},{"line_number":2982,"context_line":"    \"\"\"Returns a list of tuples of (internal provider ID, root provider ID)"},{"line_number":2983,"context_line":"    that have available inventory to satisfy all the supplied requests for"},{"line_number":2984,"context_line":"    resources."}],"source_content_type":"text/x-python","patch_set":2,"id":"9fdfeff1_e8dfc535","line":2981,"range":{"start_line":2981,"start_character":37,"end_line":2981,"end_character":44},"updated":"2019-02-21 21:38:23.000000000","message":"Possibly what Chris was talking about, this might be clearer as tree_root_id, to make clear that we\u0027ve already resolved from \"any node in the tree\" to \"the root of the tree\" (via [1]).\n\n[1] https://review.openstack.org/#/c/635723/3/placement/objects/resource_provider.py@4084","commit_id":"a4954b190ee21e80a18cd8a22d1cf27ca11e33f8"},{"author":{"_account_id":25625,"name":"Tetsuro Nakamura","email":"tetsuro.nakamura.bc@hco.ntt.co.jp","username":"tetsuro0907"},"change_message_id":"2f59a07aeab1891a4be098fdc9b708adb7a42585","unresolved":false,"context_lines":[{"line_number":2978,"context_line":""},{"line_number":2979,"context_line":"@db_api.placement_context_manager.reader"},{"line_number":2980,"context_line":"def _get_provider_ids_matching(ctx, resources, required_traits,"},{"line_number":2981,"context_line":"        forbidden_traits, member_of, tree_id):"},{"line_number":2982,"context_line":"    \"\"\"Returns a list of tuples of (internal provider ID, root provider ID)"},{"line_number":2983,"context_line":"    that have available inventory to satisfy all the supplied requests for"},{"line_number":2984,"context_line":"    resources."}],"source_content_type":"text/x-python","patch_set":2,"id":"9fdfeff1_f17b2926","line":2981,"range":{"start_line":2981,"start_character":37,"end_line":2981,"end_character":44},"in_reply_to":"9fdfeff1_e8dfc535","updated":"2019-02-22 09:08:30.000000000","message":"Done","commit_id":"a4954b190ee21e80a18cd8a22d1cf27ca11e33f8"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"fc4608c661b62a6705709a558c9c75824f15bc64","unresolved":false,"context_lines":[{"line_number":2984,"context_line":"    resources."},{"line_number":2985,"context_line":""},{"line_number":2986,"context_line":"    :note: This function is used for scenarios that do NOT involve sharing"},{"line_number":2987,"context_line":"    providers or nested providers."},{"line_number":2988,"context_line":""},{"line_number":2989,"context_line":"    :param ctx: Session context to use"},{"line_number":2990,"context_line":"    :param resources: A dict, keyed by resource class ID, of the amount"}],"source_content_type":"text/x-python","patch_set":2,"id":"9fdfeff1_c86a011a","line":2987,"range":{"start_line":2987,"start_character":13,"end_line":2987,"end_character":34},"updated":"2019-02-21 22:04:48.000000000","message":"I don\u0027t think this is correct. Nested providers may be involved when this method is invoked to satisfy a granular request group. And in that case, if the granular group needs to be satisfied by a child provider, I\u0027m pretty sure the logic breaks - see below.","commit_id":"a4954b190ee21e80a18cd8a22d1cf27ca11e33f8"},{"author":{"_account_id":25625,"name":"Tetsuro Nakamura","email":"tetsuro.nakamura.bc@hco.ntt.co.jp","username":"tetsuro0907"},"change_message_id":"2f59a07aeab1891a4be098fdc9b708adb7a42585","unresolved":false,"context_lines":[{"line_number":2984,"context_line":"    resources."},{"line_number":2985,"context_line":""},{"line_number":2986,"context_line":"    :note: This function is used for scenarios that do NOT involve sharing"},{"line_number":2987,"context_line":"    providers or nested providers."},{"line_number":2988,"context_line":""},{"line_number":2989,"context_line":"    :param ctx: Session context to use"},{"line_number":2990,"context_line":"    :param resources: A dict, keyed by resource class ID, of the amount"}],"source_content_type":"text/x-python","patch_set":2,"id":"9fdfeff1_dbdf2464","line":2987,"range":{"start_line":2987,"start_character":13,"end_line":2987,"end_character":34},"in_reply_to":"9fdfeff1_c86a011a","updated":"2019-02-22 09:08:30.000000000","message":"Thinking about the granular case, there can be cases sharing providers are involved (see the tests in the next patch). This problem is not caused by this patch. Let\u0027s separate it.","commit_id":"a4954b190ee21e80a18cd8a22d1cf27ca11e33f8"},{"author":{"_account_id":25625,"name":"Tetsuro Nakamura","email":"tetsuro.nakamura.bc@hco.ntt.co.jp","username":"tetsuro0907"},"change_message_id":"0f15fa5aa64f369f8504b0c8d4b183968e85d18f","unresolved":false,"context_lines":[{"line_number":2984,"context_line":"    resources."},{"line_number":2985,"context_line":""},{"line_number":2986,"context_line":"    :note: This function is used for scenarios that do NOT involve sharing"},{"line_number":2987,"context_line":"    providers or nested providers."},{"line_number":2988,"context_line":""},{"line_number":2989,"context_line":"    :param ctx: Session context to use"},{"line_number":2990,"context_line":"    :param resources: A dict, keyed by resource class ID, of the amount"}],"source_content_type":"text/x-python","patch_set":2,"id":"9fdfeff1_8c63a441","line":2987,"range":{"start_line":2987,"start_character":13,"end_line":2987,"end_character":34},"in_reply_to":"9fdfeff1_dbdf2464","updated":"2019-02-22 09:26:57.000000000","message":"https://review.openstack.org/#/c/638611/","commit_id":"a4954b190ee21e80a18cd8a22d1cf27ca11e33f8"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"c8e40098802f73d35d3f4276a7f90cf243824839","unresolved":false,"context_lines":[{"line_number":3028,"context_line":"    first \u003d True"},{"line_number":3029,"context_line":"    for rc_id, amount in resources.items():"},{"line_number":3030,"context_line":"        rc_name \u003d _RC_CACHE.string_from_id(rc_id)"},{"line_number":3031,"context_line":"        provs_with_resource \u003d _get_providers_with_resource(ctx, rc_id, amount)"},{"line_number":3032,"context_line":"        LOG.debug(\"found %d providers with available %d %s\","},{"line_number":3033,"context_line":"                  len(provs_with_resource), amount, rc_name)"},{"line_number":3034,"context_line":"        if not provs_with_resource:"}],"source_content_type":"text/x-python","patch_set":2,"id":"9fdfeff1_a2755e34","line":3031,"range":{"start_line":3031,"start_character":30,"end_line":3031,"end_character":78},"updated":"2019-02-21 21:30:33.000000000","message":"I get what you said in the commit message about debuggability, but it pains me to see us get this huge list of providers (potentially tens of thousands, think CERN) if we already know the one provider it could possibly be. Couldn\u0027t we...","commit_id":"a4954b190ee21e80a18cd8a22d1cf27ca11e33f8"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"fc4608c661b62a6705709a558c9c75824f15bc64","unresolved":false,"context_lines":[{"line_number":3028,"context_line":"    first \u003d True"},{"line_number":3029,"context_line":"    for rc_id, amount in resources.items():"},{"line_number":3030,"context_line":"        rc_name \u003d _RC_CACHE.string_from_id(rc_id)"},{"line_number":3031,"context_line":"        provs_with_resource \u003d _get_providers_with_resource(ctx, rc_id, amount)"},{"line_number":3032,"context_line":"        LOG.debug(\"found %d providers with available %d %s\","},{"line_number":3033,"context_line":"                  len(provs_with_resource), amount, rc_name)"},{"line_number":3034,"context_line":"        if not provs_with_resource:"}],"source_content_type":"text/x-python","patch_set":2,"id":"9fdfeff1_089d6909","line":3031,"range":{"start_line":3031,"start_character":30,"end_line":3031,"end_character":78},"in_reply_to":"9fdfeff1_a2755e34","updated":"2019-02-21 22:04:48.000000000","message":"\u003e the one provider\n \u003e it could possibly be.\n\nCorrection: we know the root of the tree the provider is in. As noted above, this code path can still apply to treed cases. So even here, we want to determine the list of providers in the tree and pass that into _get_providers_with_resource.","commit_id":"a4954b190ee21e80a18cd8a22d1cf27ca11e33f8"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"fc4608c661b62a6705709a558c9c75824f15bc64","unresolved":false,"context_lines":[{"line_number":3058,"context_line":"                    filtered_rps -\u003d forbidden_rp_ids"},{"line_number":3059,"context_line":"                    LOG.debug(\"found %d providers after applying forbidden \""},{"line_number":3060,"context_line":"                              \"traits\", len(filtered_rps))"},{"line_number":3061,"context_line":"            if tree_id is not None:"},{"line_number":3062,"context_line":"                filtered_rps \u0026\u003d set([tree_id])"},{"line_number":3063,"context_line":"                LOG.debug(\"found %d providers after applying in_tree filter \","},{"line_number":3064,"context_line":"                          len(filtered_rps))"},{"line_number":3065,"context_line":"        else:"},{"line_number":3066,"context_line":"            filtered_rps \u0026\u003d rc_rp_ids"},{"line_number":3067,"context_line":"            LOG.debug(\"found %d providers after filtering by previous result\","}],"source_content_type":"text/x-python","patch_set":2,"id":"9fdfeff1_c801a13b","line":3064,"range":{"start_line":3061,"start_character":0,"end_line":3064,"end_character":44},"updated":"2019-02-21 22:04:48.000000000","message":"IIUC, we can hit this code path on a granular request group that needs to be satisfied by a child provider. In that case, this filter will remove a viable candidate, because tree_id !\u003d provider_id as you\u0027re assuming.\n\nIf you take the suggestion above, I think it works out correctly.","commit_id":"a4954b190ee21e80a18cd8a22d1cf27ca11e33f8"},{"author":{"_account_id":25625,"name":"Tetsuro Nakamura","email":"tetsuro.nakamura.bc@hco.ntt.co.jp","username":"tetsuro0907"},"change_message_id":"2f59a07aeab1891a4be098fdc9b708adb7a42585","unresolved":false,"context_lines":[{"line_number":3058,"context_line":"                    filtered_rps -\u003d forbidden_rp_ids"},{"line_number":3059,"context_line":"                    LOG.debug(\"found %d providers after applying forbidden \""},{"line_number":3060,"context_line":"                              \"traits\", len(filtered_rps))"},{"line_number":3061,"context_line":"            if tree_id is not None:"},{"line_number":3062,"context_line":"                filtered_rps \u0026\u003d set([tree_id])"},{"line_number":3063,"context_line":"                LOG.debug(\"found %d providers after applying in_tree filter \","},{"line_number":3064,"context_line":"                          len(filtered_rps))"},{"line_number":3065,"context_line":"        else:"},{"line_number":3066,"context_line":"            filtered_rps \u0026\u003d rc_rp_ids"},{"line_number":3067,"context_line":"            LOG.debug(\"found %d providers after filtering by previous result\","}],"source_content_type":"text/x-python","patch_set":2,"id":"9fdfeff1_11d4adba","line":3064,"range":{"start_line":3061,"start_character":0,"end_line":3064,"end_character":44},"in_reply_to":"9fdfeff1_c801a13b","updated":"2019-02-22 09:08:30.000000000","message":"Right. Looks like I took the wrong alternative... :(","commit_id":"a4954b190ee21e80a18cd8a22d1cf27ca11e33f8"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"c8e40098802f73d35d3f4276a7f90cf243824839","unresolved":false,"context_lines":[{"line_number":3077,"context_line":""},{"line_number":3078,"context_line":""},{"line_number":3079,"context_line":"@db_api.placement_context_manager.reader"},{"line_number":3080,"context_line":"def _get_providers_with_resource(ctx, rc_id, amount):"},{"line_number":3081,"context_line":"    \"\"\"Returns a set of tuples of (provider ID, root provider ID) of providers"},{"line_number":3082,"context_line":"    that satisfy the request for a single resource class."},{"line_number":3083,"context_line":""}],"source_content_type":"text/x-python","patch_set":2,"id":"9fdfeff1_edc83776","line":3080,"updated":"2019-02-21 21:30:33.000000000","message":"...pass tree_id in here (actually *provider_ids - see below)...","commit_id":"a4954b190ee21e80a18cd8a22d1cf27ca11e33f8"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"c8e40098802f73d35d3f4276a7f90cf243824839","unresolved":false,"context_lines":[{"line_number":3117,"context_line":"    sel \u003d sa.select([rpt.c.id, rpt.c.root_provider_id])"},{"line_number":3118,"context_line":"    sel \u003d sel.select_from(inv_to_usage)"},{"line_number":3119,"context_line":"    sel \u003d sel.where(_capacity_check_clause(amount, usage, inv_tbl\u003dinv))"},{"line_number":3120,"context_line":"    res \u003d ctx.session.execute(sel).fetchall()"},{"line_number":3121,"context_line":"    res \u003d set((r[0], r[1]) for r in res)"},{"line_number":3122,"context_line":"    # TODO(tetsuro): Bug#1799892: We could have old providers with no root"},{"line_number":3123,"context_line":"    # provider set and they haven\u0027t undergone a data migration yet,"}],"source_content_type":"text/x-python","patch_set":2,"id":"9fdfeff1_e2a04694","line":3120,"updated":"2019-02-21 21:30:33.000000000","message":"...add `AND rpt.c.id IN provider_ids` and emit the debug message here if provider_ids are specified?","commit_id":"a4954b190ee21e80a18cd8a22d1cf27ca11e33f8"},{"author":{"_account_id":25625,"name":"Tetsuro Nakamura","email":"tetsuro.nakamura.bc@hco.ntt.co.jp","username":"tetsuro0907"},"change_message_id":"2f59a07aeab1891a4be098fdc9b708adb7a42585","unresolved":false,"context_lines":[{"line_number":3117,"context_line":"    sel \u003d sa.select([rpt.c.id, rpt.c.root_provider_id])"},{"line_number":3118,"context_line":"    sel \u003d sel.select_from(inv_to_usage)"},{"line_number":3119,"context_line":"    sel \u003d sel.where(_capacity_check_clause(amount, usage, inv_tbl\u003dinv))"},{"line_number":3120,"context_line":"    res \u003d ctx.session.execute(sel).fetchall()"},{"line_number":3121,"context_line":"    res \u003d set((r[0], r[1]) for r in res)"},{"line_number":3122,"context_line":"    # TODO(tetsuro): Bug#1799892: We could have old providers with no root"},{"line_number":3123,"context_line":"    # provider set and they haven\u0027t undergone a data migration yet,"}],"source_content_type":"text/x-python","patch_set":2,"id":"9fdfeff1_31a9b18f","line":3120,"in_reply_to":"9fdfeff1_e2a04694","updated":"2019-02-22 09:08:30.000000000","message":"Debugging log is done in the next patch because I want it to log the uuids used to filter.","commit_id":"a4954b190ee21e80a18cd8a22d1cf27ca11e33f8"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"c8e40098802f73d35d3f4276a7f90cf243824839","unresolved":false,"context_lines":[{"line_number":3277,"context_line":"    # the root provider ID and the third being resource class ID. Get the list"},{"line_number":3278,"context_line":"    # of root provider IDs and get all trees that collectively have all"},{"line_number":3279,"context_line":"    # required traits."},{"line_number":3280,"context_line":"    trees_with_inv \u003d set()"},{"line_number":3281,"context_line":""},{"line_number":3282,"context_line":"    for rc_id, amount in resources.items():"},{"line_number":3283,"context_line":"        rc_provs_with_inv \u003d _get_providers_with_resource(ctx, rc_id, amount)"}],"source_content_type":"text/x-python","patch_set":2,"id":"9fdfeff1_8d33abf6","line":3280,"range":{"start_line":3280,"start_character":4,"end_line":3280,"end_character":26},"updated":"2019-02-21 21:30:33.000000000","message":"Does it not work to initialize this with [tree_id] instead of filtering after the loop?\n\n(I tried it locally, and it at least passes all the functional tests as written, in this patch and the next. I didn\u0027t dig further than that.)","commit_id":"a4954b190ee21e80a18cd8a22d1cf27ca11e33f8"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"c8e40098802f73d35d3f4276a7f90cf243824839","unresolved":false,"context_lines":[{"line_number":3280,"context_line":"    trees_with_inv \u003d set()"},{"line_number":3281,"context_line":""},{"line_number":3282,"context_line":"    for rc_id, amount in resources.items():"},{"line_number":3283,"context_line":"        rc_provs_with_inv \u003d _get_providers_with_resource(ctx, rc_id, amount)"},{"line_number":3284,"context_line":"        if not rc_provs_with_inv:"},{"line_number":3285,"context_line":"            # If there\u0027s no providers that have one of the resource classes,"},{"line_number":3286,"context_line":"            # then we can short-circuit"}],"source_content_type":"text/x-python","patch_set":2,"id":"9fdfeff1_2de87fb1","line":3283,"updated":"2019-02-21 21:30:33.000000000","message":"Another possibility here, on the same principle as above for the non-tree case, is to first get_providers_in_tree(tree_id) [1] and then pass that list into _get_providers_with_resource with the modifications suggested above. That way we\u0027re (again) not getting a huge number of providers when we already know the teeny subset it could possibly be.\n\n[1] Dah, we don\u0027t seem to have that method yet, but it would be trivial, like SELECT id from resource_providers where root_provider_id \u003d\u003d tree_id","commit_id":"a4954b190ee21e80a18cd8a22d1cf27ca11e33f8"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"fc4608c661b62a6705709a558c9c75824f15bc64","unresolved":false,"context_lines":[{"line_number":3280,"context_line":"    trees_with_inv \u003d set()"},{"line_number":3281,"context_line":""},{"line_number":3282,"context_line":"    for rc_id, amount in resources.items():"},{"line_number":3283,"context_line":"        rc_provs_with_inv \u003d _get_providers_with_resource(ctx, rc_id, amount)"},{"line_number":3284,"context_line":"        if not rc_provs_with_inv:"},{"line_number":3285,"context_line":"            # If there\u0027s no providers that have one of the resource classes,"},{"line_number":3286,"context_line":"            # then we can short-circuit"}],"source_content_type":"text/x-python","patch_set":2,"id":"9fdfeff1_48613111","line":3283,"in_reply_to":"9fdfeff1_2de87fb1","updated":"2019-02-21 22:04:48.000000000","message":"[Later] Having seen the next patch, I\u0027m thinking you can get that list at [1] and pass it (instead of the single id of the tree root) into _get_provider_ids_matching and _get_trees_matching_all; then pass it through hot _get_providers_with_resource in both places.\n\n[1] https://review.openstack.org/#/c/635723/3/placement/objects/resource_provider.py@4084","commit_id":"a4954b190ee21e80a18cd8a22d1cf27ca11e33f8"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"c8e40098802f73d35d3f4276a7f90cf243824839","unresolved":false,"context_lines":[{"line_number":3320,"context_line":"    if not provs_with_inv:"},{"line_number":3321,"context_line":"        return []"},{"line_number":3322,"context_line":""},{"line_number":3323,"context_line":"    if tree_id is not None:"},{"line_number":3324,"context_line":"        provs_with_inv \u003d set(p for p in provs_with_inv if p[1] \u003d\u003d tree_id)"},{"line_number":3325,"context_line":""},{"line_number":3326,"context_line":"    # If \u0027member_of\u0027 has values, do a separate lookup to identify the"},{"line_number":3327,"context_line":"    # resource providers that meet the member_of constraints."}],"source_content_type":"text/x-python","patch_set":2,"id":"9fdfeff1_adec6fbb","line":3324,"range":{"start_line":3323,"start_character":0,"end_line":3324,"end_character":74},"updated":"2019-02-21 21:30:33.000000000","message":"I thought this would break the sharing case, but on further inspection, if p is a sharing provider, then p[1] is its *anchor* root provider, not its actual root.\n\nI think the comment on L3304-6 could stand to be enhanced to make that clearer. (Unrelated to this change.)","commit_id":"a4954b190ee21e80a18cd8a22d1cf27ca11e33f8"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"c8e40098802f73d35d3f4276a7f90cf243824839","unresolved":false,"context_lines":[{"line_number":3322,"context_line":""},{"line_number":3323,"context_line":"    if tree_id is not None:"},{"line_number":3324,"context_line":"        provs_with_inv \u003d set(p for p in provs_with_inv if p[1] \u003d\u003d tree_id)"},{"line_number":3325,"context_line":""},{"line_number":3326,"context_line":"    # If \u0027member_of\u0027 has values, do a separate lookup to identify the"},{"line_number":3327,"context_line":"    # resource providers that meet the member_of constraints."},{"line_number":3328,"context_line":"    if member_of:"}],"source_content_type":"text/x-python","patch_set":2,"id":"9fdfeff1_e8a7c508","line":3325,"updated":"2019-02-21 21:30:33.000000000","message":"Whatever approach we decide on, let\u0027s make a debug log for this code path. (This whole method could use debug logging, and that\u0027s good for a separate patch, but we should at least add this one here.) (If we do the thing where we add [providers_in_tree] to _get_providers_with_resource, we get a twofer.)","commit_id":"a4954b190ee21e80a18cd8a22d1cf27ca11e33f8"},{"author":{"_account_id":25625,"name":"Tetsuro Nakamura","email":"tetsuro.nakamura.bc@hco.ntt.co.jp","username":"tetsuro0907"},"change_message_id":"2f59a07aeab1891a4be098fdc9b708adb7a42585","unresolved":false,"context_lines":[{"line_number":3322,"context_line":""},{"line_number":3323,"context_line":"    if tree_id is not None:"},{"line_number":3324,"context_line":"        provs_with_inv \u003d set(p for p in provs_with_inv if p[1] \u003d\u003d tree_id)"},{"line_number":3325,"context_line":""},{"line_number":3326,"context_line":"    # If \u0027member_of\u0027 has values, do a separate lookup to identify the"},{"line_number":3327,"context_line":"    # resource providers that meet the member_of constraints."},{"line_number":3328,"context_line":"    if member_of:"}],"source_content_type":"text/x-python","patch_set":2,"id":"9fdfeff1_bbc7c064","line":3325,"in_reply_to":"9fdfeff1_e8a7c508","updated":"2019-02-22 09:08:30.000000000","message":"Added TODO.","commit_id":"a4954b190ee21e80a18cd8a22d1cf27ca11e33f8"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"a128c6105873b2cf67469b0f748da00e0e4e7efc","unresolved":false,"context_lines":[{"line_number":3303,"context_line":"            # should also get combinations of (sharing provider, anchor root)"},{"line_number":3304,"context_line":"            # in addition to (non-sharing provider, anchor root) we already"},{"line_number":3305,"context_line":"            # have."},{"line_number":3306,"context_line":"            rc_provs_with_inv \u003d _anchors_for_sharing_providers("},{"line_number":3307,"context_line":"                                        ctx, sharing_providers, get_id\u003dTrue)"},{"line_number":3308,"context_line":"            rc_provs_with_inv \u003d set("},{"line_number":3309,"context_line":"                (p[0], p[1], rc_id) for p in rc_provs_with_inv)"},{"line_number":3310,"context_line":"            rc_trees |\u003d set(p[1] for p in rc_provs_with_inv)"}],"source_content_type":"text/x-python","patch_set":3,"id":"9fdfeff1_d7d61054","line":3307,"range":{"start_line":3306,"start_character":0,"end_line":3307,"end_character":76},"updated":"2019-02-22 14:51:31.000000000","message":"Why don\u0027t you filter out the invalid sharing providers here by passing tree_root_id into _anchors_for_sharing_providers?","commit_id":"c37603aeb9384cc7388e7ca7ac031009705d14bc"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"a128c6105873b2cf67469b0f748da00e0e4e7efc","unresolved":false,"context_lines":[{"line_number":3332,"context_line":"    if tree_root_id is not None:"},{"line_number":3333,"context_line":"        # _get_providers_with_resource() has already filtered the tree,"},{"line_number":3334,"context_line":"        # but we need this again to filter unrelated sharing providers"},{"line_number":3335,"context_line":"        # that are mixed after the first filtering"},{"line_number":3336,"context_line":"        provs_with_inv \u003d set(p for p in provs_with_inv if p[1] \u003d\u003d tree_root_id)"},{"line_number":3337,"context_line":""},{"line_number":3338,"context_line":"    # If \u0027member_of\u0027 has values, do a separate lookup to identify the"}],"source_content_type":"text/x-python","patch_set":3,"id":"9fdfeff1_8c015f09","line":3335,"updated":"2019-02-22 14:51:31.000000000","message":"Oh, yeah.\n\nYou could filter them out closer to the source - see above.","commit_id":"c37603aeb9384cc7388e7ca7ac031009705d14bc"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"982d77a39f1c723aed82fd099d53f65ec162417a","unresolved":false,"context_lines":[{"line_number":3332,"context_line":"    if tree_root_id is not None:"},{"line_number":3333,"context_line":"        # _get_providers_with_resource() has already filtered the tree,"},{"line_number":3334,"context_line":"        # but we need this again to filter unrelated sharing providers"},{"line_number":3335,"context_line":"        # that are mixed after the first filtering"},{"line_number":3336,"context_line":"        provs_with_inv \u003d set(p for p in provs_with_inv if p[1] \u003d\u003d tree_root_id)"},{"line_number":3337,"context_line":""},{"line_number":3338,"context_line":"    # If \u0027member_of\u0027 has values, do a separate lookup to identify the"}],"source_content_type":"text/x-python","patch_set":3,"id":"9fdfeff1_5807adca","line":3335,"in_reply_to":"9fdfeff1_8c015f09","updated":"2019-02-22 17:02:14.000000000","message":"[Later] I tested this out by adding a second shared storage provider to the gabbi fixture [1]. As predicted, I needed to enhance the result of one of your new sharing test cases [2] - the one that didn\u0027t specify in_tree for the shared disk - but not the other [3] because the in_tree restricts the shared disk as expected.\n\nBUT\n\nWhen I remove this chunk of code, the tests (as modified) still pass. Which means one of two things: Either this extra filter isn\u0027t actually necessary; or my test assumptions are bogus.\n\n[1] https://review.openstack.org/#/c/638712/\n[2] https://review.openstack.org/#/c/638712/1/placement/tests/functional/gabbits/allocation-candidates.yaml@543\n[3] https://review.openstack.org/#/c/638712/1/placement/tests/functional/gabbits/allocation-candidates.yaml@548","commit_id":"c37603aeb9384cc7388e7ca7ac031009705d14bc"},{"author":{"_account_id":11564,"name":"Chris Dent","email":"cdent@anticdent.org","username":"chdent"},"change_message_id":"0e5f84ac823a726cdace9d626bc09aebe4b9dafa","unresolved":false,"context_lines":[{"line_number":3042,"context_line":"                      supplied aggregates of each aggregate UUID list."},{"line_number":3043,"context_line":"    :param tree_root_id: An optional root resource provider ID. If provided,"},{"line_number":3044,"context_line":"                         the result will only be for the given resource"},{"line_number":3045,"context_line":"                         provider or empty list if it can\u0027t satisfy the request"},{"line_number":3046,"context_line":"    \"\"\""},{"line_number":3047,"context_line":"    # The iteratively filtered set of resource provider internal IDs that match"},{"line_number":3048,"context_line":"    # all the constraints in the request"}],"source_content_type":"text/x-python","patch_set":5,"id":"9fdfeff1_3e5f1010","line":3045,"updated":"2019-02-25 17:15:05.000000000","message":"This description doesn\u0027t really match the name? Maybe fix it in followup?","commit_id":"12d216044d7bb68ba1363715f1727d5b620279a5"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"5468151c3ea0e7db30840ad45caf21d005392f1f","unresolved":false,"context_lines":[{"line_number":3042,"context_line":"                      supplied aggregates of each aggregate UUID list."},{"line_number":3043,"context_line":"    :param tree_root_id: An optional root resource provider ID. If provided,"},{"line_number":3044,"context_line":"                         the result will only be for the given resource"},{"line_number":3045,"context_line":"                         provider or empty list if it can\u0027t satisfy the request"},{"line_number":3046,"context_line":"    \"\"\""},{"line_number":3047,"context_line":"    # The iteratively filtered set of resource provider internal IDs that match"},{"line_number":3048,"context_line":"    # all the constraints in the request"}],"source_content_type":"text/x-python","patch_set":5,"id":"9fdfeff1_d7790782","line":3045,"in_reply_to":"9fdfeff1_3e5f1010","updated":"2019-02-25 19:02:27.000000000","message":"Done","commit_id":"12d216044d7bb68ba1363715f1727d5b620279a5"},{"author":{"_account_id":11564,"name":"Chris Dent","email":"cdent@anticdent.org","username":"chdent"},"change_message_id":"0e5f84ac823a726cdace9d626bc09aebe4b9dafa","unresolved":false,"context_lines":[{"line_number":3164,"context_line":"            sa.or_(rpt.c.root_provider_id \u003d\u003d tree_root_id,"},{"line_number":3165,"context_line":"                   rpt.c.id \u003d\u003d tree_root_id),"},{"line_number":3166,"context_line":"            where_conds)"},{"line_number":3167,"context_line":"    sel \u003d sel.where(sa.and_(*where_conds))"},{"line_number":3168,"context_line":"    res \u003d ctx.session.execute(sel).fetchall()"},{"line_number":3169,"context_line":"    res \u003d set((r[0], r[1]) for r in res)"},{"line_number":3170,"context_line":"    # TODO(tetsuro): Bug#1799892: We could have old providers with no root"}],"source_content_type":"text/x-python","patch_set":5,"id":"9fdfeff1_fe61883a","line":3167,"updated":"2019-02-25 17:15:05.000000000","message":"I\u0027m not convinced that the aggregation of the and clauses here is correct.\n\n_cacapity_check_check_clause returns an sa.and_ which we then and with tree root if we need to\n\nand then we and_ it again\n\nIf the above is changed to:\n\n    sel \u003d sel.where(where_conds)\n\nThe tests still pass. In fact the query generated by sqlalchemy is the same, so it recognizes the duplication and ignores it, so maybe we can do the simpler thing?\n\nThe other option would be to generation two different clauses and then only and them once the where is called.","commit_id":"12d216044d7bb68ba1363715f1727d5b620279a5"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"5468151c3ea0e7db30840ad45caf21d005392f1f","unresolved":false,"context_lines":[{"line_number":3164,"context_line":"            sa.or_(rpt.c.root_provider_id \u003d\u003d tree_root_id,"},{"line_number":3165,"context_line":"                   rpt.c.id \u003d\u003d tree_root_id),"},{"line_number":3166,"context_line":"            where_conds)"},{"line_number":3167,"context_line":"    sel \u003d sel.where(sa.and_(*where_conds))"},{"line_number":3168,"context_line":"    res \u003d ctx.session.execute(sel).fetchall()"},{"line_number":3169,"context_line":"    res \u003d set((r[0], r[1]) for r in res)"},{"line_number":3170,"context_line":"    # TODO(tetsuro): Bug#1799892: We could have old providers with no root"}],"source_content_type":"text/x-python","patch_set":5,"id":"9fdfeff1_d75587c3","line":3167,"in_reply_to":"9fdfeff1_fe61883a","updated":"2019-02-25 19:02:27.000000000","message":"Done.\n\nI actually suspect sqla is reducing this immediately, like way before it even tries to generate the SQL.\n\nAnyway, I just took out the last `and_`. This still winds us up with a redundant `and`, but I didn\u0027t want to try to refactor _capacity_check_clause to return a list to which the tree conditions could be appended so I could `and` the whole thing and have zero redundancy.","commit_id":"12d216044d7bb68ba1363715f1727d5b620279a5"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"da181c960c753b7df18ac047acba105f5aac7330","unresolved":false,"context_lines":[{"line_number":3339,"context_line":"        provs_with_inv |\u003d set((p[0], p[1], rc_id) for p in rc_provs_with_inv)"},{"line_number":3340,"context_line":""},{"line_number":3341,"context_line":"        sharing_providers \u003d sharing.get(rc_id)"},{"line_number":3342,"context_line":"        if sharing_providers and tree_root_id is None:"},{"line_number":3343,"context_line":"            # There are sharing providers for this resource class, so we"},{"line_number":3344,"context_line":"            # should also get combinations of (sharing provider, anchor root)"},{"line_number":3345,"context_line":"            # in addition to (non-sharing provider, anchor root) we\u0027ve just"}],"source_content_type":"text/x-python","patch_set":5,"id":"9fdfeff1_d90f03de","line":3342,"range":{"start_line":3342,"start_character":28,"end_line":3342,"end_character":54},"updated":"2019-02-25 14:46:01.000000000","message":"Just to follow up on this, I finished rebasing [1] and it still behaves as expected, so I\u0027m satisfied that this is working; and I\u0027m delighted that your solution is even more efficient than the one I originally suggested.\n\n[1] https://review.openstack.org/#/c/638712/","commit_id":"12d216044d7bb68ba1363715f1727d5b620279a5"}],"placement/tests/functional/db/test_allocation_candidates.py":[{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"c8e40098802f73d35d3f4276a7f90cf243824839","unresolved":false,"context_lines":[{"line_number":2468,"context_line":"        \"\"\"Tests that we properly winnow allocation requests when including"},{"line_number":2469,"context_line":"        shared and nested providers"},{"line_number":2470,"context_line":"        \"\"\""},{"line_number":2471,"context_line":"        # We are setting up 2 cn trees with 2 shared storages"},{"line_number":2472,"context_line":"        # that look like this:"},{"line_number":2473,"context_line":"        #"},{"line_number":2474,"context_line":"        #              compute node (cn1)      ----- shared storage (ss1)"},{"line_number":2475,"context_line":"        #             /                 \\       agg1       with 2000 DISK_GB"},{"line_number":2476,"context_line":"        #            /                   \\"},{"line_number":2477,"context_line":"        #       numa cell 1_0        numa cell 1_1"},{"line_number":2478,"context_line":"        #           |                    |"},{"line_number":2479,"context_line":"        #           |                    |"},{"line_number":2480,"context_line":"        #         pf 1_0               pf 1_1(HW_NIC_OFFLOAD_GENEVE)"},{"line_number":2481,"context_line":"        #"},{"line_number":2482,"context_line":"        #              compute node (cn2)      ----- shared storage (ss2)"},{"line_number":2483,"context_line":"        #             /                 \\       agg2       with 1000 DISK_GB"},{"line_number":2484,"context_line":"        #            /                   \\"},{"line_number":2485,"context_line":"        #       numa cell 2_0        numa cell 2_1"},{"line_number":2486,"context_line":"        #           |                    |"},{"line_number":2487,"context_line":"        #           |                    |"},{"line_number":2488,"context_line":"        #         pf 2_0               pf 2_1(HW_NIC_OFFLOAD_GENEVE)"},{"line_number":2489,"context_line":"        #"},{"line_number":2490,"context_line":"        # The second physical function in both trees (pf1_1, pf 2_1) will be"},{"line_number":2491,"context_line":"        # associated with the HW_NIC_OFFLOAD_GENEVE trait, but not the first"}],"source_content_type":"text/x-python","patch_set":2,"id":"9fdfeff1_68d3d560","line":2488,"range":{"start_line":2471,"start_character":0,"end_line":2488,"end_character":68},"updated":"2019-02-21 21:30:33.000000000","message":"Let\u0027s have a test involving sharing, please.\n\nFor example, if we ask for 1500 GB of disk with in_tree\u003dcn1 we should hit cn1+ss1, but with in_tree\u003dcn2 we should fail (because insufficient DISK_GB in ss2).","commit_id":"a4954b190ee21e80a18cd8a22d1cf27ca11e33f8"}]}
