)]}'
{"/COMMIT_MSG":[{"author":{"_account_id":25625,"name":"Tetsuro Nakamura","email":"tetsuro.nakamura.bc@hco.ntt.co.jp","username":"tetsuro0907"},"change_message_id":"90e4908ac19630ae7bbe2673311f228ff9d9d7d4","unresolved":false,"context_lines":[{"line_number":12,"context_line":"This patch fixes it to include all the providers in trees in play."},{"line_number":13,"context_line":""},{"line_number":14,"context_line":"Change-Id: I108dceb13bdefc541b272ea953acc1dec2945647"},{"line_number":15,"context_line":"Blueprint: placement-return-all-res"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":26,"id":"5f7c97a3_214c80c6","line":15,"range":{"start_line":15,"start_character":32,"end_line":15,"end_character":35},"updated":"2018-06-13 01:09:58.000000000","message":"resources...","commit_id":"78bdd8cd92bcd58b50e443b56b174df3335d7865"},{"author":{"_account_id":25625,"name":"Tetsuro Nakamura","email":"tetsuro.nakamura.bc@hco.ntt.co.jp","username":"tetsuro0907"},"change_message_id":"b390471d944cf0afdd9cfc044cdfc92db4bf738b","unresolved":false,"context_lines":[{"line_number":12,"context_line":"This patch fixes it to include all the providers in trees in play."},{"line_number":13,"context_line":""},{"line_number":14,"context_line":"Change-Id: I108dceb13bdefc541b272ea953acc1dec2945647"},{"line_number":15,"context_line":"Blueprint: placement-return-all-res"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":26,"id":"5f7c97a3_e1c76811","line":15,"range":{"start_line":15,"start_character":32,"end_line":15,"end_character":35},"in_reply_to":"5f7c97a3_214c80c6","updated":"2018-06-13 01:11:14.000000000","message":"Done","commit_id":"78bdd8cd92bcd58b50e443b56b174df3335d7865"}],"nova/api/openstack/placement/objects/resource_provider.py":[{"author":{"_account_id":25625,"name":"Tetsuro Nakamura","email":"tetsuro.nakamura.bc@hco.ntt.co.jp","username":"tetsuro0907"},"change_message_id":"1cce08968ff1f772da11b33940723ec6a0f17e17","unresolved":false,"context_lines":[{"line_number":2791,"context_line":"    \"\"\""},{"line_number":2792,"context_line":"    # We build up a SQL expression that looks like this:"},{"line_number":2793,"context_line":"    # SELECT"},{"line_number":2794,"context_line":"    #   rp.id as resource_provider_id"},{"line_number":2795,"context_line":"    # , rp.uuid as resource_provider_uuid"},{"line_number":2796,"context_line":"    # , inv.resource_class_id"},{"line_number":2797,"context_line":"    # , inv.total"}],"source_content_type":"text/x-python","patch_set":1,"id":"bf659307_c19e7f53","line":2794,"updated":"2018-04-07 09:32:52.000000000","message":", rp.parent_provider_id as parent_provider_id\n, rp.root_provider_id as root_provider_id","commit_id":"ffd4f55e0a16215b5994177d4ce13bac8a6a6e7a"},{"author":{"_account_id":25625,"name":"Tetsuro Nakamura","email":"tetsuro.nakamura.bc@hco.ntt.co.jp","username":"tetsuro0907"},"change_message_id":"1cce08968ff1f772da11b33940723ec6a0f17e17","unresolved":false,"context_lines":[{"line_number":2811,"context_line":"    # AS usages"},{"line_number":2812,"context_line":"    #   ON inv.resource_provider_id \u003d usage.resource_provider_id"},{"line_number":2813,"context_line":"    #   AND inv.resource_class_id \u003d usage.resource_class_id"},{"line_number":2814,"context_line":"    # WHERE rp.id IN ($rp_ids)"},{"line_number":2815,"context_line":"    # AND inv.resource_class_id IN ($rc_ids)"},{"line_number":2816,"context_line":"    rpt \u003d sa.alias(_RP_TBL, name\u003d\"rp\")"},{"line_number":2817,"context_line":"    inv \u003d sa.alias(_INV_TBL, name\u003d\"inv\")"}],"source_content_type":"text/x-python","patch_set":1,"id":"bf659307_a1a10b98","line":2814,"updated":"2018-04-07 09:32:52.000000000","message":"OR rp.root_provider_id IN ($rp_ids)","commit_id":"ffd4f55e0a16215b5994177d4ce13bac8a6a6e7a"},{"author":{"_account_id":25625,"name":"Tetsuro Nakamura","email":"tetsuro.nakamura.bc@hco.ntt.co.jp","username":"tetsuro0907"},"change_message_id":"892f862f7c4b98d813831af3dcf8d19572bae4ea","unresolved":false,"context_lines":[{"line_number":3443,"context_line":"    # Grab usage summaries for each provider (local or sharing)"},{"line_number":3444,"context_line":"    usages \u003d _get_usages_by_provider(ctx, all_rp_ids)"},{"line_number":3445,"context_line":""},{"line_number":3446,"context_line":"    # Build a reference dictionary keyed by resource provider internal ID"},{"line_number":3447,"context_line":"    rp_ref_dict \u003d {usage[\u0027resource_provider_id\u0027]: usage for usage in usages}"},{"line_number":3448,"context_line":""},{"line_number":3449,"context_line":"    # Get a dict, keyed by resource provider internal ID, of trait string names"}],"source_content_type":"text/x-python","patch_set":2,"id":"bf659307_a6191a89","line":3446,"range":{"start_line":3446,"start_character":12,"end_line":3446,"end_character":73},"updated":"2018-04-08 10:32:08.000000000","message":"a reference dictionary to translate from its \"resource_provider_id\" to its \"parent_provider_id\", \"root_provider_id\", and \"resource_provider_uuid\" .","commit_id":"9663f36c40ef8213b41142bf00b0b0576dd108d5"},{"author":{"_account_id":25625,"name":"Tetsuro Nakamura","email":"tetsuro.nakamura.bc@hco.ntt.co.jp","username":"tetsuro0907"},"change_message_id":"892f862f7c4b98d813831af3dcf8d19572bae4ea","unresolved":false,"context_lines":[{"line_number":3445,"context_line":""},{"line_number":3446,"context_line":"    # Build a reference dictionary keyed by resource provider internal ID"},{"line_number":3447,"context_line":"    rp_ref_dict \u003d {usage[\u0027resource_provider_id\u0027]: usage for usage in usages}"},{"line_number":3448,"context_line":""},{"line_number":3449,"context_line":"    # Get a dict, keyed by resource provider internal ID, of trait string names"},{"line_number":3450,"context_line":"    # that provider has associated with it"},{"line_number":3451,"context_line":"    prov_traits \u003d _provider_traits(ctx, all_rp_ids)"}],"source_content_type":"text/x-python","patch_set":2,"id":"bf659307_e67f12a9","line":3448,"updated":"2018-04-08 10:32:08.000000000","message":"add here;\n\n  all_rp_ids |\u003d set(rp_ref_dict)","commit_id":"9663f36c40ef8213b41142bf00b0b0576dd108d5"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"ba2bf3bd9c1eb3b26d04adf4e3315ce7beb168e2","unresolved":false,"context_lines":[{"line_number":2509,"context_line":"@db_api.api_context_manager.reader"},{"line_number":2510,"context_line":"def _get_usages_by_provider(ctx, rp_ids):"},{"line_number":2511,"context_line":"    \"\"\"Returns a row iterator of usage records grouped by resource provider ID"},{"line_number":2512,"context_line":"    and resource class ID for all resource providers"},{"line_number":2513,"context_line":"    \"\"\""},{"line_number":2514,"context_line":"    # We build up a SQL expression that looks like this:"},{"line_number":2515,"context_line":"    # SELECT"}],"source_content_type":"text/x-python","patch_set":21,"id":"5f7c97a3_f43f8d84","line":2512,"range":{"start_line":2512,"start_character":30,"end_line":2512,"end_character":52},"updated":"2018-06-07 19:41:32.000000000","message":"\"...all resource providers in all trees indicated in rp_ids.\"\n\nOr something.  See below.","commit_id":"34414a0f3afd4dcc27198ac066d15d9e725f2107"},{"author":{"_account_id":25625,"name":"Tetsuro Nakamura","email":"tetsuro.nakamura.bc@hco.ntt.co.jp","username":"tetsuro0907"},"change_message_id":"6757b8b32a8454c1549f39a766da3d01e45d328d","unresolved":false,"context_lines":[{"line_number":2509,"context_line":"@db_api.api_context_manager.reader"},{"line_number":2510,"context_line":"def _get_usages_by_provider(ctx, rp_ids):"},{"line_number":2511,"context_line":"    \"\"\"Returns a row iterator of usage records grouped by resource provider ID"},{"line_number":2512,"context_line":"    and resource class ID for all resource providers"},{"line_number":2513,"context_line":"    \"\"\""},{"line_number":2514,"context_line":"    # We build up a SQL expression that looks like this:"},{"line_number":2515,"context_line":"    # SELECT"}],"source_content_type":"text/x-python","patch_set":21,"id":"5f7c97a3_6915dbe4","line":2512,"range":{"start_line":2512,"start_character":30,"end_line":2512,"end_character":52},"in_reply_to":"5f7c97a3_f43f8d84","updated":"2018-06-08 06:29:26.000000000","message":"Done","commit_id":"34414a0f3afd4dcc27198ac066d15d9e725f2107"},{"author":{"_account_id":7,"name":"Jay Pipes","email":"jaypipes@gmail.com","username":"jaypipes"},"change_message_id":"7b8db90e3cec59e483831da917f3e21189ac7316","unresolved":false,"context_lines":[{"line_number":2522,"context_line":"    # , inv.max_unit"},{"line_number":2523,"context_line":"    # , usage.used"},{"line_number":2524,"context_line":"    # FROM resource_providers AS rp"},{"line_number":2525,"context_line":"    # LEFT JOIN inventories AS inv"},{"line_number":2526,"context_line":"    #  ON rp.id \u003d inv.resource_provider_id"},{"line_number":2527,"context_line":"    # LEFT JOIN ("},{"line_number":2528,"context_line":"    #   SELECT resource_provider_id, resource_class_id, SUM(used) as used"}],"source_content_type":"text/x-python","patch_set":21,"id":"5f7c97a3_23dced16","line":2525,"updated":"2018-06-07 17:43:33.000000000","message":"note for future...\n\nwe should refactor all these additions of LEFT JOINs out in the future and just do a single query to get all providers in the trees of any resource-matching provider. That way we continue to have a more efficient query for usage and inventory information and only do the \"expand from provider -\u003e provider tree\" query once, and only when nested providers are even in use.","commit_id":"34414a0f3afd4dcc27198ac066d15d9e725f2107"},{"author":{"_account_id":25625,"name":"Tetsuro Nakamura","email":"tetsuro.nakamura.bc@hco.ntt.co.jp","username":"tetsuro0907"},"change_message_id":"6757b8b32a8454c1549f39a766da3d01e45d328d","unresolved":false,"context_lines":[{"line_number":2522,"context_line":"    # , inv.max_unit"},{"line_number":2523,"context_line":"    # , usage.used"},{"line_number":2524,"context_line":"    # FROM resource_providers AS rp"},{"line_number":2525,"context_line":"    # LEFT JOIN inventories AS inv"},{"line_number":2526,"context_line":"    #  ON rp.id \u003d inv.resource_provider_id"},{"line_number":2527,"context_line":"    # LEFT JOIN ("},{"line_number":2528,"context_line":"    #   SELECT resource_provider_id, resource_class_id, SUM(used) as used"}],"source_content_type":"text/x-python","patch_set":21,"id":"5f7c97a3_89ce3781","line":2525,"in_reply_to":"5f7c97a3_23dced16","updated":"2018-06-08 06:29:26.000000000","message":"So for the first step we should create(revive) an optimization path for neither nested or sharing providers are not in use... is that what you want to say? I\u0027m good with that, because the new paths for nested candidates are pretty exercised by the test cases that had been created before for that simple case of no nested/sharing path.","commit_id":"34414a0f3afd4dcc27198ac066d15d9e725f2107"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"ba2bf3bd9c1eb3b26d04adf4e3315ce7beb168e2","unresolved":false,"context_lines":[{"line_number":2533,"context_line":"    # AS usages"},{"line_number":2534,"context_line":"    #   ON inv.resource_provider_id \u003d usage.resource_provider_id"},{"line_number":2535,"context_line":"    #   AND inv.resource_class_id \u003d usage.resource_class_id"},{"line_number":2536,"context_line":"    # WHERE rp.id IN ($rp_ids) OR rp.root_provider_id IN ($rp_ids)"},{"line_number":2537,"context_line":"    rpt \u003d sa.alias(_RP_TBL, name\u003d\"rp\")"},{"line_number":2538,"context_line":"    inv \u003d sa.alias(_INV_TBL, name\u003d\"inv\")"},{"line_number":2539,"context_line":"    # Build our derived table (subquery in the FROM clause) that sums used"}],"source_content_type":"text/x-python","patch_set":21,"id":"5f7c97a3_f9db064c","line":2536,"range":{"start_line":2536,"start_character":31,"end_line":2536,"end_character":66},"updated":"2018-06-07 19:41:32.000000000","message":"This seems upside down to me.  Are we guaranteed that the rp_ids list contains all root providers corresponding to any child providers therein?\n\nI expected the logic to read more like:\n\n WHERE rp.root_provider_id in (\n   SELECT DISTINCT root_provider_id\n     FROM resource_providers\n     WHERE id IN ($rp_ids))\n\n(Or whatever the JOINy equivalent might be.)\n\nThe test case for this would be a query where some candidates are satisfied only by non-root providers.\n\n[Later] Well, I found such a test scenario.  So I guess this is working.\n\n[Even later] I tracked down calls to this method, and it looks like if we go through _allocation_candidates_single_provider, which happens when we\u0027re dealing with a granular group, we aren\u0027t necessarily passing root provider IDs, so this breaks as I suspected.","commit_id":"34414a0f3afd4dcc27198ac066d15d9e725f2107"},{"author":{"_account_id":25625,"name":"Tetsuro Nakamura","email":"tetsuro.nakamura.bc@hco.ntt.co.jp","username":"tetsuro0907"},"change_message_id":"6757b8b32a8454c1549f39a766da3d01e45d328d","unresolved":false,"context_lines":[{"line_number":2533,"context_line":"    # AS usages"},{"line_number":2534,"context_line":"    #   ON inv.resource_provider_id \u003d usage.resource_provider_id"},{"line_number":2535,"context_line":"    #   AND inv.resource_class_id \u003d usage.resource_class_id"},{"line_number":2536,"context_line":"    # WHERE rp.id IN ($rp_ids) OR rp.root_provider_id IN ($rp_ids)"},{"line_number":2537,"context_line":"    rpt \u003d sa.alias(_RP_TBL, name\u003d\"rp\")"},{"line_number":2538,"context_line":"    inv \u003d sa.alias(_INV_TBL, name\u003d\"inv\")"},{"line_number":2539,"context_line":"    # Build our derived table (subquery in the FROM clause) that sums used"}],"source_content_type":"text/x-python","patch_set":21,"id":"5f7c97a3_a9c5333f","line":2536,"range":{"start_line":2536,"start_character":31,"end_line":2536,"end_character":66},"in_reply_to":"5f7c97a3_f9db064c","updated":"2018-06-08 06:29:26.000000000","message":"Good catch. But I\u0027d like to avoid to issue a subquery for this...\nDone in the same way for cases that multiple providers are in play in a following patch. Thank you so much for this find!","commit_id":"34414a0f3afd4dcc27198ac066d15d9e725f2107"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"ba2bf3bd9c1eb3b26d04adf4e3315ce7beb168e2","unresolved":false,"context_lines":[{"line_number":3691,"context_line":""},{"line_number":3692,"context_line":"    # Now we have to produce provider summaries.  The provider summaries in"},{"line_number":3693,"context_line":"    # the candidates input contain all the information; we just need to"},{"line_number":3694,"context_line":"    # filter it down to only the providers in our merged list of allocation"},{"line_number":3695,"context_line":"    # requests."},{"line_number":3696,"context_line":"    tree_uuids \u003d set()"},{"line_number":3697,"context_line":"    for areq in areqs:"}],"source_content_type":"text/x-python","patch_set":21,"id":"5f7c97a3_d9708add","line":3694,"range":{"start_line":3694,"start_character":33,"end_line":3694,"end_character":56},"updated":"2018-06-07 19:41:32.000000000","message":"\"...providers in trees represented by our merged...\"\n\nor something.","commit_id":"34414a0f3afd4dcc27198ac066d15d9e725f2107"},{"author":{"_account_id":25625,"name":"Tetsuro Nakamura","email":"tetsuro.nakamura.bc@hco.ntt.co.jp","username":"tetsuro0907"},"change_message_id":"6757b8b32a8454c1549f39a766da3d01e45d328d","unresolved":false,"context_lines":[{"line_number":3691,"context_line":""},{"line_number":3692,"context_line":"    # Now we have to produce provider summaries.  The provider summaries in"},{"line_number":3693,"context_line":"    # the candidates input contain all the information; we just need to"},{"line_number":3694,"context_line":"    # filter it down to only the providers in our merged list of allocation"},{"line_number":3695,"context_line":"    # requests."},{"line_number":3696,"context_line":"    tree_uuids \u003d set()"},{"line_number":3697,"context_line":"    for areq in areqs:"}],"source_content_type":"text/x-python","patch_set":21,"id":"5f7c97a3_69671bb9","line":3694,"range":{"start_line":3694,"start_character":33,"end_line":3694,"end_character":56},"in_reply_to":"5f7c97a3_d9708add","updated":"2018-06-08 06:29:26.000000000","message":"Done","commit_id":"34414a0f3afd4dcc27198ac066d15d9e725f2107"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"76fb170a68568c413d25e2ecc7fa72c72a9e5117","unresolved":false,"context_lines":[{"line_number":2509,"context_line":"@db_api.api_context_manager.reader"},{"line_number":2510,"context_line":"def _get_usages_by_provider(ctx, rp_ids):"},{"line_number":2511,"context_line":"    \"\"\"Returns a row iterator of usage records grouped by resource provider ID"},{"line_number":2512,"context_line":"    for all resource providers in all trees indicated in rp_ids."},{"line_number":2513,"context_line":"    \"\"\""},{"line_number":2514,"context_line":"    # We build up a SQL expression that looks like this:"},{"line_number":2515,"context_line":"    # SELECT"}],"source_content_type":"text/x-python","patch_set":23,"id":"5f7c97a3_eb2f95f3","line":2512,"range":{"start_line":2512,"start_character":31,"end_line":2512,"end_character":64},"updated":"2018-06-08 15:33:54.000000000","message":"But this isn\u0027t true as written.  It\u0027s only true if you make the change I suggested.\n\nThe way you\u0027ve implemented this and the subsequent patch, this method should be renamed as:\n\n def _get_usages_by_provider_tree(ctx, root_rp_ids):\n     \"\"\"...\n\n     :param root_rp_ids: Iterable of root provider internal IDs.     \n     \"\"\"","commit_id":"c19871abf0054a4219920b80c0dd51295d801f7a"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"76fb170a68568c413d25e2ecc7fa72c72a9e5117","unresolved":false,"context_lines":[{"line_number":2533,"context_line":"    # AS usages"},{"line_number":2534,"context_line":"    #   ON inv.resource_provider_id \u003d usage.resource_provider_id"},{"line_number":2535,"context_line":"    #   AND inv.resource_class_id \u003d usage.resource_class_id"},{"line_number":2536,"context_line":"    # WHERE rp.id IN ($rp_ids) OR rp.root_provider_id IN ($rp_ids)"},{"line_number":2537,"context_line":"    rpt \u003d sa.alias(_RP_TBL, name\u003d\"rp\")"},{"line_number":2538,"context_line":"    inv \u003d sa.alias(_INV_TBL, name\u003d\"inv\")"},{"line_number":2539,"context_line":"    # Build our derived table (subquery in the FROM clause) that sums used"}],"source_content_type":"text/x-python","patch_set":23,"id":"5f7c97a3_0b4451b7","line":2536,"range":{"start_line":2536,"start_character":12,"end_line":2536,"end_character":34},"updated":"2018-06-08 15:33:54.000000000","message":"The way you\u0027ve done this patch and the subsequent one, you don\u0027t need this part of the condition.","commit_id":"c19871abf0054a4219920b80c0dd51295d801f7a"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"76fb170a68568c413d25e2ecc7fa72c72a9e5117","unresolved":false,"context_lines":[{"line_number":3346,"context_line":""},{"line_number":3347,"context_line":"    # Grab usage summaries for each provider including root providers"},{"line_number":3348,"context_line":"    # that don\u0027t provide the requested resources"},{"line_number":3349,"context_line":"    rp_ids \u003d set(p[0] for p in rp_tuples) | set(p[1] for p in rp_tuples)"},{"line_number":3350,"context_line":"    usages \u003d _get_usages_by_provider(ctx, rp_ids)"},{"line_number":3351,"context_line":""},{"line_number":3352,"context_line":"    # Get a dict, keyed by resource provider internal ID, of trait string names"}],"source_content_type":"text/x-python","patch_set":23,"id":"5f7c97a3_eb99d51e","line":3349,"range":{"start_line":3349,"start_character":44,"end_line":3349,"end_character":71},"updated":"2018-06-08 15:33:54.000000000","message":"You only need to send these (the root provider IDs) to _get_usages_by_provider now.","commit_id":"c19871abf0054a4219920b80c0dd51295d801f7a"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"1f853ff040ec3ca885cd7f0dabba34be45f13042","unresolved":false,"context_lines":[{"line_number":3346,"context_line":""},{"line_number":3347,"context_line":"    # Grab usage summaries for each provider including root providers"},{"line_number":3348,"context_line":"    # that don\u0027t provide the requested resources"},{"line_number":3349,"context_line":"    rp_ids \u003d set(p[0] for p in rp_tuples) | set(p[1] for p in rp_tuples)"},{"line_number":3350,"context_line":"    usages \u003d _get_usages_by_provider(ctx, rp_ids)"},{"line_number":3351,"context_line":""},{"line_number":3352,"context_line":"    # Get a dict, keyed by resource provider internal ID, of trait string names"}],"source_content_type":"text/x-python","patch_set":23,"id":"5f7c97a3_badc5b18","line":3349,"range":{"start_line":3349,"start_character":44,"end_line":3349,"end_character":71},"in_reply_to":"5f7c97a3_bd579a5a","updated":"2018-06-11 22:20:31.000000000","message":"Ah, okay, good call.","commit_id":"c19871abf0054a4219920b80c0dd51295d801f7a"},{"author":{"_account_id":25625,"name":"Tetsuro Nakamura","email":"tetsuro.nakamura.bc@hco.ntt.co.jp","username":"tetsuro0907"},"change_message_id":"2bbbec2b02e4e11826d3bf825cb86ff2a46a0ff5","unresolved":false,"context_lines":[{"line_number":3346,"context_line":""},{"line_number":3347,"context_line":"    # Grab usage summaries for each provider including root providers"},{"line_number":3348,"context_line":"    # that don\u0027t provide the requested resources"},{"line_number":3349,"context_line":"    rp_ids \u003d set(p[0] for p in rp_tuples) | set(p[1] for p in rp_tuples)"},{"line_number":3350,"context_line":"    usages \u003d _get_usages_by_provider(ctx, rp_ids)"},{"line_number":3351,"context_line":""},{"line_number":3352,"context_line":"    # Get a dict, keyed by resource provider internal ID, of trait string names"}],"source_content_type":"text/x-python","patch_set":23,"id":"5f7c97a3_bd579a5a","line":3349,"range":{"start_line":3349,"start_character":44,"end_line":3349,"end_character":71},"in_reply_to":"5f7c97a3_eb99d51e","updated":"2018-06-11 08:43:37.000000000","message":"That\u0027s not true for sharing providers are present cases. Remember that rps in p[1] are *anchor* root providers. Documented well in the code comment.","commit_id":"c19871abf0054a4219920b80c0dd51295d801f7a"},{"author":{"_account_id":11564,"name":"Chris Dent","email":"cdent@anticdent.org","username":"chdent"},"change_message_id":"47cb006efd631f4f5fcf5250afca4cf861b6f9e4","unresolved":false,"context_lines":[{"line_number":3433,"context_line":"    rpt \u003d sa.alias(_RP_TBL, name\u003d\u0027rpt\u0027)"},{"line_number":3434,"context_line":"    rptt \u003d sa.alias(_RP_TRAIT_TBL, name\u003d\u0027rptt\u0027)"},{"line_number":3435,"context_line":"    tt \u003d sa.alias(_TRAIT_TBL, name\u003d\u0027t\u0027)"},{"line_number":3436,"context_line":"    rpt_rptt \u003d sa.join(rpt, rptt, rpt.c.id \u003d\u003d rptt.c.resource_provider_id)"},{"line_number":3437,"context_line":"    j \u003d sa.join(rpt_rptt, tt, rptt.c.trait_id \u003d\u003d tt.c.id)"},{"line_number":3438,"context_line":"    sel \u003d sa.select([rptt.c.resource_provider_id, tt.c.name]).select_from(j)"},{"line_number":3439,"context_line":"    sel \u003d sel.where(rpt.c.root_provider_id.in_(root_ids))"}],"source_content_type":"text/x-python","patch_set":26,"id":"5f7c97a3_97f85b4a","line":3436,"updated":"2018-06-11 20:23:56.000000000","message":"these variable names are getting treacherous, when we come back here in the hoped-for refactoring I hope we can break this acronym style. It leads to sameness and decoding that I struggle with. If I\u0027m i the minority on that struggle, cool, I\u0027ll adapt, but based on the usual style guidelines I would assume not.","commit_id":"78bdd8cd92bcd58b50e443b56b174df3335d7865"},{"author":{"_account_id":25625,"name":"Tetsuro Nakamura","email":"tetsuro.nakamura.bc@hco.ntt.co.jp","username":"tetsuro0907"},"change_message_id":"59e3d1e848f5db209ba591d95670d047fa30ee32","unresolved":false,"context_lines":[{"line_number":3433,"context_line":"    rpt \u003d sa.alias(_RP_TBL, name\u003d\u0027rpt\u0027)"},{"line_number":3434,"context_line":"    rptt \u003d sa.alias(_RP_TRAIT_TBL, name\u003d\u0027rptt\u0027)"},{"line_number":3435,"context_line":"    tt \u003d sa.alias(_TRAIT_TBL, name\u003d\u0027t\u0027)"},{"line_number":3436,"context_line":"    rpt_rptt \u003d sa.join(rpt, rptt, rpt.c.id \u003d\u003d rptt.c.resource_provider_id)"},{"line_number":3437,"context_line":"    j \u003d sa.join(rpt_rptt, tt, rptt.c.trait_id \u003d\u003d tt.c.id)"},{"line_number":3438,"context_line":"    sel \u003d sa.select([rptt.c.resource_provider_id, tt.c.name]).select_from(j)"},{"line_number":3439,"context_line":"    sel \u003d sel.where(rpt.c.root_provider_id.in_(root_ids))"}],"source_content_type":"text/x-python","patch_set":26,"id":"5f7c97a3_41ebbca2","line":3436,"in_reply_to":"5f7c97a3_2f0a3e25","updated":"2018-06-13 01:04:49.000000000","message":"I got it. Thanks!","commit_id":"78bdd8cd92bcd58b50e443b56b174df3335d7865"},{"author":{"_account_id":25625,"name":"Tetsuro Nakamura","email":"tetsuro.nakamura.bc@hco.ntt.co.jp","username":"tetsuro0907"},"change_message_id":"d85d063317c1b087af623e6327969a22dd53bf6f","unresolved":false,"context_lines":[{"line_number":3433,"context_line":"    rpt \u003d sa.alias(_RP_TBL, name\u003d\u0027rpt\u0027)"},{"line_number":3434,"context_line":"    rptt \u003d sa.alias(_RP_TRAIT_TBL, name\u003d\u0027rptt\u0027)"},{"line_number":3435,"context_line":"    tt \u003d sa.alias(_TRAIT_TBL, name\u003d\u0027t\u0027)"},{"line_number":3436,"context_line":"    rpt_rptt \u003d sa.join(rpt, rptt, rpt.c.id \u003d\u003d rptt.c.resource_provider_id)"},{"line_number":3437,"context_line":"    j \u003d sa.join(rpt_rptt, tt, rptt.c.trait_id \u003d\u003d tt.c.id)"},{"line_number":3438,"context_line":"    sel \u003d sa.select([rptt.c.resource_provider_id, tt.c.name]).select_from(j)"},{"line_number":3439,"context_line":"    sel \u003d sel.where(rpt.c.root_provider_id.in_(root_ids))"}],"source_content_type":"text/x-python","patch_set":26,"id":"5f7c97a3_cc8e3d2d","line":3436,"in_reply_to":"5f7c97a3_97f85b4a","updated":"2018-06-12 04:28:15.000000000","message":"Do you mean \"rpt\" should be something like \"rp_tbl\" and rptt should be something like \"rp_trait_tbl\"?","commit_id":"78bdd8cd92bcd58b50e443b56b174df3335d7865"},{"author":{"_account_id":11564,"name":"Chris Dent","email":"cdent@anticdent.org","username":"chdent"},"change_message_id":"77cc0674714825ead4561967752dc0c31ce70259","unresolved":false,"context_lines":[{"line_number":3433,"context_line":"    rpt \u003d sa.alias(_RP_TBL, name\u003d\u0027rpt\u0027)"},{"line_number":3434,"context_line":"    rptt \u003d sa.alias(_RP_TRAIT_TBL, name\u003d\u0027rptt\u0027)"},{"line_number":3435,"context_line":"    tt \u003d sa.alias(_TRAIT_TBL, name\u003d\u0027t\u0027)"},{"line_number":3436,"context_line":"    rpt_rptt \u003d sa.join(rpt, rptt, rpt.c.id \u003d\u003d rptt.c.resource_provider_id)"},{"line_number":3437,"context_line":"    j \u003d sa.join(rpt_rptt, tt, rptt.c.trait_id \u003d\u003d tt.c.id)"},{"line_number":3438,"context_line":"    sel \u003d sa.select([rptt.c.resource_provider_id, tt.c.name]).select_from(j)"},{"line_number":3439,"context_line":"    sel \u003d sel.where(rpt.c.root_provider_id.in_(root_ids))"}],"source_content_type":"text/x-python","patch_set":26,"id":"5f7c97a3_2f0a3e25","line":3436,"in_reply_to":"5f7c97a3_cc8e3d2d","updated":"2018-06-12 10:16:54.000000000","message":"Basically \"rpt\" and \"rptt\" are too hard to distinguish from one another. I\u0027m not suggesting you change anything now, just making a comment about room for improvement in the future.","commit_id":"78bdd8cd92bcd58b50e443b56b174df3335d7865"},{"author":{"_account_id":7,"name":"Jay Pipes","email":"jaypipes@gmail.com","username":"jaypipes"},"change_message_id":"f39ad2932c681a1ecfa58231d0609fc21dfba27a","unresolved":false,"context_lines":[{"line_number":2543,"context_line":"            _ALLOC_TBL.c.resource_provider_id,"},{"line_number":2544,"context_line":"            _ALLOC_TBL.c.resource_class_id,"},{"line_number":2545,"context_line":"            sql.func.sum(_ALLOC_TBL.c.used).label(\u0027used\u0027),"},{"line_number":2546,"context_line":"        ]).where("},{"line_number":2547,"context_line":"            sa.and_("},{"line_number":2548,"context_line":"                _ALLOC_TBL.c.resource_provider_id.in_(rp_ids)"},{"line_number":2549,"context_line":"            ),"},{"line_number":2550,"context_line":"        ).group_by("},{"line_number":2551,"context_line":"            _ALLOC_TBL.c.resource_provider_id,"},{"line_number":2552,"context_line":"            _ALLOC_TBL.c.resource_class_id"}],"source_content_type":"text/x-python","patch_set":27,"id":"5f7c97a3_773a1198","side":"PARENT","line":2549,"range":{"start_line":2546,"start_character":0,"end_line":2549,"end_character":14},"updated":"2018-06-14 14:02:04.000000000","message":"yeh, it\u0027s definitely a mistake to remove this WHERE condition. That will cause the derived table to be a full table scan across the entire allocations table. We definitely do not want to do that.","commit_id":"a7da8f257f2661c7809046aac4f062c6c1b8c120"},{"author":{"_account_id":7,"name":"Jay Pipes","email":"jaypipes@gmail.com","username":"jaypipes"},"change_message_id":"f39ad2932c681a1ecfa58231d0609fc21dfba27a","unresolved":false,"context_lines":[{"line_number":2529,"context_line":"    #   FROM allocations"},{"line_number":2530,"context_line":"    #   # NOTE(tetsuro): It might be better to use another subquery to get"},{"line_number":2531,"context_line":"    #   # more performance here, or we need more basic refactoring :("},{"line_number":2532,"context_line":"    #   # WHERE resource_provider_id in ("},{"line_number":2533,"context_line":"    #   #   SELECT rp.id"},{"line_number":2534,"context_line":"    #   #   FROM resource_providers AS rp"},{"line_number":2535,"context_line":"    #   #   WHERE rp.root_provider_id IN ($root_ids))"},{"line_number":2536,"context_line":"    #   GROUP BY resource_provider_id, resource_class_id"},{"line_number":2537,"context_line":"    # )"},{"line_number":2538,"context_line":"    # AS usages"}],"source_content_type":"text/x-python","patch_set":27,"id":"5f7c97a3_77d53142","line":2535,"range":{"start_line":2532,"start_character":0,"end_line":2535,"end_character":53},"updated":"2018-06-14 14:02:04.000000000","message":"Just do this:\n\n SELECT resource_provider_id, resource_class_id, SUM(used) as used\n FROM allocations\n JOIN resource_providers\n  ON allocations.resource_provider_id \u003d resource_providers.id\n  AND resource_providers.root_provider_id IN ($root_ids)\n GROUP BY resource_provider_id, resource_class_id","commit_id":"2d1c30584051cdf26ae526d2200eb398717d9f6b"},{"author":{"_account_id":7,"name":"Jay Pipes","email":"jaypipes@gmail.com","username":"jaypipes"},"change_message_id":"f39ad2932c681a1ecfa58231d0609fc21dfba27a","unresolved":false,"context_lines":[{"line_number":2543,"context_line":"    inv \u003d sa.alias(_INV_TBL, name\u003d\"inv\")"},{"line_number":2544,"context_line":"    # Build our derived table (subquery in the FROM clause) that sums used"},{"line_number":2545,"context_line":"    # amounts for resource provider and resource class"},{"line_number":2546,"context_line":"    usage \u003d sa.alias("},{"line_number":2547,"context_line":"        sa.select(["},{"line_number":2548,"context_line":"            _ALLOC_TBL.c.resource_provider_id,"},{"line_number":2549,"context_line":"            _ALLOC_TBL.c.resource_class_id,"},{"line_number":2550,"context_line":"            sql.func.sum(_ALLOC_TBL.c.used).label(\u0027used\u0027),"},{"line_number":2551,"context_line":"        ]).group_by("},{"line_number":2552,"context_line":"            _ALLOC_TBL.c.resource_provider_id,"},{"line_number":2553,"context_line":"            _ALLOC_TBL.c.resource_class_id"},{"line_number":2554,"context_line":"        ),"},{"line_number":2555,"context_line":"        name\u003d\u0027usage\u0027,"},{"line_number":2556,"context_line":"    )"},{"line_number":2557,"context_line":"    # Build a join between the resource providers and inventories table"},{"line_number":2558,"context_line":"    rpt_inv_join \u003d sa.outerjoin(rpt, inv,"},{"line_number":2559,"context_line":"                                rpt.c.id \u003d\u003d inv.c.resource_provider_id)"}],"source_content_type":"text/x-python","patch_set":27,"id":"5f7c97a3_f7f381e5","line":2556,"range":{"start_line":2546,"start_character":3,"end_line":2556,"end_character":5},"updated":"2018-06-14 14:02:04.000000000","message":"You can do the following to maintain the WHERE filter in the derived table:\n\n derived_alloc_to_rp \u003d sa.join(\n     _ALLOC_TBL, _RP_TBL,\n     sa.and_(_ALLOC_TBL.c.resource_provider_id \u003d\u003d _RP_TBL.c.id,\n             _RP_TBL.c.root_provider_id.in_(root_ids)))\n usage \u003d sa.alias(\n         sa.select([\n             _ALLOC_TBL.c.resource_provider_id,\n             _ALLOC_TBL.c.resource_class_id,\n             sql.func.sum(_ALLOC_TBL.c.used).label(\u0027used\u0027),\n         ]).select_from(derived_alloc_to_rp).group_by(\n             _ALLOC_TBL.c.resource_provider_id,\n             _ALLOC_TBL.c.resource_class_id\n         ),\n         name\u003d\u0027usage\u0027)","commit_id":"2d1c30584051cdf26ae526d2200eb398717d9f6b"},{"author":{"_account_id":7,"name":"Jay Pipes","email":"jaypipes@gmail.com","username":"jaypipes"},"change_message_id":"4253053a805ac8b85b6de62b8b0f6f5b1b0322af","unresolved":false,"context_lines":[{"line_number":3407,"context_line":"        return [], []"},{"line_number":3408,"context_line":""},{"line_number":3409,"context_line":"    # Get all the root resource provider IDs. We should include the first"},{"line_number":3410,"context_line":"    # values of rp_tuples because while sharing providers are root providers,"},{"line_number":3411,"context_line":"    # they have their \"anchor\" providers for the second value."},{"line_number":3412,"context_line":"    root_ids \u003d set(p[0] for p in rp_tuples) | set(p[1] for p in rp_tuples)"},{"line_number":3413,"context_line":""}],"source_content_type":"text/x-python","patch_set":30,"id":"5f7c97a3_612f4a3e","line":3410,"range":{"start_line":3410,"start_character":26,"end_line":3410,"end_character":76},"updated":"2018-06-19 18:02:37.000000000","message":"there\u0027s nothing that says all sharing providers are root providers...","commit_id":"562fff5208dc42c128fb081ca6911e5cc2792c6f"},{"author":{"_account_id":7,"name":"Jay Pipes","email":"jaypipes@gmail.com","username":"jaypipes"},"change_message_id":"4253053a805ac8b85b6de62b8b0f6f5b1b0322af","unresolved":false,"context_lines":[{"line_number":3495,"context_line":"    rpt_rptt \u003d sa.join(rpt, rptt, rpt.c.id \u003d\u003d rptt.c.resource_provider_id)"},{"line_number":3496,"context_line":"    j \u003d sa.join(rpt_rptt, tt, rptt.c.trait_id \u003d\u003d tt.c.id)"},{"line_number":3497,"context_line":"    sel \u003d sa.select([rptt.c.resource_provider_id, tt.c.name]).select_from(j)"},{"line_number":3498,"context_line":"    sel \u003d sel.where(rpt.c.root_provider_id.in_(root_ids))"},{"line_number":3499,"context_line":"    res \u003d collections.defaultdict(list)"},{"line_number":3500,"context_line":"    for r in ctx.session.execute(sel):"},{"line_number":3501,"context_line":"        res[r[0]].append(r[1])"}],"source_content_type":"text/x-python","patch_set":30,"id":"5f7c97a3_a166c2ba","line":3498,"updated":"2018-06-19 18:02:37.000000000","message":"✓","commit_id":"562fff5208dc42c128fb081ca6911e5cc2792c6f"}],"nova/tests/functional/api/openstack/placement/db/test_allocation_candidates.py":[{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"ba2bf3bd9c1eb3b26d04adf4e3315ce7beb168e2","unresolved":false,"context_lines":[{"line_number":1877,"context_line":"        }"},{"line_number":1878,"context_line":"        self._validate_provider_summary_traits(expected, alloc_cands)"},{"line_number":1879,"context_line":""},{"line_number":1880,"context_line":"        # Next we test that we get resources only on non-root providers"},{"line_number":1881,"context_line":"        # without root providers involved"},{"line_number":1882,"context_line":"        alloc_cands \u003d self._get_allocation_candidates("},{"line_number":1883,"context_line":"            {\u0027\u0027: placement_lib.RequestGroup("},{"line_number":1884,"context_line":"                use_same_provider\u003dFalse,"},{"line_number":1885,"context_line":"                resources\u003d{"},{"line_number":1886,"context_line":"                    fields.ResourceClass.SRIOV_NET_VF: 1,"},{"line_number":1887,"context_line":"                },"},{"line_number":1888,"context_line":"            )}"},{"line_number":1889,"context_line":"        )"},{"line_number":1890,"context_line":""},{"line_number":1891,"context_line":"        expected \u003d ["},{"line_number":1892,"context_line":"            [(\u0027cn_numa0_pf0\u0027, fields.ResourceClass.SRIOV_NET_VF, 1)],"},{"line_number":1893,"context_line":"            [(\u0027cn_numa1_pf1\u0027, fields.ResourceClass.SRIOV_NET_VF, 1)],"},{"line_number":1894,"context_line":"        ]"},{"line_number":1895,"context_line":"        self._validate_allocation_requests(expected, alloc_cands)"},{"line_number":1896,"context_line":""},{"line_number":1897,"context_line":"        expected \u003d {"},{"line_number":1898,"context_line":"            \u0027cn\u0027: set(["},{"line_number":1899,"context_line":"                (fields.ResourceClass.VCPU, 16, 0),"},{"line_number":1900,"context_line":"                (fields.ResourceClass.MEMORY_MB, 32768, 0),"},{"line_number":1901,"context_line":"            ]),"},{"line_number":1902,"context_line":"            \u0027cn_numa0\u0027: set([]),"},{"line_number":1903,"context_line":"            \u0027cn_numa1\u0027: set([]),"},{"line_number":1904,"context_line":"            \u0027cn_numa0_pf0\u0027: set(["},{"line_number":1905,"context_line":"                (fields.ResourceClass.SRIOV_NET_VF, 8, 0),"},{"line_number":1906,"context_line":"            ]),"},{"line_number":1907,"context_line":"            \u0027cn_numa1_pf1\u0027: set(["},{"line_number":1908,"context_line":"                (fields.ResourceClass.SRIOV_NET_VF, 8, 0),"},{"line_number":1909,"context_line":"            ]),"},{"line_number":1910,"context_line":"        }"},{"line_number":1911,"context_line":"        self._validate_provider_summary_resources(expected, alloc_cands)"},{"line_number":1912,"context_line":""},{"line_number":1913,"context_line":"        expected \u003d {"},{"line_number":1914,"context_line":"            \u0027cn\u0027: set([]),"},{"line_number":1915,"context_line":"            \u0027cn_numa0\u0027: set([]),"},{"line_number":1916,"context_line":"            \u0027cn_numa1\u0027: set([]),"},{"line_number":1917,"context_line":"            \u0027cn_numa0_pf0\u0027: set([]),"},{"line_number":1918,"context_line":"            \u0027cn_numa1_pf1\u0027: set([os_traits.HW_NIC_OFFLOAD_GENEVE]),"},{"line_number":1919,"context_line":"        }"},{"line_number":1920,"context_line":"        self._validate_provider_summary_traits(expected, alloc_cands)"},{"line_number":1921,"context_line":""},{"line_number":1922,"context_line":"        # Now consume all the inventory of SRIOV_NET_VF on the second physical"},{"line_number":1923,"context_line":"        # function (the one with HW_NIC_OFFLOAD_GENEVE associated with it) and"}],"source_content_type":"text/x-python","patch_set":21,"id":"5f7c97a3_d491319c","line":1920,"range":{"start_line":1880,"start_character":0,"end_line":1920,"end_character":69},"updated":"2018-06-07 19:41:32.000000000","message":"This is such a test case, and it obviously works.\n\nBUT we can break it as I anticipated by putting the request into a granular group (use_same_provider\u003dTrue on L1884).","commit_id":"34414a0f3afd4dcc27198ac066d15d9e725f2107"}]}
