)]}'
{"/COMMIT_MSG":[{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"b16dd01a6ca36642942098e21057db3a7d899ffe","unresolved":false,"context_lines":[{"line_number":7,"context_line":"Claim resources in resource tracker"},{"line_number":8,"context_line":""},{"line_number":9,"context_line":"In periodic update_available_resource, ResourceTracker.prov_tree"},{"line_number":10,"context_line":"will be updated, get availble resources from ResourceTracker.prov_tree"},{"line_number":11,"context_line":"and assigned resources based on tracked instances and migrations,"},{"line_number":12,"context_line":"then claim resources according to allocations from free resources."},{"line_number":13,"context_line":""}],"source_content_type":"text/x-gerrit-commit-message","patch_set":7,"id":"7faddb67_16fb2f47","line":10,"range":{"start_line":10,"start_character":21,"end_line":10,"end_character":29},"updated":"2019-08-29 23:02:16.000000000","message":"available","commit_id":"fc0d1b1258d42a20044504a7ee6a1791183e3dd2"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"3d7eb310beac331848500982bb51dbd15256160b","unresolved":false,"context_lines":[{"line_number":7,"context_line":"Claim resources in resource tracker"},{"line_number":8,"context_line":""},{"line_number":9,"context_line":"In periodic update_available_resource, ResourceTracker.prov_tree"},{"line_number":10,"context_line":"will be updated, get availble resources from ResourceTracker.prov_tree"},{"line_number":11,"context_line":"and assigned resources based on tracked instances and migrations,"},{"line_number":12,"context_line":"then claim resources according to allocations from free resources."},{"line_number":13,"context_line":""}],"source_content_type":"text/x-gerrit-commit-message","patch_set":10,"id":"7faddb67_64689887","line":10,"range":{"start_line":10,"start_character":21,"end_line":10,"end_character":29},"updated":"2019-08-30 18:01:28.000000000","message":"available","commit_id":"3263c8915f740ac3f311e743ddac63151055114e"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"2277fceb9be589ebbcea73aa254c7576c3587dae","unresolved":false,"context_lines":[{"line_number":7,"context_line":"Claim resources in resource tracker"},{"line_number":8,"context_line":""},{"line_number":9,"context_line":"In periodic update_available_resource, ResourceTracker.prov_tree"},{"line_number":10,"context_line":"will be updated, get availble resources from ResourceTracker.prov_tree"},{"line_number":11,"context_line":"and assigned resources based on tracked instances and migrations,"},{"line_number":12,"context_line":"then claim resources according to allocations from free resources."},{"line_number":13,"context_line":""}],"source_content_type":"text/x-gerrit-commit-message","patch_set":10,"id":"7faddb67_9ad64127","line":10,"range":{"start_line":10,"start_character":21,"end_line":10,"end_character":29},"in_reply_to":"7faddb67_64689887","updated":"2019-09-02 07:10:33.000000000","message":"Done","commit_id":"3263c8915f740ac3f311e743ddac63151055114e"}],"nova/compute/resource_tracker.py":[{"author":{"_account_id":5754,"name":"Alex Xu","email":"hejie.xu@intel.com","username":"xuhj"},"change_message_id":"4c8e95b8fb6be681ef1d140d07a991d3a95dc4e3","unresolved":false,"context_lines":[{"line_number":391,"context_line":"        \"\"\"Claim resources according to assigned resources from allocations"},{"line_number":392,"context_line":"        and available resources in provider tree"},{"line_number":393,"context_line":"        \"\"\""},{"line_number":394,"context_line":"        if not allocations:"},{"line_number":395,"context_line":"            return None"},{"line_number":396,"context_line":""},{"line_number":397,"context_line":"        claimed_resources \u003d []"},{"line_number":398,"context_line":"        assigned_resources \u003d self._get_assigned_resources(context, nodename)"}],"source_content_type":"text/x-python","patch_set":4,"id":"7faddb67_77872114","line":395,"range":{"start_line":394,"start_character":8,"end_line":395,"end_character":23},"updated":"2019-08-28 05:51:05.000000000","message":"emm...is there any case we don\u0027t have allocations?","commit_id":"65d7fc96b8a564619b991b642d516dfa8c0c5530"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"f5d5279afb1d2368d3dc1cbbb6648bb51945bed4","unresolved":false,"context_lines":[{"line_number":391,"context_line":"        \"\"\"Claim resources according to assigned resources from allocations"},{"line_number":392,"context_line":"        and available resources in provider tree"},{"line_number":393,"context_line":"        \"\"\""},{"line_number":394,"context_line":"        if not allocations:"},{"line_number":395,"context_line":"            return None"},{"line_number":396,"context_line":""},{"line_number":397,"context_line":"        claimed_resources \u003d []"},{"line_number":398,"context_line":"        assigned_resources \u003d self._get_assigned_resources(context, nodename)"}],"source_content_type":"text/x-python","patch_set":4,"id":"7faddb67_8d8acc17","line":395,"range":{"start_line":394,"start_character":8,"end_line":395,"end_character":23},"in_reply_to":"7faddb67_77872114","updated":"2019-08-28 10:46:07.000000000","message":"I think no in real OpenStack env. But for convenience, I fake the allocations as empty dict in testcases.","commit_id":"65d7fc96b8a564619b991b642d516dfa8c0c5530"},{"author":{"_account_id":5754,"name":"Alex Xu","email":"hejie.xu@intel.com","username":"xuhj"},"change_message_id":"4c8e95b8fb6be681ef1d140d07a991d3a95dc4e3","unresolved":false,"context_lines":[{"line_number":405,"context_line":"                # in real OpenStack enviroment. Still need look into"},{"line_number":406,"context_line":"                # functional tests, this is not as we expected."},{"line_number":407,"context_line":"                provider_data \u003d self.prov_tree.data(rp_uuid)"},{"line_number":408,"context_line":"            except Exception:"},{"line_number":409,"context_line":"                continue"},{"line_number":410,"context_line":"            for rc, amount in resources.items():"},{"line_number":411,"context_line":"                if rc not in provider_data.resources:"}],"source_content_type":"text/x-python","patch_set":4,"id":"7faddb67_978f3d21","line":408,"range":{"start_line":408,"start_character":19,"end_line":408,"end_character":28},"updated":"2019-08-28 05:51:05.000000000","message":"catch specific exception instead of this generic one.","commit_id":"65d7fc96b8a564619b991b642d516dfa8c0c5530"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"f5d5279afb1d2368d3dc1cbbb6648bb51945bed4","unresolved":false,"context_lines":[{"line_number":405,"context_line":"                # in real OpenStack enviroment. Still need look into"},{"line_number":406,"context_line":"                # functional tests, this is not as we expected."},{"line_number":407,"context_line":"                provider_data \u003d self.prov_tree.data(rp_uuid)"},{"line_number":408,"context_line":"            except Exception:"},{"line_number":409,"context_line":"                continue"},{"line_number":410,"context_line":"            for rc, amount in resources.items():"},{"line_number":411,"context_line":"                if rc not in provider_data.resources:"}],"source_content_type":"text/x-python","patch_set":4,"id":"7faddb67_8d316c0d","line":408,"range":{"start_line":408,"start_character":19,"end_line":408,"end_character":28},"in_reply_to":"7faddb67_978f3d21","updated":"2019-08-28 10:46:07.000000000","message":"Done","commit_id":"65d7fc96b8a564619b991b642d516dfa8c0c5530"},{"author":{"_account_id":5754,"name":"Alex Xu","email":"hejie.xu@intel.com","username":"xuhj"},"change_message_id":"4c8e95b8fb6be681ef1d140d07a991d3a95dc4e3","unresolved":false,"context_lines":[{"line_number":408,"context_line":"            except Exception:"},{"line_number":409,"context_line":"                continue"},{"line_number":410,"context_line":"            for rc, amount in resources.items():"},{"line_number":411,"context_line":"                if rc not in provider_data.resources:"},{"line_number":412,"context_line":"                    continue"},{"line_number":413,"context_line":"                available \u003d provider_data.resources.get(rc)"},{"line_number":414,"context_line":"                assigned \u003d assigned_resources[rp_uuid].get(rc, set())"}],"source_content_type":"text/x-python","patch_set":4,"id":"7faddb67_b774b937","line":411,"updated":"2019-08-28 05:51:05.000000000","message":"good to add a comment about what the case is when rc not in resources.","commit_id":"65d7fc96b8a564619b991b642d516dfa8c0c5530"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"f5d5279afb1d2368d3dc1cbbb6648bb51945bed4","unresolved":false,"context_lines":[{"line_number":408,"context_line":"            except Exception:"},{"line_number":409,"context_line":"                continue"},{"line_number":410,"context_line":"            for rc, amount in resources.items():"},{"line_number":411,"context_line":"                if rc not in provider_data.resources:"},{"line_number":412,"context_line":"                    continue"},{"line_number":413,"context_line":"                available \u003d provider_data.resources.get(rc)"},{"line_number":414,"context_line":"                assigned \u003d assigned_resources[rp_uuid].get(rc, set())"}],"source_content_type":"text/x-python","patch_set":4,"id":"7faddb67_e8ab2ed4","line":411,"in_reply_to":"7faddb67_b774b937","updated":"2019-08-28 10:46:07.000000000","message":"Done","commit_id":"65d7fc96b8a564619b991b642d516dfa8c0c5530"},{"author":{"_account_id":5754,"name":"Alex Xu","email":"hejie.xu@intel.com","username":"xuhj"},"change_message_id":"4c8e95b8fb6be681ef1d140d07a991d3a95dc4e3","unresolved":false,"context_lines":[{"line_number":418,"context_line":"                        claimed_resources.append(free.pop())"},{"line_number":419,"context_line":"                    except Exception:"},{"line_number":420,"context_line":"                        reason \u003d _(\"Resouce Class: %s\") % rc"},{"line_number":421,"context_line":"                        raise exception.ClaimResourceFailed(reason\u003dreason)"},{"line_number":422,"context_line":""},{"line_number":423,"context_line":"        if claimed_resources:"},{"line_number":424,"context_line":"            return objects.ResourceList(objects\u003dclaimed_resources)"}],"source_content_type":"text/x-python","patch_set":4,"id":"7faddb67_97ddfd14","line":421,"range":{"start_line":421,"start_character":40,"end_line":421,"end_character":59},"updated":"2019-08-28 05:51:05.000000000","message":"or we just raise exception.ComputeResourcesUnavailable, then you get all the process when claim failed naturally.","commit_id":"65d7fc96b8a564619b991b642d516dfa8c0c5530"},{"author":{"_account_id":5754,"name":"Alex Xu","email":"hejie.xu@intel.com","username":"xuhj"},"change_message_id":"4c8e95b8fb6be681ef1d140d07a991d3a95dc4e3","unresolved":false,"context_lines":[{"line_number":413,"context_line":"                available \u003d provider_data.resources.get(rc)"},{"line_number":414,"context_line":"                assigned \u003d assigned_resources[rp_uuid].get(rc, set())"},{"line_number":415,"context_line":"                free \u003d self._get_free_resources(available, assigned)"},{"line_number":416,"context_line":"                for i in range(amount):"},{"line_number":417,"context_line":"                    try:"},{"line_number":418,"context_line":"                        claimed_resources.append(free.pop())"},{"line_number":419,"context_line":"                    except Exception:"},{"line_number":420,"context_line":"                        reason \u003d _(\"Resouce Class: %s\") % rc"},{"line_number":421,"context_line":"                        raise exception.ClaimResourceFailed(reason\u003dreason)"},{"line_number":422,"context_line":""},{"line_number":423,"context_line":"        if claimed_resources:"},{"line_number":424,"context_line":"            return objects.ResourceList(objects\u003dclaimed_resources)"}],"source_content_type":"text/x-python","patch_set":4,"id":"7faddb67_77b5e1cf","line":421,"range":{"start_line":416,"start_character":16,"end_line":421,"end_character":74},"updated":"2019-08-28 05:51:05.000000000","message":"we can test the len of free, then you can get a more specific error message also.","commit_id":"65d7fc96b8a564619b991b642d516dfa8c0c5530"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"f5d5279afb1d2368d3dc1cbbb6648bb51945bed4","unresolved":false,"context_lines":[{"line_number":413,"context_line":"                available \u003d provider_data.resources.get(rc)"},{"line_number":414,"context_line":"                assigned \u003d assigned_resources[rp_uuid].get(rc, set())"},{"line_number":415,"context_line":"                free \u003d self._get_free_resources(available, assigned)"},{"line_number":416,"context_line":"                for i in range(amount):"},{"line_number":417,"context_line":"                    try:"},{"line_number":418,"context_line":"                        claimed_resources.append(free.pop())"},{"line_number":419,"context_line":"                    except Exception:"},{"line_number":420,"context_line":"                        reason \u003d _(\"Resouce Class: %s\") % rc"},{"line_number":421,"context_line":"                        raise exception.ClaimResourceFailed(reason\u003dreason)"},{"line_number":422,"context_line":""},{"line_number":423,"context_line":"        if claimed_resources:"},{"line_number":424,"context_line":"            return objects.ResourceList(objects\u003dclaimed_resources)"}],"source_content_type":"text/x-python","patch_set":4,"id":"7faddb67_c8faf2b8","line":421,"range":{"start_line":416,"start_character":16,"end_line":421,"end_character":74},"in_reply_to":"7faddb67_77b5e1cf","updated":"2019-08-28 10:46:07.000000000","message":"Done","commit_id":"65d7fc96b8a564619b991b642d516dfa8c0c5530"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"f5d5279afb1d2368d3dc1cbbb6648bb51945bed4","unresolved":false,"context_lines":[{"line_number":418,"context_line":"                        claimed_resources.append(free.pop())"},{"line_number":419,"context_line":"                    except Exception:"},{"line_number":420,"context_line":"                        reason \u003d _(\"Resouce Class: %s\") % rc"},{"line_number":421,"context_line":"                        raise exception.ClaimResourceFailed(reason\u003dreason)"},{"line_number":422,"context_line":""},{"line_number":423,"context_line":"        if claimed_resources:"},{"line_number":424,"context_line":"            return objects.ResourceList(objects\u003dclaimed_resources)"}],"source_content_type":"text/x-python","patch_set":4,"id":"7faddb67_a8ff76a9","line":421,"range":{"start_line":421,"start_character":40,"end_line":421,"end_character":59},"in_reply_to":"7faddb67_97ddfd14","updated":"2019-08-28 10:46:07.000000000","message":"Done","commit_id":"65d7fc96b8a564619b991b642d516dfa8c0c5530"},{"author":{"_account_id":5754,"name":"Alex Xu","email":"hejie.xu@intel.com","username":"xuhj"},"change_message_id":"4c8e95b8fb6be681ef1d140d07a991d3a95dc4e3","unresolved":false,"context_lines":[{"line_number":440,"context_line":"        def update_resources(instance, migration\u003dNone, host\u003dNone):"},{"line_number":441,"context_line":"            if not migration:"},{"line_number":442,"context_line":"                if instance.resources:"},{"line_number":443,"context_line":"                    resources.extend(instance.resources.objects)"},{"line_number":444,"context_line":"                return"},{"line_number":445,"context_line":"            prefix \u003d []"},{"line_number":446,"context_line":"            if migration.source_compute \u003d\u003d host:"}],"source_content_type":"text/x-python","patch_set":4,"id":"7faddb67_f7247110","line":443,"range":{"start_line":443,"start_character":37,"end_line":443,"end_character":63},"updated":"2019-08-28 05:51:05.000000000","message":"I thought, resources.extend(instance.resources), works?","commit_id":"65d7fc96b8a564619b991b642d516dfa8c0c5530"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"f5d5279afb1d2368d3dc1cbbb6648bb51945bed4","unresolved":false,"context_lines":[{"line_number":440,"context_line":"        def update_resources(instance, migration\u003dNone, host\u003dNone):"},{"line_number":441,"context_line":"            if not migration:"},{"line_number":442,"context_line":"                if instance.resources:"},{"line_number":443,"context_line":"                    resources.extend(instance.resources.objects)"},{"line_number":444,"context_line":"                return"},{"line_number":445,"context_line":"            prefix \u003d []"},{"line_number":446,"context_line":"            if migration.source_compute \u003d\u003d host:"}],"source_content_type":"text/x-python","patch_set":4,"id":"7faddb67_68dade1d","line":443,"range":{"start_line":443,"start_character":37,"end_line":443,"end_character":63},"in_reply_to":"7faddb67_f7247110","updated":"2019-08-28 10:46:07.000000000","message":"yes, it works","commit_id":"65d7fc96b8a564619b991b642d516dfa8c0c5530"},{"author":{"_account_id":5754,"name":"Alex Xu","email":"hejie.xu@intel.com","username":"xuhj"},"change_message_id":"4c8e95b8fb6be681ef1d140d07a991d3a95dc4e3","unresolved":false,"context_lines":[{"line_number":461,"context_line":"            update_resources(migration.instance, migration, host\u003dself.host)"},{"line_number":462,"context_line":""},{"line_number":463,"context_line":"        # Get resources assigned to instances not in migrating"},{"line_number":464,"context_line":"        instance_uuids \u003d self.tracked_instances - migrating_inst_uuids"},{"line_number":465,"context_line":"        instances \u003d objects.InstanceList.get_by_filters("},{"line_number":466,"context_line":"            context, {\u0027uuid\u0027: instance_uuids}, expected_attrs\u003d[\u0027resources\u0027],"},{"line_number":467,"context_line":"            use_slave\u003dTrue)"}],"source_content_type":"text/x-python","patch_set":4,"id":"7faddb67_37320960","line":464,"range":{"start_line":464,"start_character":8,"end_line":464,"end_character":70},"updated":"2019-08-28 05:51:05.000000000","message":"will the RT already guarantee that ? https://github.com/openstack/nova/blob/master/nova/compute/resource_tracker.py#L1124","commit_id":"65d7fc96b8a564619b991b642d516dfa8c0c5530"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"6eef9e9216bb53c153c761212b750227a8e1a1de","unresolved":false,"context_lines":[{"line_number":461,"context_line":"            update_resources(migration.instance, migration, host\u003dself.host)"},{"line_number":462,"context_line":""},{"line_number":463,"context_line":"        # Get resources assigned to instances not in migrating"},{"line_number":464,"context_line":"        instance_uuids \u003d self.tracked_instances - migrating_inst_uuids"},{"line_number":465,"context_line":"        instances \u003d objects.InstanceList.get_by_filters("},{"line_number":466,"context_line":"            context, {\u0027uuid\u0027: instance_uuids}, expected_attrs\u003d[\u0027resources\u0027],"},{"line_number":467,"context_line":"            use_slave\u003dTrue)"}],"source_content_type":"text/x-python","patch_set":4,"id":"7faddb67_55d3fa5f","line":464,"range":{"start_line":464,"start_character":8,"end_line":464,"end_character":70},"in_reply_to":"7faddb67_37320960","updated":"2019-08-28 10:48:00.000000000","message":"Sorry, I don\u0027t realy following you, guarantee what?","commit_id":"65d7fc96b8a564619b991b642d516dfa8c0c5530"},{"author":{"_account_id":5754,"name":"Alex Xu","email":"hejie.xu@intel.com","username":"xuhj"},"change_message_id":"502accebaa4fec4dfb73a441a40a5a737c2835f1","unresolved":false,"context_lines":[{"line_number":461,"context_line":"            update_resources(migration.instance, migration, host\u003dself.host)"},{"line_number":462,"context_line":""},{"line_number":463,"context_line":"        # Get resources assigned to instances not in migrating"},{"line_number":464,"context_line":"        instance_uuids \u003d self.tracked_instances - migrating_inst_uuids"},{"line_number":465,"context_line":"        instances \u003d objects.InstanceList.get_by_filters("},{"line_number":466,"context_line":"            context, {\u0027uuid\u0027: instance_uuids}, expected_attrs\u003d[\u0027resources\u0027],"},{"line_number":467,"context_line":"            use_slave\u003dTrue)"}],"source_content_type":"text/x-python","patch_set":4,"id":"7faddb67_a80be828","line":464,"range":{"start_line":464,"start_character":8,"end_line":464,"end_character":70},"in_reply_to":"7faddb67_55d3fa5f","updated":"2019-08-28 23:25:39.000000000","message":"The RT ensure there is no overlap between tracked_instance and tracked_migration","commit_id":"65d7fc96b8a564619b991b642d516dfa8c0c5530"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"88ddb9e9b3ba621d3963afb50129ece39d994819","unresolved":false,"context_lines":[{"line_number":461,"context_line":"            update_resources(migration.instance, migration, host\u003dself.host)"},{"line_number":462,"context_line":""},{"line_number":463,"context_line":"        # Get resources assigned to instances not in migrating"},{"line_number":464,"context_line":"        instance_uuids \u003d self.tracked_instances - migrating_inst_uuids"},{"line_number":465,"context_line":"        instances \u003d objects.InstanceList.get_by_filters("},{"line_number":466,"context_line":"            context, {\u0027uuid\u0027: instance_uuids}, expected_attrs\u003d[\u0027resources\u0027],"},{"line_number":467,"context_line":"            use_slave\u003dTrue)"}],"source_content_type":"text/x-python","patch_set":4,"id":"7faddb67_003530a8","line":464,"range":{"start_line":464,"start_character":8,"end_line":464,"end_character":70},"in_reply_to":"7faddb67_a80be828","updated":"2019-08-29 03:23:06.000000000","message":"Oh,I see.","commit_id":"65d7fc96b8a564619b991b642d516dfa8c0c5530"},{"author":{"_account_id":5754,"name":"Alex Xu","email":"hejie.xu@intel.com","username":"xuhj"},"change_message_id":"4c8e95b8fb6be681ef1d140d07a991d3a95dc4e3","unresolved":false,"context_lines":[{"line_number":462,"context_line":""},{"line_number":463,"context_line":"        # Get resources assigned to instances not in migrating"},{"line_number":464,"context_line":"        instance_uuids \u003d self.tracked_instances - migrating_inst_uuids"},{"line_number":465,"context_line":"        instances \u003d objects.InstanceList.get_by_filters("},{"line_number":466,"context_line":"            context, {\u0027uuid\u0027: instance_uuids}, expected_attrs\u003d[\u0027resources\u0027],"},{"line_number":467,"context_line":"            use_slave\u003dTrue)"},{"line_number":468,"context_line":"        for instance in instances:"},{"line_number":469,"context_line":"            update_resources(instance)"},{"line_number":470,"context_line":""}],"source_content_type":"text/x-python","patch_set":4,"id":"7faddb67_f73b1136","line":467,"range":{"start_line":465,"start_character":8,"end_line":467,"end_character":27},"updated":"2019-08-28 05:51:05.000000000","message":"Maybe add a TODO note, we cache instance obj in self.tracked_instaces.","commit_id":"65d7fc96b8a564619b991b642d516dfa8c0c5530"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"6eef9e9216bb53c153c761212b750227a8e1a1de","unresolved":false,"context_lines":[{"line_number":462,"context_line":""},{"line_number":463,"context_line":"        # Get resources assigned to instances not in migrating"},{"line_number":464,"context_line":"        instance_uuids \u003d self.tracked_instances - migrating_inst_uuids"},{"line_number":465,"context_line":"        instances \u003d objects.InstanceList.get_by_filters("},{"line_number":466,"context_line":"            context, {\u0027uuid\u0027: instance_uuids}, expected_attrs\u003d[\u0027resources\u0027],"},{"line_number":467,"context_line":"            use_slave\u003dTrue)"},{"line_number":468,"context_line":"        for instance in instances:"},{"line_number":469,"context_line":"            update_resources(instance)"},{"line_number":470,"context_line":""}],"source_content_type":"text/x-python","patch_set":4,"id":"7faddb67_f5c9c6ab","line":467,"range":{"start_line":465,"start_character":8,"end_line":467,"end_character":27},"in_reply_to":"7faddb67_f73b1136","updated":"2019-08-28 10:48:00.000000000","message":"Done","commit_id":"65d7fc96b8a564619b991b642d516dfa8c0c5530"},{"author":{"_account_id":5754,"name":"Alex Xu","email":"hejie.xu@intel.com","username":"xuhj"},"change_message_id":"4c8e95b8fb6be681ef1d140d07a991d3a95dc4e3","unresolved":false,"context_lines":[{"line_number":498,"context_line":"            provider_data \u003d self.prov_tree.data(rp_uuid)"},{"line_number":499,"context_line":"            for rc in assigned_resources[rp_uuid]:"},{"line_number":500,"context_line":"                available \u003d provider_data.resources.get(rc, [])"},{"line_number":501,"context_line":"                assigned \u003d assigned_resources[rp_uuid].get(rc, set())"},{"line_number":502,"context_line":"                for resource in available:"},{"line_number":503,"context_line":"                    if resource.identifier in assigned:"},{"line_number":504,"context_line":"                        assigned.remove(resource.identifier)"}],"source_content_type":"text/x-python","patch_set":4,"id":"7faddb67_d7dcd5e2","line":501,"range":{"start_line":501,"start_character":27,"end_line":501,"end_character":69},"updated":"2019-08-28 05:51:05.000000000","message":"nit, assigned_resources[rp_uuid][rc], since you are in loop of assigned_resources.","commit_id":"65d7fc96b8a564619b991b642d516dfa8c0c5530"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"6eef9e9216bb53c153c761212b750227a8e1a1de","unresolved":false,"context_lines":[{"line_number":498,"context_line":"            provider_data \u003d self.prov_tree.data(rp_uuid)"},{"line_number":499,"context_line":"            for rc in assigned_resources[rp_uuid]:"},{"line_number":500,"context_line":"                available \u003d provider_data.resources.get(rc, [])"},{"line_number":501,"context_line":"                assigned \u003d assigned_resources[rp_uuid].get(rc, set())"},{"line_number":502,"context_line":"                for resource in available:"},{"line_number":503,"context_line":"                    if resource.identifier in assigned:"},{"line_number":504,"context_line":"                        assigned.remove(resource.identifier)"}],"source_content_type":"text/x-python","patch_set":4,"id":"7faddb67_b5c34e8a","line":501,"range":{"start_line":501,"start_character":27,"end_line":501,"end_character":69},"in_reply_to":"7faddb67_d7dcd5e2","updated":"2019-08-28 10:48:00.000000000","message":"Done","commit_id":"65d7fc96b8a564619b991b642d516dfa8c0c5530"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"b16dd01a6ca36642942098e21057db3a7d899ffe","unresolved":false,"context_lines":[{"line_number":395,"context_line":"            return None"},{"line_number":396,"context_line":""},{"line_number":397,"context_line":"        claimed_resources \u003d []"},{"line_number":398,"context_line":"        assigned_resources \u003d self._get_assigned_resources(context, nodename)"},{"line_number":399,"context_line":"        for rp_uuid in allocations:"},{"line_number":400,"context_line":"            resources \u003d allocations[rp_uuid][\u0027resources\u0027]"},{"line_number":401,"context_line":"            try:"}],"source_content_type":"text/x-python","patch_set":7,"id":"7faddb67_bc131965","line":398,"range":{"start_line":398,"start_character":29,"end_line":398,"end_character":76},"updated":"2019-08-29 23:02:16.000000000","message":"as noted below, this should be using a cached value, not rebuilding every time.","commit_id":"fc0d1b1258d42a20044504a7ee6a1791183e3dd2"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"3a6ffebc5bb12a1f3216deb38873f566c6cdf37a","unresolved":false,"context_lines":[{"line_number":395,"context_line":"            return None"},{"line_number":396,"context_line":""},{"line_number":397,"context_line":"        claimed_resources \u003d []"},{"line_number":398,"context_line":"        assigned_resources \u003d self._get_assigned_resources(context, nodename)"},{"line_number":399,"context_line":"        for rp_uuid in allocations:"},{"line_number":400,"context_line":"            resources \u003d allocations[rp_uuid][\u0027resources\u0027]"},{"line_number":401,"context_line":"            try:"}],"source_content_type":"text/x-python","patch_set":7,"id":"7faddb67_4b7815c0","line":398,"range":{"start_line":398,"start_character":29,"end_line":398,"end_character":76},"in_reply_to":"7faddb67_bc131965","updated":"2019-08-30 09:38:37.000000000","message":"Done","commit_id":"fc0d1b1258d42a20044504a7ee6a1791183e3dd2"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"b16dd01a6ca36642942098e21057db3a7d899ffe","unresolved":false,"context_lines":[{"line_number":396,"context_line":""},{"line_number":397,"context_line":"        claimed_resources \u003d []"},{"line_number":398,"context_line":"        assigned_resources \u003d self._get_assigned_resources(context, nodename)"},{"line_number":399,"context_line":"        for rp_uuid in allocations:"},{"line_number":400,"context_line":"            resources \u003d allocations[rp_uuid][\u0027resources\u0027]"},{"line_number":401,"context_line":"            try:"},{"line_number":402,"context_line":"                # TODO(Luyao)"},{"line_number":403,"context_line":"                # In many functional tests, provider tree doesn\u0027t have"}],"source_content_type":"text/x-python","patch_set":7,"id":"7faddb67_dffda708","line":400,"range":{"start_line":399,"start_character":8,"end_line":400,"end_character":57},"updated":"2019-08-29 23:02:16.000000000","message":"or\n\n for rp_uuid, alloc_dict in allocations.items():\n     resources \u003d alloc_dict[\u0027resources\u0027]","commit_id":"fc0d1b1258d42a20044504a7ee6a1791183e3dd2"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"3a6ffebc5bb12a1f3216deb38873f566c6cdf37a","unresolved":false,"context_lines":[{"line_number":396,"context_line":""},{"line_number":397,"context_line":"        claimed_resources \u003d []"},{"line_number":398,"context_line":"        assigned_resources \u003d self._get_assigned_resources(context, nodename)"},{"line_number":399,"context_line":"        for rp_uuid in allocations:"},{"line_number":400,"context_line":"            resources \u003d allocations[rp_uuid][\u0027resources\u0027]"},{"line_number":401,"context_line":"            try:"},{"line_number":402,"context_line":"                # TODO(Luyao)"},{"line_number":403,"context_line":"                # In many functional tests, provider tree doesn\u0027t have"}],"source_content_type":"text/x-python","patch_set":7,"id":"7faddb67_eb4a2181","line":400,"range":{"start_line":399,"start_character":8,"end_line":400,"end_character":57},"in_reply_to":"7faddb67_dffda708","updated":"2019-08-30 09:38:37.000000000","message":"Done","commit_id":"fc0d1b1258d42a20044504a7ee6a1791183e3dd2"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"b16dd01a6ca36642942098e21057db3a7d899ffe","unresolved":false,"context_lines":[{"line_number":399,"context_line":"        for rp_uuid in allocations:"},{"line_number":400,"context_line":"            resources \u003d allocations[rp_uuid][\u0027resources\u0027]"},{"line_number":401,"context_line":"            try:"},{"line_number":402,"context_line":"                # TODO(Luyao)"},{"line_number":403,"context_line":"                # In many functional tests, provider tree doesn\u0027t have"},{"line_number":404,"context_line":"                # rp uuids in allocations, we believe this won\u0027t happen"},{"line_number":405,"context_line":"                # in real OpenStack enviroment. Still need look into"},{"line_number":406,"context_line":"                # functional tests, this is not as we expected."},{"line_number":407,"context_line":"                provider_data \u003d self.prov_tree.data(rp_uuid)"},{"line_number":408,"context_line":"            except ValueError:"},{"line_number":409,"context_line":"                continue"}],"source_content_type":"text/x-python","patch_set":7,"id":"7faddb67_ff2bc37e","line":406,"range":{"start_line":402,"start_character":0,"end_line":406,"end_character":63},"updated":"2019-08-29 23:02:16.000000000","message":"Not having looked specifically, this is likely because older Placement microversions returned allocations in a different format [1]. It\u0027s probably something we should clean up, because we haven\u0027t used that format in several releases.\n\n[1] https://docs.openstack.org/api-ref/placement/?expanded\u003dlist-allocations-detail,list-allocation-candidates-detail,list-resource-provider-allocations-detail#response-example-microversions-1-10-1-11","commit_id":"fc0d1b1258d42a20044504a7ee6a1791183e3dd2"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"3d7eb310beac331848500982bb51dbd15256160b","unresolved":false,"context_lines":[{"line_number":399,"context_line":"        for rp_uuid in allocations:"},{"line_number":400,"context_line":"            resources \u003d allocations[rp_uuid][\u0027resources\u0027]"},{"line_number":401,"context_line":"            try:"},{"line_number":402,"context_line":"                # TODO(Luyao)"},{"line_number":403,"context_line":"                # In many functional tests, provider tree doesn\u0027t have"},{"line_number":404,"context_line":"                # rp uuids in allocations, we believe this won\u0027t happen"},{"line_number":405,"context_line":"                # in real OpenStack enviroment. Still need look into"},{"line_number":406,"context_line":"                # functional tests, this is not as we expected."},{"line_number":407,"context_line":"                provider_data \u003d self.prov_tree.data(rp_uuid)"},{"line_number":408,"context_line":"            except ValueError:"},{"line_number":409,"context_line":"                continue"}],"source_content_type":"text/x-python","patch_set":7,"id":"7faddb67_243620b6","line":406,"range":{"start_line":402,"start_character":0,"end_line":406,"end_character":63},"in_reply_to":"7faddb67_b3e1ffd1","updated":"2019-08-30 18:01:28.000000000","message":"Sorry, I understand now. You\u0027re saying that, in the test environment, the provider tree \"returned by the virt driver\" doesn\u0027t contain the providers for the port resources.\n\nYeah, I don\u0027t *think* that should happen in real life -- but we should probably ask gibi to be sure.","commit_id":"fc0d1b1258d42a20044504a7ee6a1791183e3dd2"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"2811d6d2430f7d90f17ad8be759240d4772e24eb","unresolved":false,"context_lines":[{"line_number":399,"context_line":"        for rp_uuid in allocations:"},{"line_number":400,"context_line":"            resources \u003d allocations[rp_uuid][\u0027resources\u0027]"},{"line_number":401,"context_line":"            try:"},{"line_number":402,"context_line":"                # TODO(Luyao)"},{"line_number":403,"context_line":"                # In many functional tests, provider tree doesn\u0027t have"},{"line_number":404,"context_line":"                # rp uuids in allocations, we believe this won\u0027t happen"},{"line_number":405,"context_line":"                # in real OpenStack enviroment. Still need look into"},{"line_number":406,"context_line":"                # functional tests, this is not as we expected."},{"line_number":407,"context_line":"                provider_data \u003d self.prov_tree.data(rp_uuid)"},{"line_number":408,"context_line":"            except ValueError:"},{"line_number":409,"context_line":"                continue"}],"source_content_type":"text/x-python","patch_set":7,"id":"7faddb67_b3e1ffd1","line":406,"range":{"start_line":402,"start_character":0,"end_line":406,"end_character":63},"in_reply_to":"7faddb67_ff2bc37e","updated":"2019-08-30 10:36:40.000000000","message":"It\u0027s not related to the allocation format. I checked one test of them, the format is right, but there are newtron port resources, should this be handled by neutronbut not  nova-compute.","commit_id":"fc0d1b1258d42a20044504a7ee6a1791183e3dd2"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"b16dd01a6ca36642942098e21057db3a7d899ffe","unresolved":false,"context_lines":[{"line_number":419,"context_line":"                assigned \u003d assigned_resources[rp_uuid].get(rc, set())"},{"line_number":420,"context_line":"                free \u003d self._get_free_resources(available, assigned)"},{"line_number":421,"context_line":"                if amount \u003e len(free):"},{"line_number":422,"context_line":"                    reason \u003d _(\"Resouce Class: %s\") % rc"},{"line_number":423,"context_line":"                    raise exception.ComputeResourcesUnavailable(reason\u003dreason)"},{"line_number":424,"context_line":"                for i in range(amount):"},{"line_number":425,"context_line":"                    claimed_resources.append(free.pop())"}],"source_content_type":"text/x-python","patch_set":7,"id":"7faddb67_1c026d0d","line":422,"range":{"start_line":422,"start_character":32,"end_line":422,"end_character":39},"updated":"2019-08-29 23:02:16.000000000","message":"Resource","commit_id":"fc0d1b1258d42a20044504a7ee6a1791183e3dd2"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"3a6ffebc5bb12a1f3216deb38873f566c6cdf37a","unresolved":false,"context_lines":[{"line_number":419,"context_line":"                assigned \u003d assigned_resources[rp_uuid].get(rc, set())"},{"line_number":420,"context_line":"                free \u003d self._get_free_resources(available, assigned)"},{"line_number":421,"context_line":"                if amount \u003e len(free):"},{"line_number":422,"context_line":"                    reason \u003d _(\"Resouce Class: %s\") % rc"},{"line_number":423,"context_line":"                    raise exception.ComputeResourcesUnavailable(reason\u003dreason)"},{"line_number":424,"context_line":"                for i in range(amount):"},{"line_number":425,"context_line":"                    claimed_resources.append(free.pop())"}],"source_content_type":"text/x-python","patch_set":7,"id":"7faddb67_ab40a960","line":422,"range":{"start_line":422,"start_character":32,"end_line":422,"end_character":39},"in_reply_to":"7faddb67_1c026d0d","updated":"2019-08-30 09:38:37.000000000","message":"Done","commit_id":"fc0d1b1258d42a20044504a7ee6a1791183e3dd2"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"b16dd01a6ca36642942098e21057db3a7d899ffe","unresolved":false,"context_lines":[{"line_number":428,"context_line":"            return objects.ResourceList(objects\u003dclaimed_resources)"},{"line_number":429,"context_line":"        return None"},{"line_number":430,"context_line":""},{"line_number":431,"context_line":"    def _get_assigned_resources(self, context, nodename):"},{"line_number":432,"context_line":"        \"\"\"Return organized assigned resources with resource class and"},{"line_number":433,"context_line":"        reource provider uuid."},{"line_number":434,"context_line":""}],"source_content_type":"text/x-python","patch_set":7,"id":"7faddb67_99d74f23","line":431,"range":{"start_line":431,"start_character":47,"end_line":431,"end_character":55},"updated":"2019-08-29 23:02:16.000000000","message":"not used","commit_id":"fc0d1b1258d42a20044504a7ee6a1791183e3dd2"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"b06ec915180eeb9bb04ebe77452b69d01bf22f17","unresolved":false,"context_lines":[{"line_number":428,"context_line":"            return objects.ResourceList(objects\u003dclaimed_resources)"},{"line_number":429,"context_line":"        return None"},{"line_number":430,"context_line":""},{"line_number":431,"context_line":"    def _get_assigned_resources(self, context, nodename):"},{"line_number":432,"context_line":"        \"\"\"Return organized assigned resources with resource class and"},{"line_number":433,"context_line":"        reource provider uuid."},{"line_number":434,"context_line":""}],"source_content_type":"text/x-python","patch_set":7,"id":"7faddb67_002af7e5","line":431,"range":{"start_line":431,"start_character":47,"end_line":431,"end_character":55},"in_reply_to":"7faddb67_99d74f23","updated":"2019-08-30 09:42:04.000000000","message":"Done","commit_id":"fc0d1b1258d42a20044504a7ee6a1791183e3dd2"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"b16dd01a6ca36642942098e21057db3a7d899ffe","unresolved":false,"context_lines":[{"line_number":440,"context_line":"        \"\"\""},{"line_number":441,"context_line":"        resources \u003d []"},{"line_number":442,"context_line":""},{"line_number":443,"context_line":"        def update_resources(instance, migration\u003dNone, host\u003dNone):"},{"line_number":444,"context_line":"            if not migration:"},{"line_number":445,"context_line":"                if instance.resources:"},{"line_number":446,"context_line":"                    resources.extend(instance.resources)"}],"source_content_type":"text/x-python","patch_set":7,"id":"7faddb67_fc08b1d9","line":443,"range":{"start_line":443,"start_character":55,"end_line":443,"end_character":64},"updated":"2019-08-29 23:02:16.000000000","message":"This doesn\u0027t seem necessary; just use self.host on L449 \u0026 L451.","commit_id":"fc0d1b1258d42a20044504a7ee6a1791183e3dd2"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"b16dd01a6ca36642942098e21057db3a7d899ffe","unresolved":false,"context_lines":[{"line_number":454,"context_line":"            for pre in prefix:"},{"line_number":455,"context_line":"                attr_name \u003d pre + \u0027resources\u0027"},{"line_number":456,"context_line":"                if attr_name in migration_ctxt:"},{"line_number":457,"context_line":"                    pre_res \u003d getattr(migration_ctxt, attr_name)"},{"line_number":458,"context_line":"                    resources.extend(pre_res.objects if pre_res else [])"},{"line_number":459,"context_line":""},{"line_number":460,"context_line":"        # Get resources assigned to instances in migrating"}],"source_content_type":"text/x-python","patch_set":7,"id":"7faddb67_9c7e5d19","line":457,"range":{"start_line":457,"start_character":30,"end_line":457,"end_character":37},"updated":"2019-08-29 23:02:16.000000000","message":"if you do getattr(migration_ctxt, attr_name, []) here, then you don\u0027t need to do the `if pre_res else []` on the next line","commit_id":"fc0d1b1258d42a20044504a7ee6a1791183e3dd2"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"b16dd01a6ca36642942098e21057db3a7d899ffe","unresolved":false,"context_lines":[{"line_number":455,"context_line":"                attr_name \u003d pre + \u0027resources\u0027"},{"line_number":456,"context_line":"                if attr_name in migration_ctxt:"},{"line_number":457,"context_line":"                    pre_res \u003d getattr(migration_ctxt, attr_name)"},{"line_number":458,"context_line":"                    resources.extend(pre_res.objects if pre_res else [])"},{"line_number":459,"context_line":""},{"line_number":460,"context_line":"        # Get resources assigned to instances in migrating"},{"line_number":461,"context_line":"        migrations \u003d self.tracked_migrations"}],"source_content_type":"text/x-python","patch_set":7,"id":"7faddb67_3ce889dd","line":458,"updated":"2019-08-29 23:02:16.000000000","message":"This inner method seems excessively complicated, and I don\u0027t love the fact that it modifies a variable in the parent method. I think it makes more sense to just blow this out into the parent and be explicit. You don\u0027t actually lose LOC this way, and IMO it\u0027s easier to read:\n\n resources \u003d []\n for mig in self.tracked_migrations.values()\n     mig_ctx \u003d mig.instance.migration_context\n     if mig.source_compute \u003d\u003d self.host and \u0027old_resources\u0027 in mig_ctx:\n         resources.extend(mig_ctx.old_resources or [])\n     if mig.dest_compute \u003d\u003d self.host and \u0027new_resources\u0027 in mig_ctx:\n         resources.extend(mig_ctx.new_resources or [])\n\n instances \u003d objects.InstanceList.get_by_filters(\n     context, {\u0027uuid\u0027: self.tracked_instances, \u0027deleted\u0027: False},\n     expected_attrs\u003d[\u0027resources\u0027])\n\n for inst in instances:\n     resources.extend(instance.resources or [])\n\n ...\n\nI think it would also be worth breaking that part ^ out into its own method and doing the conversion to dict format separately.","commit_id":"fc0d1b1258d42a20044504a7ee6a1791183e3dd2"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"b06ec915180eeb9bb04ebe77452b69d01bf22f17","unresolved":false,"context_lines":[{"line_number":455,"context_line":"                attr_name \u003d pre + \u0027resources\u0027"},{"line_number":456,"context_line":"                if attr_name in migration_ctxt:"},{"line_number":457,"context_line":"                    pre_res \u003d getattr(migration_ctxt, attr_name)"},{"line_number":458,"context_line":"                    resources.extend(pre_res.objects if pre_res else [])"},{"line_number":459,"context_line":""},{"line_number":460,"context_line":"        # Get resources assigned to instances in migrating"},{"line_number":461,"context_line":"        migrations \u003d self.tracked_migrations"}],"source_content_type":"text/x-python","patch_set":7,"id":"7faddb67_e0347b4b","line":458,"in_reply_to":"7faddb67_3ce889dd","updated":"2019-08-30 09:42:04.000000000","message":"Done","commit_id":"fc0d1b1258d42a20044504a7ee6a1791183e3dd2"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"b16dd01a6ca36642942098e21057db3a7d899ffe","unresolved":false,"context_lines":[{"line_number":459,"context_line":""},{"line_number":460,"context_line":"        # Get resources assigned to instances in migrating"},{"line_number":461,"context_line":"        migrations \u003d self.tracked_migrations"},{"line_number":462,"context_line":"        for inst_uuid, migration in migrations.items():"},{"line_number":463,"context_line":"            update_resources(migration.instance, migration, host\u003dself.host)"},{"line_number":464,"context_line":""},{"line_number":465,"context_line":"        # Get resources assigned to instances not in migrating"}],"source_content_type":"text/x-python","patch_set":7,"id":"7faddb67_bcb559ef","line":462,"range":{"start_line":462,"start_character":12,"end_line":462,"end_character":21},"updated":"2019-08-29 23:02:16.000000000","message":"not used; just do\n\n for migration in migrations.values()","commit_id":"fc0d1b1258d42a20044504a7ee6a1791183e3dd2"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"b06ec915180eeb9bb04ebe77452b69d01bf22f17","unresolved":false,"context_lines":[{"line_number":459,"context_line":""},{"line_number":460,"context_line":"        # Get resources assigned to instances in migrating"},{"line_number":461,"context_line":"        migrations \u003d self.tracked_migrations"},{"line_number":462,"context_line":"        for inst_uuid, migration in migrations.items():"},{"line_number":463,"context_line":"            update_resources(migration.instance, migration, host\u003dself.host)"},{"line_number":464,"context_line":""},{"line_number":465,"context_line":"        # Get resources assigned to instances not in migrating"}],"source_content_type":"text/x-python","patch_set":7,"id":"7faddb67_803d872d","line":462,"range":{"start_line":462,"start_character":12,"end_line":462,"end_character":21},"in_reply_to":"7faddb67_bcb559ef","updated":"2019-08-30 09:42:04.000000000","message":"Done","commit_id":"fc0d1b1258d42a20044504a7ee6a1791183e3dd2"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"b16dd01a6ca36642942098e21057db3a7d899ffe","unresolved":false,"context_lines":[{"line_number":460,"context_line":"        # Get resources assigned to instances in migrating"},{"line_number":461,"context_line":"        migrations \u003d self.tracked_migrations"},{"line_number":462,"context_line":"        for inst_uuid, migration in migrations.items():"},{"line_number":463,"context_line":"            update_resources(migration.instance, migration, host\u003dself.host)"},{"line_number":464,"context_line":""},{"line_number":465,"context_line":"        # Get resources assigned to instances not in migrating"},{"line_number":466,"context_line":"        instance_uuids \u003d self.tracked_instances"}],"source_content_type":"text/x-python","patch_set":7,"id":"7faddb67_3c65e9af","line":463,"range":{"start_line":463,"start_character":49,"end_line":463,"end_character":58},"updated":"2019-08-29 23:02:16.000000000","message":"prefer naming kwargs","commit_id":"fc0d1b1258d42a20044504a7ee6a1791183e3dd2"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"b16dd01a6ca36642942098e21057db3a7d899ffe","unresolved":false,"context_lines":[{"line_number":463,"context_line":"            update_resources(migration.instance, migration, host\u003dself.host)"},{"line_number":464,"context_line":""},{"line_number":465,"context_line":"        # Get resources assigned to instances not in migrating"},{"line_number":466,"context_line":"        instance_uuids \u003d self.tracked_instances"},{"line_number":467,"context_line":"        # TODO(Luyao) We can cache instance obj in self.tracked_instances"},{"line_number":468,"context_line":"        instances \u003d objects.InstanceList.get_by_filters("},{"line_number":469,"context_line":"            context, {\u0027uuid\u0027: instance_uuids}, expected_attrs\u003d[\u0027resources\u0027],"}],"source_content_type":"text/x-python","patch_set":7,"id":"7faddb67_9cac1d89","line":466,"range":{"start_line":466,"start_character":8,"end_line":466,"end_character":22},"updated":"2019-08-29 23:02:16.000000000","message":"this var seems unnecessary since you\u0027re just using it once; just use self.tracked_instances below.","commit_id":"fc0d1b1258d42a20044504a7ee6a1791183e3dd2"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"b16dd01a6ca36642942098e21057db3a7d899ffe","unresolved":false,"context_lines":[{"line_number":464,"context_line":""},{"line_number":465,"context_line":"        # Get resources assigned to instances not in migrating"},{"line_number":466,"context_line":"        instance_uuids \u003d self.tracked_instances"},{"line_number":467,"context_line":"        # TODO(Luyao) We can cache instance obj in self.tracked_instances"},{"line_number":468,"context_line":"        instances \u003d objects.InstanceList.get_by_filters("},{"line_number":469,"context_line":"            context, {\u0027uuid\u0027: instance_uuids}, expected_attrs\u003d[\u0027resources\u0027],"},{"line_number":470,"context_line":"            use_slave\u003dTrue)"},{"line_number":471,"context_line":"        for instance in instances:"},{"line_number":472,"context_line":"            update_resources(instance)"},{"line_number":473,"context_line":""}],"source_content_type":"text/x-python","patch_set":7,"id":"7faddb67_d9770708","line":470,"range":{"start_line":467,"start_character":0,"end_line":470,"end_character":27},"updated":"2019-08-29 23:02:16.000000000","message":"Couple things here.\n\n- I think this gets deleted instances. I assume those should have no `resources` (or if they do, they\u0027re not really claimed) so we might as well not retrieve them.\n- use_slave doesn\u0027t seem to do anything. What were you expecting?\n- Even long-term, the most common instance won\u0027t have any `resources`, so we could make this more efficient by adding a filter to only retrieve instances where `resources` IS NOT NULL. That might be a tweak for a followon.\n\nBut my biggest concern:\n\n- Ew, we\u0027re grabbing *all* this host\u0027s instances *every* time we do a claim? That doesn\u0027t seem like a good plan. As noted in your TODO, we should cache -- but we should just cache the (claimed) resources, not the whole Instance (particularly because, as noted above, most Instances won\u0027t have any resources). And when we claim/unclaim, we update that cache (under lock). The initial setup of the cache can be done in the code path where you currently have _check_resources -- i.e. only triggered on startup.","commit_id":"fc0d1b1258d42a20044504a7ee6a1791183e3dd2"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"b16dd01a6ca36642942098e21057db3a7d899ffe","unresolved":false,"context_lines":[{"line_number":476,"context_line":"            rp_uuid \u003d resource.rp_uuid"},{"line_number":477,"context_line":"            rc \u003d resource.resource_class"},{"line_number":478,"context_line":"            identifier \u003d resource.identifier"},{"line_number":479,"context_line":"            assigned_resources[rp_uuid].setdefault(rc, set())"},{"line_number":480,"context_line":"            assigned_resources[rp_uuid][rc].add(identifier)"},{"line_number":481,"context_line":""},{"line_number":482,"context_line":"        return assigned_resources"}],"source_content_type":"text/x-python","patch_set":7,"id":"7faddb67_bc0d5990","line":479,"range":{"start_line":479,"start_character":12,"end_line":479,"end_character":61},"updated":"2019-08-29 23:02:16.000000000","message":"If you wanted to get clever, you could make assigned_resources a nested defaultdict like this:\n\n assigned_resources \u003d collections.defaultdict(\n     lambda: collections.defaultdict(set))\n\n...and then you wouldn\u0027t need this line.","commit_id":"fc0d1b1258d42a20044504a7ee6a1791183e3dd2"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"b16dd01a6ca36642942098e21057db3a7d899ffe","unresolved":false,"context_lines":[{"line_number":482,"context_line":"        return assigned_resources"},{"line_number":483,"context_line":""},{"line_number":484,"context_line":"    def _get_free_resources(self, available, assigned):"},{"line_number":485,"context_line":"        \"\"\"Get free resource of one specific resource class."},{"line_number":486,"context_line":""},{"line_number":487,"context_line":"        :param available: list of objects.Resource"},{"line_number":488,"context_line":"        :param assigned: set of objects.Resource.identifier"}],"source_content_type":"text/x-python","patch_set":7,"id":"7faddb67_bc8239c6","line":485,"range":{"start_line":485,"start_character":29,"end_line":485,"end_character":59},"updated":"2019-08-29 23:02:16.000000000","message":"This method doesn\u0027t do anything with resource classes. (You happen to be limiting to a single resource class at the caller, but that\u0027s not relevant in this context.)","commit_id":"fc0d1b1258d42a20044504a7ee6a1791183e3dd2"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"3a6ffebc5bb12a1f3216deb38873f566c6cdf37a","unresolved":false,"context_lines":[{"line_number":482,"context_line":"        return assigned_resources"},{"line_number":483,"context_line":""},{"line_number":484,"context_line":"    def _get_free_resources(self, available, assigned):"},{"line_number":485,"context_line":"        \"\"\"Get free resource of one specific resource class."},{"line_number":486,"context_line":""},{"line_number":487,"context_line":"        :param available: list of objects.Resource"},{"line_number":488,"context_line":"        :param assigned: set of objects.Resource.identifier"}],"source_content_type":"text/x-python","patch_set":7,"id":"7faddb67_e098fb69","line":485,"range":{"start_line":485,"start_character":29,"end_line":485,"end_character":59},"in_reply_to":"7faddb67_bc8239c6","updated":"2019-08-30 09:38:37.000000000","message":"this method is removed, I don\u0027t need this any more.\njust use \u0027all_resources - assigned\u0027 to get free resources, because we use set now.","commit_id":"fc0d1b1258d42a20044504a7ee6a1791183e3dd2"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"b16dd01a6ca36642942098e21057db3a7d899ffe","unresolved":false,"context_lines":[{"line_number":484,"context_line":"    def _get_free_resources(self, available, assigned):"},{"line_number":485,"context_line":"        \"\"\"Get free resource of one specific resource class."},{"line_number":486,"context_line":""},{"line_number":487,"context_line":"        :param available: list of objects.Resource"},{"line_number":488,"context_line":"        :param assigned: set of objects.Resource.identifier"},{"line_number":489,"context_line":"        :returns: list of objects.Resource"},{"line_number":490,"context_line":"        \"\"\""}],"source_content_type":"text/x-python","patch_set":7,"id":"7faddb67_dcc5b50b","line":487,"range":{"start_line":487,"start_character":15,"end_line":487,"end_character":24},"updated":"2019-08-29 23:02:16.000000000","message":"This is a misleading name: \u0027available\u0027 is sort of synonymous with \u0027free\u0027. I would suggest \u0027all\u0027, but that\u0027s a reserved word :(  Could use \u0027all_resources\u0027.\n\nIn either case, document that it means *all* resources, free and assigned.","commit_id":"fc0d1b1258d42a20044504a7ee6a1791183e3dd2"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"b16dd01a6ca36642942098e21057db3a7d899ffe","unresolved":false,"context_lines":[{"line_number":488,"context_line":"        :param assigned: set of objects.Resource.identifier"},{"line_number":489,"context_line":"        :returns: list of objects.Resource"},{"line_number":490,"context_line":"        \"\"\""},{"line_number":491,"context_line":"        free \u003d []"},{"line_number":492,"context_line":"        for resource in available:"},{"line_number":493,"context_line":"            if resource.identifier not in assigned:"},{"line_number":494,"context_line":"                free.append(resource)"},{"line_number":495,"context_line":"        return free"},{"line_number":496,"context_line":""},{"line_number":497,"context_line":"    def _check_resources(self, context, nodename):"},{"line_number":498,"context_line":"        \"\"\"Check if there are assigned resources not found in provider tree\"\"\""}],"source_content_type":"text/x-python","patch_set":7,"id":"7faddb67_7c684120","line":495,"range":{"start_line":491,"start_character":0,"end_line":495,"end_character":19},"updated":"2019-08-29 23:02:16.000000000","message":"So once again, if you were using sets, this would just be\n\n available - assigned\n\n(and you could inline it where it\u0027s used)","commit_id":"fc0d1b1258d42a20044504a7ee6a1791183e3dd2"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"b16dd01a6ca36642942098e21057db3a7d899ffe","unresolved":false,"context_lines":[{"line_number":500,"context_line":"        for rp_uuid in assigned_resources:"},{"line_number":501,"context_line":"            provider_data \u003d self.prov_tree.data(rp_uuid)"},{"line_number":502,"context_line":"            for rc in assigned_resources[rp_uuid]:"},{"line_number":503,"context_line":"                available \u003d provider_data.resources.get(rc, [])"},{"line_number":504,"context_line":"                assigned \u003d assigned_resources[rp_uuid][rc]"},{"line_number":505,"context_line":"                for resource in available:"},{"line_number":506,"context_line":"                    if resource.identifier in assigned:"},{"line_number":507,"context_line":"                        assigned.remove(resource.identifier)"},{"line_number":508,"context_line":"                if assigned:"},{"line_number":509,"context_line":"                    raise exception.AssignedResourceNotFound("},{"line_number":510,"context_line":"                        resources\u003dassigned)"},{"line_number":511,"context_line":""}],"source_content_type":"text/x-python","patch_set":7,"id":"7faddb67_3cdc09e0","line":508,"range":{"start_line":503,"start_character":0,"end_line":508,"end_character":28},"updated":"2019-08-29 23:02:16.000000000","message":"This could be simplified a bit:\n\n available \u003d set(r.identifier for r in provider_data.resources.get(rc, []))\n extras \u003d assigned_resources[rp_uuid][rc] - available\n if extras:\n     raise ...","commit_id":"fc0d1b1258d42a20044504a7ee6a1791183e3dd2"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"b16dd01a6ca36642942098e21057db3a7d899ffe","unresolved":false,"context_lines":[{"line_number":507,"context_line":"                        assigned.remove(resource.identifier)"},{"line_number":508,"context_line":"                if assigned:"},{"line_number":509,"context_line":"                    raise exception.AssignedResourceNotFound("},{"line_number":510,"context_line":"                        resources\u003dassigned)"},{"line_number":511,"context_line":""},{"line_number":512,"context_line":"    def _set_instance_host_and_node(self, instance, nodename):"},{"line_number":513,"context_line":"        \"\"\"Tag the instance as belonging to this host.  This should be done"}],"source_content_type":"text/x-python","patch_set":7,"id":"7faddb67_5c5ea545","line":510,"range":{"start_line":510,"start_character":34,"end_line":510,"end_character":42},"updated":"2019-08-29 23:02:16.000000000","message":"This is a set() of Resource.identifier, right? So in the exception string it\u0027ll render as \"set([\u0027ident\u0027, ...])\", which isn\u0027t ideal. Consider:\n\n resources\u003d\u0027, \u0027.join(assigned)","commit_id":"fc0d1b1258d42a20044504a7ee6a1791183e3dd2"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"b16dd01a6ca36642942098e21057db3a7d899ffe","unresolved":false,"context_lines":[{"line_number":1169,"context_line":"            self._check_resources(context, nodename)"},{"line_number":1170,"context_line":"        # Flush any changes. If we processed ReshapeNeeded above, allocs is not"},{"line_number":1171,"context_line":"        # None, and this will hit placement\u0027s POST /reshaper route."},{"line_number":1172,"context_line":"        self.prov_tree \u003d prov_tree"},{"line_number":1173,"context_line":"        self.reportclient.update_from_provider_tree(context, prov_tree,"},{"line_number":1174,"context_line":"                                                    allocations\u003dallocs)"},{"line_number":1175,"context_line":""}],"source_content_type":"text/x-python","patch_set":7,"id":"7faddb67_fc667129","line":1172,"range":{"start_line":1172,"start_character":8,"end_line":1172,"end_character":34},"updated":"2019-08-29 23:02:16.000000000","message":"Curious why we\u0027re waiting until here to set this instance attr, as opposed to doing it on L1108 and using it throughout.\n\nAlso, it doesn\u0027t make sense for this to be the first thing after the above comment.","commit_id":"fc0d1b1258d42a20044504a7ee6a1791183e3dd2"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"3d7eb310beac331848500982bb51dbd15256160b","unresolved":false,"context_lines":[{"line_number":1169,"context_line":"            self._check_resources(context, nodename)"},{"line_number":1170,"context_line":"        # Flush any changes. If we processed ReshapeNeeded above, allocs is not"},{"line_number":1171,"context_line":"        # None, and this will hit placement\u0027s POST /reshaper route."},{"line_number":1172,"context_line":"        self.prov_tree \u003d prov_tree"},{"line_number":1173,"context_line":"        self.reportclient.update_from_provider_tree(context, prov_tree,"},{"line_number":1174,"context_line":"                                                    allocations\u003dallocs)"},{"line_number":1175,"context_line":""}],"source_content_type":"text/x-python","patch_set":7,"id":"7faddb67_aadbb97a","line":1172,"range":{"start_line":1172,"start_character":8,"end_line":1172,"end_character":34},"in_reply_to":"7faddb67_40c0ef2b","updated":"2019-08-30 18:01:28.000000000","message":"Okay, now I think I understand why this was done, and it should probably be put back the way it was.\n\nSetting this up right after get_provider_tree_and_ensure_root means we don\u0027t yet have the (latest) resource information from the virt driver. If something goes wrong in the body of _update_to_placement, the data would remain stale.\n\nSo you had it right before - sorry about that :)","commit_id":"fc0d1b1258d42a20044504a7ee6a1791183e3dd2"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"3a6ffebc5bb12a1f3216deb38873f566c6cdf37a","unresolved":false,"context_lines":[{"line_number":1169,"context_line":"            self._check_resources(context, nodename)"},{"line_number":1170,"context_line":"        # Flush any changes. If we processed ReshapeNeeded above, allocs is not"},{"line_number":1171,"context_line":"        # None, and this will hit placement\u0027s POST /reshaper route."},{"line_number":1172,"context_line":"        self.prov_tree \u003d prov_tree"},{"line_number":1173,"context_line":"        self.reportclient.update_from_provider_tree(context, prov_tree,"},{"line_number":1174,"context_line":"                                                    allocations\u003dallocs)"},{"line_number":1175,"context_line":""}],"source_content_type":"text/x-python","patch_set":7,"id":"7faddb67_40c0ef2b","line":1172,"range":{"start_line":1172,"start_character":8,"end_line":1172,"end_character":34},"in_reply_to":"7faddb67_fc667129","updated":"2019-08-30 09:38:37.000000000","message":"Done","commit_id":"fc0d1b1258d42a20044504a7ee6a1791183e3dd2"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"3d7eb310beac331848500982bb51dbd15256160b","unresolved":false,"context_lines":[{"line_number":158,"context_line":"        self.assigned_resources \u003d collections.defaultdict("},{"line_number":159,"context_line":"            lambda: collections.defaultdict(set))"},{"line_number":160,"context_line":""},{"line_number":161,"context_line":"    @utils.synchronized(COMPUTE_RESOURCE_SEMAPHORE)"},{"line_number":162,"context_line":"    def instance_claim(self, context, instance, nodename, allocations,"},{"line_number":163,"context_line":"                       limits\u003dNone):"},{"line_number":164,"context_line":"        \"\"\"Indicate that some resources are needed for an upcoming compute"}],"source_content_type":"text/x-python","patch_set":10,"id":"7faddb67_e4b00800","line":161,"range":{"start_line":161,"start_character":4,"end_line":161,"end_character":51},"updated":"2019-08-30 18:01:28.000000000","message":"✔","commit_id":"3263c8915f740ac3f311e743ddac63151055114e"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"3d7eb310beac331848500982bb51dbd15256160b","unresolved":false,"context_lines":[{"line_number":234,"context_line":""},{"line_number":235,"context_line":"        return claim"},{"line_number":236,"context_line":""},{"line_number":237,"context_line":"    @utils.synchronized(COMPUTE_RESOURCE_SEMAPHORE)"},{"line_number":238,"context_line":"    def rebuild_claim(self, context, instance, nodename, allocations,"},{"line_number":239,"context_line":"                      limits\u003dNone, image_meta\u003dNone, migration\u003dNone):"},{"line_number":240,"context_line":"        \"\"\"Create a claim for a rebuild operation.\"\"\""}],"source_content_type":"text/x-python","patch_set":10,"id":"7faddb67_a4ce9080","line":237,"range":{"start_line":237,"start_character":4,"end_line":237,"end_character":51},"updated":"2019-08-30 18:01:28.000000000","message":"✔","commit_id":"3263c8915f740ac3f311e743ddac63151055114e"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"3d7eb310beac331848500982bb51dbd15256160b","unresolved":false,"context_lines":[{"line_number":243,"context_line":"                                migration, allocations, move_type\u003d\u0027evacuation\u0027,"},{"line_number":244,"context_line":"                                limits\u003dlimits, image_meta\u003dimage_meta)"},{"line_number":245,"context_line":""},{"line_number":246,"context_line":"    @utils.synchronized(COMPUTE_RESOURCE_SEMAPHORE)"},{"line_number":247,"context_line":"    def resize_claim(self, context, instance, instance_type, nodename,"},{"line_number":248,"context_line":"                     migration, allocations, image_meta\u003dNone, limits\u003dNone):"},{"line_number":249,"context_line":"        \"\"\"Create a claim for a resize or cold-migration move."}],"source_content_type":"text/x-python","patch_set":10,"id":"7faddb67_c4cb8c6f","line":246,"range":{"start_line":246,"start_character":4,"end_line":246,"end_character":51},"updated":"2019-08-30 18:01:28.000000000","message":"✔","commit_id":"3263c8915f740ac3f311e743ddac63151055114e"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"3d7eb310beac331848500982bb51dbd15256160b","unresolved":false,"context_lines":[{"line_number":390,"context_line":"        migration.status \u003d \u0027pre-migrating\u0027"},{"line_number":391,"context_line":"        migration.save()"},{"line_number":392,"context_line":""},{"line_number":393,"context_line":"    def _claim_resources(self, allocations):"},{"line_number":394,"context_line":"        \"\"\"Claim resources according to assigned resources from allocations"},{"line_number":395,"context_line":"        and available resources in provider tree"},{"line_number":396,"context_line":"        \"\"\""}],"source_content_type":"text/x-python","patch_set":10,"id":"7faddb67_84c11451","line":393,"range":{"start_line":393,"start_character":8,"end_line":393,"end_character":24},"updated":"2019-08-30 18:01:28.000000000","message":"nts: this is already @synchronized(COMPUTE_RESOURCE_SEMAPHORE) up the stack ✔","commit_id":"3263c8915f740ac3f311e743ddac63151055114e"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"3d7eb310beac331848500982bb51dbd15256160b","unresolved":false,"context_lines":[{"line_number":397,"context_line":"        if not allocations:"},{"line_number":398,"context_line":"            return None"},{"line_number":399,"context_line":"        claimed_resources \u003d []"},{"line_number":400,"context_line":"        assigned_resources \u003d self.assigned_resources"},{"line_number":401,"context_line":"        for rp_uuid, alloc_dict in allocations.items():"},{"line_number":402,"context_line":"            allocate_resources \u003d alloc_dict[\u0027resources\u0027]"},{"line_number":403,"context_line":"            try:"}],"source_content_type":"text/x-python","patch_set":10,"id":"7faddb67_27c62218","line":400,"range":{"start_line":400,"start_character":8,"end_line":400,"end_character":26},"updated":"2019-08-30 18:01:28.000000000","message":"No need for this extra variable.\n\n(In particular, this is *not* making a deep copy of self.assigned_resources. Nor should it.)","commit_id":"3263c8915f740ac3f311e743ddac63151055114e"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"2277fceb9be589ebbcea73aa254c7576c3587dae","unresolved":false,"context_lines":[{"line_number":397,"context_line":"        if not allocations:"},{"line_number":398,"context_line":"            return None"},{"line_number":399,"context_line":"        claimed_resources \u003d []"},{"line_number":400,"context_line":"        assigned_resources \u003d self.assigned_resources"},{"line_number":401,"context_line":"        for rp_uuid, alloc_dict in allocations.items():"},{"line_number":402,"context_line":"            allocate_resources \u003d alloc_dict[\u0027resources\u0027]"},{"line_number":403,"context_line":"            try:"}],"source_content_type":"text/x-python","patch_set":10,"id":"7faddb67_308e4f27","line":400,"range":{"start_line":400,"start_character":8,"end_line":400,"end_character":26},"in_reply_to":"7faddb67_27c62218","updated":"2019-09-02 07:10:33.000000000","message":"Done","commit_id":"3263c8915f740ac3f311e743ddac63151055114e"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"3d7eb310beac331848500982bb51dbd15256160b","unresolved":false,"context_lines":[{"line_number":399,"context_line":"        claimed_resources \u003d []"},{"line_number":400,"context_line":"        assigned_resources \u003d self.assigned_resources"},{"line_number":401,"context_line":"        for rp_uuid, alloc_dict in allocations.items():"},{"line_number":402,"context_line":"            allocate_resources \u003d alloc_dict[\u0027resources\u0027]"},{"line_number":403,"context_line":"            try:"},{"line_number":404,"context_line":"                # TODO(Luyao)"},{"line_number":405,"context_line":"                # In many functional tests, provider tree doesn\u0027t have"}],"source_content_type":"text/x-python","patch_set":10,"id":"7faddb67_2404e0c5","line":402,"range":{"start_line":402,"start_character":12,"end_line":402,"end_character":20},"updated":"2019-08-30 18:01:28.000000000","message":"allocated","commit_id":"3263c8915f740ac3f311e743ddac63151055114e"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"2277fceb9be589ebbcea73aa254c7576c3587dae","unresolved":false,"context_lines":[{"line_number":399,"context_line":"        claimed_resources \u003d []"},{"line_number":400,"context_line":"        assigned_resources \u003d self.assigned_resources"},{"line_number":401,"context_line":"        for rp_uuid, alloc_dict in allocations.items():"},{"line_number":402,"context_line":"            allocate_resources \u003d alloc_dict[\u0027resources\u0027]"},{"line_number":403,"context_line":"            try:"},{"line_number":404,"context_line":"                # TODO(Luyao)"},{"line_number":405,"context_line":"                # In many functional tests, provider tree doesn\u0027t have"}],"source_content_type":"text/x-python","patch_set":10,"id":"7faddb67_b0a1df97","line":402,"range":{"start_line":402,"start_character":12,"end_line":402,"end_character":20},"in_reply_to":"7faddb67_2404e0c5","updated":"2019-09-02 07:10:33.000000000","message":"Done","commit_id":"3263c8915f740ac3f311e743ddac63151055114e"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"3d7eb310beac331848500982bb51dbd15256160b","unresolved":false,"context_lines":[{"line_number":406,"context_line":"                # rp uuids in allocations, we believe this won\u0027t happen"},{"line_number":407,"context_line":"                # in real OpenStack enviroment. Still need look into"},{"line_number":408,"context_line":"                # functional tests, this is not as we expected."},{"line_number":409,"context_line":"                provider_data \u003d self.prov_tree.data(rp_uuid)"},{"line_number":410,"context_line":"            except ValueError:"},{"line_number":411,"context_line":"                continue"},{"line_number":412,"context_line":"            for rc, amount in allocate_resources.items():"}],"source_content_type":"text/x-python","patch_set":10,"id":"7faddb67_2a5fc9e5","line":409,"range":{"start_line":409,"start_character":32,"end_line":409,"end_character":60},"updated":"2019-08-30 18:01:28.000000000","message":"I\u0027m a little bit concerned about this access of self.prov_tree racing with it being updated from _update_to_placement.\n\nI would think in the general case the resources herein should almost never change after initial startup, so it\u0027s probably not an issue.","commit_id":"3263c8915f740ac3f311e743ddac63151055114e"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"3d7eb310beac331848500982bb51dbd15256160b","unresolved":false,"context_lines":[{"line_number":410,"context_line":"            except ValueError:"},{"line_number":411,"context_line":"                continue"},{"line_number":412,"context_line":"            for rc, amount in allocate_resources.items():"},{"line_number":413,"context_line":"                if rc not in provider_data.resources:"},{"line_number":414,"context_line":"                    # This means we don\u0027t use provider_data.resources to"},{"line_number":415,"context_line":"                    # assign this kind of resource class, such as \u0027VCPU\u0027 for"},{"line_number":416,"context_line":"                    # now, otherwise the provider_data.resources will be"}],"source_content_type":"text/x-python","patch_set":10,"id":"7faddb67_a7969293","line":413,"range":{"start_line":413,"start_character":16,"end_line":413,"end_character":52},"updated":"2019-08-30 18:01:28.000000000","message":"Consider broadening this to something more like:\n\n if not provider_data.resources.get(rc):\n\n...to tolerate the case where the virt driver puts down an empty set or explicitly None for the resources for a given RC instead of omitting it entirely.","commit_id":"3263c8915f740ac3f311e743ddac63151055114e"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"2277fceb9be589ebbcea73aa254c7576c3587dae","unresolved":false,"context_lines":[{"line_number":410,"context_line":"            except ValueError:"},{"line_number":411,"context_line":"                continue"},{"line_number":412,"context_line":"            for rc, amount in allocate_resources.items():"},{"line_number":413,"context_line":"                if rc not in provider_data.resources:"},{"line_number":414,"context_line":"                    # This means we don\u0027t use provider_data.resources to"},{"line_number":415,"context_line":"                    # assign this kind of resource class, such as \u0027VCPU\u0027 for"},{"line_number":416,"context_line":"                    # now, otherwise the provider_data.resources will be"}],"source_content_type":"text/x-python","patch_set":10,"id":"7faddb67_b026bf15","line":413,"range":{"start_line":413,"start_character":16,"end_line":413,"end_character":52},"in_reply_to":"7faddb67_a7969293","updated":"2019-09-02 07:10:33.000000000","message":"We should not tolerate this case, the case you mentioned means that the available resources is empty, it should go into the following process to try claiming resources and then trigger the exception \"ComputeResourceUnavailable\".\n\nSee the note here, this is for skipping those resources that not use provider_data.resources to claim resources.","commit_id":"3263c8915f740ac3f311e743ddac63151055114e"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"3d7eb310beac331848500982bb51dbd15256160b","unresolved":false,"context_lines":[{"line_number":422,"context_line":"                free \u003d all_resources - assigned"},{"line_number":423,"context_line":"                if amount \u003e len(free):"},{"line_number":424,"context_line":"                    reason \u003d _(\"Resource Class: %s\") % rc"},{"line_number":425,"context_line":"                    raise exception.ComputeResourcesUnavailable(reason\u003dreason)"},{"line_number":426,"context_line":"                for i in range(amount):"},{"line_number":427,"context_line":"                    resource \u003d free.pop()"},{"line_number":428,"context_line":"                    claimed_resources.append(resource)"}],"source_content_type":"text/x-python","patch_set":10,"id":"7faddb67_a7545255","line":425,"range":{"start_line":425,"start_character":36,"end_line":425,"end_character":63},"updated":"2019-08-30 18:01:28.000000000","message":"If we hit this exception *after* the first loop, we will have already modified self.assigned_resources, resulting in at least one leaked assignment.\n\nYou should instead wait until after the loops complete and merge claimed_resources into assigned_resources.\n\nAnd you should write a test to prove that this works properly.","commit_id":"3263c8915f740ac3f311e743ddac63151055114e"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"2277fceb9be589ebbcea73aa254c7576c3587dae","unresolved":false,"context_lines":[{"line_number":422,"context_line":"                free \u003d all_resources - assigned"},{"line_number":423,"context_line":"                if amount \u003e len(free):"},{"line_number":424,"context_line":"                    reason \u003d _(\"Resource Class: %s\") % rc"},{"line_number":425,"context_line":"                    raise exception.ComputeResourcesUnavailable(reason\u003dreason)"},{"line_number":426,"context_line":"                for i in range(amount):"},{"line_number":427,"context_line":"                    resource \u003d free.pop()"},{"line_number":428,"context_line":"                    claimed_resources.append(resource)"}],"source_content_type":"text/x-python","patch_set":10,"id":"7faddb67_d0233b04","line":425,"range":{"start_line":425,"start_character":36,"end_line":425,"end_character":63},"in_reply_to":"7faddb67_a7545255","updated":"2019-09-02 07:10:33.000000000","message":"Done","commit_id":"3263c8915f740ac3f311e743ddac63151055114e"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"3d7eb310beac331848500982bb51dbd15256160b","unresolved":false,"context_lines":[{"line_number":432,"context_line":"            return objects.ResourceList(objects\u003dclaimed_resources)"},{"line_number":433,"context_line":"        return None"},{"line_number":434,"context_line":""},{"line_number":435,"context_line":"    def _get_assigned_resources(self, context):"},{"line_number":436,"context_line":"        \"\"\"Return organized assigned resources with resource class and"},{"line_number":437,"context_line":"        reource provider uuid."},{"line_number":438,"context_line":""}],"source_content_type":"text/x-python","patch_set":10,"id":"7faddb67_e767aa23","line":435,"range":{"start_line":435,"start_character":8,"end_line":435,"end_character":31},"updated":"2019-08-30 18:01:28.000000000","message":"Either this method should be called something more like _populate_assigned_resources (and not return anything), or it should return the data structure instead of having the side-effect of modifying self.assigned_resources.\n\nIn either case, this should be invoked immediately during __init__, not via _check_resources (see also below).","commit_id":"3263c8915f740ac3f311e743ddac63151055114e"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"2277fceb9be589ebbcea73aa254c7576c3587dae","unresolved":false,"context_lines":[{"line_number":432,"context_line":"            return objects.ResourceList(objects\u003dclaimed_resources)"},{"line_number":433,"context_line":"        return None"},{"line_number":434,"context_line":""},{"line_number":435,"context_line":"    def _get_assigned_resources(self, context):"},{"line_number":436,"context_line":"        \"\"\"Return organized assigned resources with resource class and"},{"line_number":437,"context_line":"        reource provider uuid."},{"line_number":438,"context_line":""}],"source_content_type":"text/x-python","patch_set":10,"id":"7faddb67_108313cd","line":435,"range":{"start_line":435,"start_character":8,"end_line":435,"end_character":31},"in_reply_to":"7faddb67_e767aa23","updated":"2019-09-02 07:10:33.000000000","message":"I couldn\u0027t populate the assigned resources during __init__,  because it\u0027s based on self.tracked_instances and self.tracked_migrations.\n\nI\u0027ll change this method name, and put it after self.tracked_instances and self.tracked_migrations populated in _update_available_resource.","commit_id":"3263c8915f740ac3f311e743ddac63151055114e"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"3d7eb310beac331848500982bb51dbd15256160b","unresolved":false,"context_lines":[{"line_number":434,"context_line":""},{"line_number":435,"context_line":"    def _get_assigned_resources(self, context):"},{"line_number":436,"context_line":"        \"\"\"Return organized assigned resources with resource class and"},{"line_number":437,"context_line":"        reource provider uuid."},{"line_number":438,"context_line":""},{"line_number":439,"context_line":"        :returns: {"},{"line_number":440,"context_line":"            $RP_UUID: {"}],"source_content_type":"text/x-python","patch_set":10,"id":"7faddb67_a7d9b2f4","line":437,"updated":"2019-08-30 18:01:28.000000000","message":"Would be worth adding something like\n\n .. note:: This is expensive and should only be done on startup.","commit_id":"3263c8915f740ac3f311e743ddac63151055114e"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"2277fceb9be589ebbcea73aa254c7576c3587dae","unresolved":false,"context_lines":[{"line_number":434,"context_line":""},{"line_number":435,"context_line":"    def _get_assigned_resources(self, context):"},{"line_number":436,"context_line":"        \"\"\"Return organized assigned resources with resource class and"},{"line_number":437,"context_line":"        reource provider uuid."},{"line_number":438,"context_line":""},{"line_number":439,"context_line":"        :returns: {"},{"line_number":440,"context_line":"            $RP_UUID: {"}],"source_content_type":"text/x-python","patch_set":10,"id":"7faddb67_b0b0ff8c","line":437,"in_reply_to":"7faddb67_a7d9b2f4","updated":"2019-09-02 07:10:33.000000000","message":"Consider the comment Alex gave at line@1157, this _populate_assigned_resources will be periodic.","commit_id":"3263c8915f740ac3f311e743ddac63151055114e"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"3d7eb310beac331848500982bb51dbd15256160b","unresolved":false,"context_lines":[{"line_number":459,"context_line":"        for inst in instances:"},{"line_number":460,"context_line":"            resources.extend(inst.resources or [])"},{"line_number":461,"context_line":""},{"line_number":462,"context_line":"        for resource in resources:"},{"line_number":463,"context_line":"            rp_uuid \u003d resource.rp_uuid"},{"line_number":464,"context_line":"            rc \u003d resource.resource_class"},{"line_number":465,"context_line":"            self.assigned_resources[rp_uuid][rc].add(resource)"},{"line_number":466,"context_line":""},{"line_number":467,"context_line":"        return self.assigned_resources"},{"line_number":468,"context_line":""}],"source_content_type":"text/x-python","patch_set":10,"id":"7faddb67_678dfad2","line":465,"range":{"start_line":462,"start_character":8,"end_line":465,"end_character":62},"updated":"2019-08-30 18:01:28.000000000","message":"Yeah, you could pull this out into a little helper and reuse it for the \u0027merge\u0027 step at the end of _claim_resources as noted on L425.","commit_id":"3263c8915f740ac3f311e743ddac63151055114e"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"2277fceb9be589ebbcea73aa254c7576c3587dae","unresolved":false,"context_lines":[{"line_number":459,"context_line":"        for inst in instances:"},{"line_number":460,"context_line":"            resources.extend(inst.resources or [])"},{"line_number":461,"context_line":""},{"line_number":462,"context_line":"        for resource in resources:"},{"line_number":463,"context_line":"            rp_uuid \u003d resource.rp_uuid"},{"line_number":464,"context_line":"            rc \u003d resource.resource_class"},{"line_number":465,"context_line":"            self.assigned_resources[rp_uuid][rc].add(resource)"},{"line_number":466,"context_line":""},{"line_number":467,"context_line":"        return self.assigned_resources"},{"line_number":468,"context_line":""}],"source_content_type":"text/x-python","patch_set":10,"id":"7faddb67_30bdef67","line":465,"range":{"start_line":462,"start_character":8,"end_line":465,"end_character":62},"in_reply_to":"7faddb67_678dfad2","updated":"2019-09-02 07:10:33.000000000","message":"Done","commit_id":"3263c8915f740ac3f311e743ddac63151055114e"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"3d7eb310beac331848500982bb51dbd15256160b","unresolved":false,"context_lines":[{"line_number":468,"context_line":""},{"line_number":469,"context_line":"    def _check_resources(self, context):"},{"line_number":470,"context_line":"        \"\"\"Check if there are assigned resources not found in provider tree\"\"\""},{"line_number":471,"context_line":"        assigned_resources \u003d self._get_assigned_resources(context)"},{"line_number":472,"context_line":"        for rp_uuid in assigned_resources:"},{"line_number":473,"context_line":"            provider_data \u003d self.prov_tree.data(rp_uuid)"},{"line_number":474,"context_line":"            for rc, assigned in assigned_resources[rp_uuid].items():"}],"source_content_type":"text/x-python","patch_set":10,"id":"7faddb67_a75e9242","line":471,"range":{"start_line":471,"start_character":8,"end_line":471,"end_character":66},"updated":"2019-08-30 18:01:28.000000000","message":"I think this should not be done within this method. It should instead assume self.assigned_resources is already populated and just use that.","commit_id":"3263c8915f740ac3f311e743ddac63151055114e"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"2277fceb9be589ebbcea73aa254c7576c3587dae","unresolved":false,"context_lines":[{"line_number":468,"context_line":""},{"line_number":469,"context_line":"    def _check_resources(self, context):"},{"line_number":470,"context_line":"        \"\"\"Check if there are assigned resources not found in provider tree\"\"\""},{"line_number":471,"context_line":"        assigned_resources \u003d self._get_assigned_resources(context)"},{"line_number":472,"context_line":"        for rp_uuid in assigned_resources:"},{"line_number":473,"context_line":"            provider_data \u003d self.prov_tree.data(rp_uuid)"},{"line_number":474,"context_line":"            for rc, assigned in assigned_resources[rp_uuid].items():"}],"source_content_type":"text/x-python","patch_set":10,"id":"7faddb67_d0ad7b31","line":471,"range":{"start_line":471,"start_character":8,"end_line":471,"end_character":66},"in_reply_to":"7faddb67_a75e9242","updated":"2019-09-02 07:10:33.000000000","message":"Done","commit_id":"3263c8915f740ac3f311e743ddac63151055114e"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"3d7eb310beac331848500982bb51dbd15256160b","unresolved":false,"context_lines":[{"line_number":472,"context_line":"        for rp_uuid in assigned_resources:"},{"line_number":473,"context_line":"            provider_data \u003d self.prov_tree.data(rp_uuid)"},{"line_number":474,"context_line":"            for rc, assigned in assigned_resources[rp_uuid].items():"},{"line_number":475,"context_line":"                all_resources \u003d provider_data.resources[rc]"},{"line_number":476,"context_line":"                notfound \u003d assigned - all_resources"},{"line_number":477,"context_line":"                if notfound:"},{"line_number":478,"context_line":"                    raise exception.AssignedResourceNotFound("}],"source_content_type":"text/x-python","patch_set":10,"id":"7faddb67_a70c5242","line":475,"range":{"start_line":475,"start_character":32,"end_line":475,"end_character":59},"updated":"2019-08-30 18:01:28.000000000","message":"This is assuming the provider tree will have resources[rc] for anything in assigned_resources. Since we\u0027re specifically checking whether that\u0027s *not* the case, this should probably be provider_data.resources.get(rc, set()) instead.","commit_id":"3263c8915f740ac3f311e743ddac63151055114e"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"3d7eb310beac331848500982bb51dbd15256160b","unresolved":false,"context_lines":[{"line_number":472,"context_line":"        for rp_uuid in assigned_resources:"},{"line_number":473,"context_line":"            provider_data \u003d self.prov_tree.data(rp_uuid)"},{"line_number":474,"context_line":"            for rc, assigned in assigned_resources[rp_uuid].items():"},{"line_number":475,"context_line":"                all_resources \u003d provider_data.resources[rc]"},{"line_number":476,"context_line":"                notfound \u003d assigned - all_resources"},{"line_number":477,"context_line":"                if notfound:"},{"line_number":478,"context_line":"                    raise exception.AssignedResourceNotFound("}],"source_content_type":"text/x-python","patch_set":10,"id":"7faddb67_27194287","line":475,"range":{"start_line":475,"start_character":16,"end_line":475,"end_character":29},"updated":"2019-08-30 18:01:28.000000000","message":"no real need for this variable","commit_id":"3263c8915f740ac3f311e743ddac63151055114e"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"2277fceb9be589ebbcea73aa254c7576c3587dae","unresolved":false,"context_lines":[{"line_number":472,"context_line":"        for rp_uuid in assigned_resources:"},{"line_number":473,"context_line":"            provider_data \u003d self.prov_tree.data(rp_uuid)"},{"line_number":474,"context_line":"            for rc, assigned in assigned_resources[rp_uuid].items():"},{"line_number":475,"context_line":"                all_resources \u003d provider_data.resources[rc]"},{"line_number":476,"context_line":"                notfound \u003d assigned - all_resources"},{"line_number":477,"context_line":"                if notfound:"},{"line_number":478,"context_line":"                    raise exception.AssignedResourceNotFound("}],"source_content_type":"text/x-python","patch_set":10,"id":"7faddb67_906f035f","line":475,"range":{"start_line":475,"start_character":16,"end_line":475,"end_character":29},"in_reply_to":"7faddb67_27194287","updated":"2019-09-02 07:10:33.000000000","message":"Done","commit_id":"3263c8915f740ac3f311e743ddac63151055114e"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"2277fceb9be589ebbcea73aa254c7576c3587dae","unresolved":false,"context_lines":[{"line_number":472,"context_line":"        for rp_uuid in assigned_resources:"},{"line_number":473,"context_line":"            provider_data \u003d self.prov_tree.data(rp_uuid)"},{"line_number":474,"context_line":"            for rc, assigned in assigned_resources[rp_uuid].items():"},{"line_number":475,"context_line":"                all_resources \u003d provider_data.resources[rc]"},{"line_number":476,"context_line":"                notfound \u003d assigned - all_resources"},{"line_number":477,"context_line":"                if notfound:"},{"line_number":478,"context_line":"                    raise exception.AssignedResourceNotFound("}],"source_content_type":"text/x-python","patch_set":10,"id":"7faddb67_70a60757","line":475,"range":{"start_line":475,"start_character":32,"end_line":475,"end_character":59},"in_reply_to":"7faddb67_a70c5242","updated":"2019-09-02 07:10:33.000000000","message":"provider_data.resources is collections.defaultdict(set).","commit_id":"3263c8915f740ac3f311e743ddac63151055114e"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"3d7eb310beac331848500982bb51dbd15256160b","unresolved":false,"context_lines":[{"line_number":475,"context_line":"                all_resources \u003d provider_data.resources[rc]"},{"line_number":476,"context_line":"                notfound \u003d assigned - all_resources"},{"line_number":477,"context_line":"                if notfound:"},{"line_number":478,"context_line":"                    raise exception.AssignedResourceNotFound("},{"line_number":479,"context_line":"                        resources\u003d[res.identifier for res in notfound])"},{"line_number":480,"context_line":""},{"line_number":481,"context_line":"    def _unclaim_resources(self, resources):"}],"source_content_type":"text/x-python","patch_set":10,"id":"7faddb67_ea1c5167","line":478,"range":{"start_line":478,"start_character":36,"end_line":478,"end_character":61},"updated":"2019-08-30 18:01:28.000000000","message":"I don\u0027t think we can fail compute startup for this. What would the admin/operator be able to do to recover? We should definitely log an error/warning. And I guess it would make sense to take the bogus assignment out of the cache so we don\u0027t keep logging the same message? But beyond that, I\u0027m not sure if there\u0027s anything sensible to be done about it.","commit_id":"3263c8915f740ac3f311e743ddac63151055114e"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"3d7eb310beac331848500982bb51dbd15256160b","unresolved":false,"context_lines":[{"line_number":486,"context_line":"            rc \u003d resource.resource_class"},{"line_number":487,"context_line":"            try:"},{"line_number":488,"context_line":"                # TODO(Luyao)"},{"line_number":489,"context_line":"                # We probably need a driver interface to cleanup resource"},{"line_number":490,"context_line":"                # when unclaiming the resource."},{"line_number":491,"context_line":"                self.assigned_resources[rp_uuid][rc].remove(resource)"},{"line_number":492,"context_line":"            except KeyError:"}],"source_content_type":"text/x-python","patch_set":10,"id":"7faddb67_6a45c143","line":489,"range":{"start_line":489,"start_character":37,"end_line":489,"end_character":64},"updated":"2019-08-30 18:01:28.000000000","message":"I would think the driver ought to be able to do that for itself, right?\n\n...except I suppose in those corner cases where the driver has lost the XML and/or whatever is necessary to know which local resources they are.\n\nSo yeah, you\u0027re probably right. I guess even right now, for vpmem, we should have that in place to make sure it gets cleared.","commit_id":"3263c8915f740ac3f311e743ddac63151055114e"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"3d7eb310beac331848500982bb51dbd15256160b","unresolved":false,"context_lines":[{"line_number":575,"context_line":"                \u0027numa_topology\u0027, instance, prefix\u003dprefix)"},{"line_number":576,"context_line":"            resources \u003d self._get_migration_context_resource("},{"line_number":577,"context_line":"                \u0027resources\u0027, instance, prefix\u003dprefix)"},{"line_number":578,"context_line":"            self._unclaim_resources(resources)"},{"line_number":579,"context_line":"            usage \u003d self._get_usage_dict("},{"line_number":580,"context_line":"                    instance_type, instance, numa_topology\u003dnuma_topology)"},{"line_number":581,"context_line":"            self._drop_pci_devices(instance, nodename, prefix)"}],"source_content_type":"text/x-python","patch_set":10,"id":"7faddb67_aa6899b9","line":578,"updated":"2019-08-30 18:01:28.000000000","message":"The ordering here is a little weird. Keep the NUMA stuff together.","commit_id":"3263c8915f740ac3f311e743ddac63151055114e"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"2277fceb9be589ebbcea73aa254c7576c3587dae","unresolved":false,"context_lines":[{"line_number":575,"context_line":"                \u0027numa_topology\u0027, instance, prefix\u003dprefix)"},{"line_number":576,"context_line":"            resources \u003d self._get_migration_context_resource("},{"line_number":577,"context_line":"                \u0027resources\u0027, instance, prefix\u003dprefix)"},{"line_number":578,"context_line":"            self._unclaim_resources(resources)"},{"line_number":579,"context_line":"            usage \u003d self._get_usage_dict("},{"line_number":580,"context_line":"                    instance_type, instance, numa_topology\u003dnuma_topology)"},{"line_number":581,"context_line":"            self._drop_pci_devices(instance, nodename, prefix)"}],"source_content_type":"text/x-python","patch_set":10,"id":"7faddb67_3062cf17","line":578,"in_reply_to":"7faddb67_aa6899b9","updated":"2019-09-02 07:10:33.000000000","message":"Done","commit_id":"3263c8915f740ac3f311e743ddac63151055114e"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"3d7eb310beac331848500982bb51dbd15256160b","unresolved":false,"context_lines":[{"line_number":1093,"context_line":"        # provider corresponding to the compute node."},{"line_number":1094,"context_line":"        prov_tree \u003d self.reportclient.get_provider_tree_and_ensure_root("},{"line_number":1095,"context_line":"            context, compute_node.uuid, name\u003dcompute_node.hypervisor_hostname)"},{"line_number":1096,"context_line":"        self.prov_tree \u003d prov_tree"},{"line_number":1097,"context_line":"        # Let the virt driver rearrange the provider tree and set/update"},{"line_number":1098,"context_line":"        # the inventory, traits, and aggregates throughout."},{"line_number":1099,"context_line":"        allocs \u003d None"}],"source_content_type":"text/x-python","patch_set":10,"id":"7faddb67_4ad6c551","line":1096,"range":{"start_line":1096,"start_character":8,"end_line":1096,"end_character":34},"updated":"2019-08-30 18:01:28.000000000","message":"Sorry, please move this back to the bottom -- see PS7 comment.","commit_id":"3263c8915f740ac3f311e743ddac63151055114e"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"3d7eb310beac331848500982bb51dbd15256160b","unresolved":false,"context_lines":[{"line_number":1153,"context_line":"            prov_tree.update_inventory(nodename, inv_data)"},{"line_number":1154,"context_line":""},{"line_number":1155,"context_line":"        # Check if there is any resource assigned but not found"},{"line_number":1156,"context_line":"        # in provider tree, and populate self.assigned_resources"},{"line_number":1157,"context_line":"        if startup:"},{"line_number":1158,"context_line":"            self._check_resources(context)"},{"line_number":1159,"context_line":""}],"source_content_type":"text/x-python","patch_set":10,"id":"7faddb67_8ab03d42","line":1156,"range":{"start_line":1156,"start_character":32,"end_line":1156,"end_character":64},"updated":"2019-08-30 18:01:28.000000000","message":"Unless there\u0027s some reason we need to wait until update() to populate self.assigned_resources, I think we should do it right away in __init__.\n\n(I understand why we have to wait until here to do the actual `check` part of _check_resources - we need to make sure the provider tree is up to date.)","commit_id":"3263c8915f740ac3f311e743ddac63151055114e"},{"author":{"_account_id":5754,"name":"Alex Xu","email":"hejie.xu@intel.com","username":"xuhj"},"change_message_id":"4409db775e967ce30125f44edc0e84cf567e7515","unresolved":false,"context_lines":[{"line_number":1154,"context_line":""},{"line_number":1155,"context_line":"        # Check if there is any resource assigned but not found"},{"line_number":1156,"context_line":"        # in provider tree, and populate self.assigned_resources"},{"line_number":1157,"context_line":"        if startup:"},{"line_number":1158,"context_line":"            self._check_resources(context)"},{"line_number":1159,"context_line":""},{"line_number":1160,"context_line":"        # Flush any changes. If we processed ReshapeNeeded above, allocs is not"}],"source_content_type":"text/x-python","patch_set":10,"id":"7faddb67_5abc4cba","line":1157,"range":{"start_line":1157,"start_character":8,"end_line":1157,"end_character":19},"updated":"2019-09-01 13:35:37.000000000","message":"so you aren\u0027t going to auto heal this assigned resources list in each time the running of update_available_resources?\n\nI would say no, since there are many case depend on the update_available_resources to correct. For incomplete migration and orphaned instance will be cleanup by the periodic task in the ComputeManager, then we RT.update_available_resource will be able to release the claim. WIthout update assigend_resource in update_available_resource eachtime, there will be have some claim never be released except a restart of nova-compute.","commit_id":"3263c8915f740ac3f311e743ddac63151055114e"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"2277fceb9be589ebbcea73aa254c7576c3587dae","unresolved":false,"context_lines":[{"line_number":1154,"context_line":""},{"line_number":1155,"context_line":"        # Check if there is any resource assigned but not found"},{"line_number":1156,"context_line":"        # in provider tree, and populate self.assigned_resources"},{"line_number":1157,"context_line":"        if startup:"},{"line_number":1158,"context_line":"            self._check_resources(context)"},{"line_number":1159,"context_line":""},{"line_number":1160,"context_line":"        # Flush any changes. If we processed ReshapeNeeded above, allocs is not"}],"source_content_type":"text/x-python","patch_set":10,"id":"7faddb67_30308f07","line":1157,"range":{"start_line":1157,"start_character":8,"end_line":1157,"end_character":19},"in_reply_to":"7faddb67_5abc4cba","updated":"2019-09-02 07:10:33.000000000","message":"Yes, agree. _populate_assigned_resources will be periodic, and check_resources will be called when startup.","commit_id":"3263c8915f740ac3f311e743ddac63151055114e"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"3d7eb310beac331848500982bb51dbd15256160b","unresolved":false,"context_lines":[{"line_number":1154,"context_line":""},{"line_number":1155,"context_line":"        # Check if there is any resource assigned but not found"},{"line_number":1156,"context_line":"        # in provider tree, and populate self.assigned_resources"},{"line_number":1157,"context_line":"        if startup:"},{"line_number":1158,"context_line":"            self._check_resources(context)"},{"line_number":1159,"context_line":""},{"line_number":1160,"context_line":"        # Flush any changes. If we processed ReshapeNeeded above, allocs is not"},{"line_number":1161,"context_line":"        # None, and this will hit placement\u0027s POST /reshaper route."}],"source_content_type":"text/x-python","patch_set":10,"id":"7faddb67_4a3245a9","line":1158,"range":{"start_line":1157,"start_character":0,"end_line":1158,"end_character":42},"updated":"2019-08-30 18:01:28.000000000","message":"This isn\u0027t really related to the theme of \"update to placement\", so it should probably be moved up the stack at least one level to _update() (like to L1186).","commit_id":"3263c8915f740ac3f311e743ddac63151055114e"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"2277fceb9be589ebbcea73aa254c7576c3587dae","unresolved":false,"context_lines":[{"line_number":1154,"context_line":""},{"line_number":1155,"context_line":"        # Check if there is any resource assigned but not found"},{"line_number":1156,"context_line":"        # in provider tree, and populate self.assigned_resources"},{"line_number":1157,"context_line":"        if startup:"},{"line_number":1158,"context_line":"            self._check_resources(context)"},{"line_number":1159,"context_line":""},{"line_number":1160,"context_line":"        # Flush any changes. If we processed ReshapeNeeded above, allocs is not"},{"line_number":1161,"context_line":"        # None, and this will hit placement\u0027s POST /reshaper route."}],"source_content_type":"text/x-python","patch_set":10,"id":"7faddb67_90514333","line":1158,"range":{"start_line":1157,"start_character":0,"end_line":1158,"end_character":42},"in_reply_to":"7faddb67_4a3245a9","updated":"2019-09-02 07:10:33.000000000","message":"Done","commit_id":"3263c8915f740ac3f311e743ddac63151055114e"},{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"fb5ff9386dd79ef0b09c071ab39e30305232368d","unresolved":false,"context_lines":[{"line_number":151,"context_line":"        self.ram_allocation_ratio \u003d CONF.ram_allocation_ratio"},{"line_number":152,"context_line":"        self.cpu_allocation_ratio \u003d CONF.cpu_allocation_ratio"},{"line_number":153,"context_line":"        self.disk_allocation_ratio \u003d CONF.disk_allocation_ratio"},{"line_number":154,"context_line":"        self.prov_tree \u003d None"},{"line_number":155,"context_line":"        # Dict of assigned_resources, keyed by resource provider uuid"},{"line_number":156,"context_line":"        # the value is a dict again, keyed by resource class"},{"line_number":157,"context_line":"        # and value of this sub-dict is a set of Resource obj"}],"source_content_type":"text/x-python","patch_set":13,"id":"7faddb67_5dc18d7f","line":154,"range":{"start_line":154,"start_character":13,"end_line":154,"end_character":22},"updated":"2019-09-03 16:32:07.000000000","message":"provider_tree","commit_id":"6650f2ee650f904d60edb15505eea7edb766a92b"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"5b3462c65a7e0df8e58e4bf1dea84ce9a592143a","unresolved":false,"context_lines":[{"line_number":151,"context_line":"        self.ram_allocation_ratio \u003d CONF.ram_allocation_ratio"},{"line_number":152,"context_line":"        self.cpu_allocation_ratio \u003d CONF.cpu_allocation_ratio"},{"line_number":153,"context_line":"        self.disk_allocation_ratio \u003d CONF.disk_allocation_ratio"},{"line_number":154,"context_line":"        self.prov_tree \u003d None"},{"line_number":155,"context_line":"        # Dict of assigned_resources, keyed by resource provider uuid"},{"line_number":156,"context_line":"        # the value is a dict again, keyed by resource class"},{"line_number":157,"context_line":"        # and value of this sub-dict is a set of Resource obj"}],"source_content_type":"text/x-python","patch_set":13,"id":"7faddb67_1298d466","line":154,"range":{"start_line":154,"start_character":13,"end_line":154,"end_character":22},"in_reply_to":"7faddb67_5dc18d7f","updated":"2019-09-04 12:53:01.000000000","message":"Done","commit_id":"6650f2ee650f904d60edb15505eea7edb766a92b"},{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"fb5ff9386dd79ef0b09c071ab39e30305232368d","unresolved":false,"context_lines":[{"line_number":428,"context_line":"        if claimed_resources:"},{"line_number":429,"context_line":"            self._add_assigned_resources(claimed_resources)"},{"line_number":430,"context_line":"            return objects.ResourceList(objects\u003dclaimed_resources)"},{"line_number":431,"context_line":"        return None"},{"line_number":432,"context_line":""},{"line_number":433,"context_line":"    def _populate_assigned_resources(self, context):"},{"line_number":434,"context_line":"        \"\"\"Populate self.assigned_resources organized by resource class and"}],"source_content_type":"text/x-python","patch_set":13,"id":"7faddb67_dd3a5d96","line":431,"range":{"start_line":431,"start_character":0,"end_line":431,"end_character":19},"updated":"2019-09-03 16:32:07.000000000","message":"nit: you don\u0027t really need this (it\u0027ll happen automatically)","commit_id":"6650f2ee650f904d60edb15505eea7edb766a92b"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"5b3462c65a7e0df8e58e4bf1dea84ce9a592143a","unresolved":false,"context_lines":[{"line_number":428,"context_line":"        if claimed_resources:"},{"line_number":429,"context_line":"            self._add_assigned_resources(claimed_resources)"},{"line_number":430,"context_line":"            return objects.ResourceList(objects\u003dclaimed_resources)"},{"line_number":431,"context_line":"        return None"},{"line_number":432,"context_line":""},{"line_number":433,"context_line":"    def _populate_assigned_resources(self, context):"},{"line_number":434,"context_line":"        \"\"\"Populate self.assigned_resources organized by resource class and"}],"source_content_type":"text/x-python","patch_set":13,"id":"7faddb67_32bcf0da","line":431,"range":{"start_line":431,"start_character":0,"end_line":431,"end_character":19},"in_reply_to":"7faddb67_dd3a5d96","updated":"2019-09-04 12:53:01.000000000","message":"Done","commit_id":"6650f2ee650f904d60edb15505eea7edb766a92b"},{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"fb5ff9386dd79ef0b09c071ab39e30305232368d","unresolved":false,"context_lines":[{"line_number":465,"context_line":"        for rp_uuid in self.assigned_resources:"},{"line_number":466,"context_line":"            provider_data \u003d self.prov_tree.data(rp_uuid)"},{"line_number":467,"context_line":"            for rc, assigned in self.assigned_resources[rp_uuid].items():"},{"line_number":468,"context_line":"                notfound +\u003d (assigned - provider_data.resources[rc])"},{"line_number":469,"context_line":""},{"line_number":470,"context_line":"        if not notfound:"},{"line_number":471,"context_line":"            return"}],"source_content_type":"text/x-python","patch_set":13,"id":"7faddb67_ddbfbdcd","line":468,"range":{"start_line":468,"start_character":25,"end_line":468,"end_character":27},"updated":"2019-09-03 16:32:07.000000000","message":"You can\u0027t do this with sets. How is this working? Is it working?","commit_id":"6650f2ee650f904d60edb15505eea7edb766a92b"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"5b3462c65a7e0df8e58e4bf1dea84ce9a592143a","unresolved":false,"context_lines":[{"line_number":465,"context_line":"        for rp_uuid in self.assigned_resources:"},{"line_number":466,"context_line":"            provider_data \u003d self.prov_tree.data(rp_uuid)"},{"line_number":467,"context_line":"            for rc, assigned in self.assigned_resources[rp_uuid].items():"},{"line_number":468,"context_line":"                notfound +\u003d (assigned - provider_data.resources[rc])"},{"line_number":469,"context_line":""},{"line_number":470,"context_line":"        if not notfound:"},{"line_number":471,"context_line":"            return"}],"source_content_type":"text/x-python","patch_set":13,"id":"7faddb67_7273484f","line":468,"range":{"start_line":468,"start_character":25,"end_line":468,"end_character":27},"in_reply_to":"7faddb67_ddbfbdcd","updated":"2019-09-04 12:53:01.000000000","message":"sorry, it should be \u0027|+\u0027","commit_id":"6650f2ee650f904d60edb15505eea7edb766a92b"},{"author":{"_account_id":5754,"name":"Alex Xu","email":"hejie.xu@intel.com","username":"xuhj"},"change_message_id":"dfad8680125afc1d6d78d33c0f1583302bb7315b","unresolved":false,"context_lines":[{"line_number":390,"context_line":"        migration.status \u003d \u0027pre-migrating\u0027"},{"line_number":391,"context_line":"        migration.save()"},{"line_number":392,"context_line":""},{"line_number":393,"context_line":"    def _claim_resources(self, allocations):"},{"line_number":394,"context_line":"        \"\"\"Claim resources according to assigned resources from allocations"},{"line_number":395,"context_line":"        and available resources in provider tree"},{"line_number":396,"context_line":"        \"\"\""}],"source_content_type":"text/x-python","patch_set":17,"id":"7faddb67_a73647e6","line":393,"updated":"2019-09-05 05:50:13.000000000","message":"do you have unittest for this? The unittest you have is only about startup population?","commit_id":"cdc5f556173cdb1fe738af7e95569bbf31a117b6"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"85b2f588efdde35be606af490ec56d4988d19db9","unresolved":false,"context_lines":[{"line_number":390,"context_line":"        migration.status \u003d \u0027pre-migrating\u0027"},{"line_number":391,"context_line":"        migration.save()"},{"line_number":392,"context_line":""},{"line_number":393,"context_line":"    def _claim_resources(self, allocations):"},{"line_number":394,"context_line":"        \"\"\"Claim resources according to assigned resources from allocations"},{"line_number":395,"context_line":"        and available resources in provider tree"},{"line_number":396,"context_line":"        \"\"\""}],"source_content_type":"text/x-python","patch_set":17,"id":"7faddb67_bdd89a51","line":393,"in_reply_to":"7faddb67_a73647e6","updated":"2019-09-05 10:33:43.000000000","message":"yes I have.\nseveral tests from https://review.opendev.org/#/c/678452/17/nova/tests/unit/compute/test_resource_tracker.py@2277","commit_id":"cdc5f556173cdb1fe738af7e95569bbf31a117b6"},{"author":{"_account_id":5754,"name":"Alex Xu","email":"hejie.xu@intel.com","username":"xuhj"},"change_message_id":"519b8ce55a5e435b1cdbae91a80cb215ba1ad9ed","unresolved":false,"context_lines":[{"line_number":390,"context_line":"        migration.status \u003d \u0027pre-migrating\u0027"},{"line_number":391,"context_line":"        migration.save()"},{"line_number":392,"context_line":""},{"line_number":393,"context_line":"    def _claim_resources(self, allocations):"},{"line_number":394,"context_line":"        \"\"\"Claim resources according to assigned resources from allocations"},{"line_number":395,"context_line":"        and available resources in provider tree"},{"line_number":396,"context_line":"        \"\"\""}],"source_content_type":"text/x-python","patch_set":17,"id":"7faddb67_a8cff325","line":393,"in_reply_to":"7faddb67_bdd89a51","updated":"2019-09-05 13:09:00.000000000","message":"Sorry, I must blind","commit_id":"cdc5f556173cdb1fe738af7e95569bbf31a117b6"},{"author":{"_account_id":5754,"name":"Alex Xu","email":"hejie.xu@intel.com","username":"xuhj"},"change_message_id":"84efe652129c93cbf08b16dcfffb5d01fb9fbde5","unresolved":false,"context_lines":[{"line_number":414,"context_line":"                    # assign this kind of resource class, such as \u0027VCPU\u0027 for"},{"line_number":415,"context_line":"                    # now, otherwise the provider_data.resources will be"},{"line_number":416,"context_line":"                    # populated with this resource class when updating"},{"line_number":417,"context_line":"                    # provider tree."},{"line_number":418,"context_line":"                    continue"},{"line_number":419,"context_line":"                assigned \u003d self.assigned_resources[rp_uuid][rc]"},{"line_number":420,"context_line":"                free \u003d provider_data.resources[rc] - assigned"}],"source_content_type":"text/x-python","patch_set":17,"id":"7faddb67_4c1d3abc","line":417,"updated":"2019-09-05 05:41:01.000000000","message":"nice comment :)","commit_id":"cdc5f556173cdb1fe738af7e95569bbf31a117b6"},{"author":{"_account_id":5754,"name":"Alex Xu","email":"hejie.xu@intel.com","username":"xuhj"},"change_message_id":"84efe652129c93cbf08b16dcfffb5d01fb9fbde5","unresolved":false,"context_lines":[{"line_number":484,"context_line":"            rp_uuid \u003d resource.provider_uuid"},{"line_number":485,"context_line":"            rc \u003d resource.resource_class"},{"line_number":486,"context_line":"            try:"},{"line_number":487,"context_line":"                # TODO(Luyao)"},{"line_number":488,"context_line":"                # We probably need a driver interface to cleanup resource"},{"line_number":489,"context_line":"                # when unclaiming the resource."},{"line_number":490,"context_line":"                self.assigned_resources[rp_uuid][rc].remove(resource)"},{"line_number":491,"context_line":"            except KeyError:"},{"line_number":492,"context_line":"                continue"}],"source_content_type":"text/x-python","patch_set":17,"id":"7faddb67_ac506e5f","line":489,"range":{"start_line":487,"start_character":16,"end_line":489,"end_character":47},"updated":"2019-09-05 05:41:01.000000000","message":"no, we needn\u0027t. We won\u0027t release the assigned resource before we do the cleanup.","commit_id":"cdc5f556173cdb1fe738af7e95569bbf31a117b6"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"85b2f588efdde35be606af490ec56d4988d19db9","unresolved":false,"context_lines":[{"line_number":484,"context_line":"            rp_uuid \u003d resource.provider_uuid"},{"line_number":485,"context_line":"            rc \u003d resource.resource_class"},{"line_number":486,"context_line":"            try:"},{"line_number":487,"context_line":"                # TODO(Luyao)"},{"line_number":488,"context_line":"                # We probably need a driver interface to cleanup resource"},{"line_number":489,"context_line":"                # when unclaiming the resource."},{"line_number":490,"context_line":"                self.assigned_resources[rp_uuid][rc].remove(resource)"},{"line_number":491,"context_line":"            except KeyError:"},{"line_number":492,"context_line":"                continue"}],"source_content_type":"text/x-python","patch_set":17,"id":"7faddb67_9dd7de4f","line":489,"range":{"start_line":487,"start_character":16,"end_line":489,"end_character":47},"in_reply_to":"7faddb67_ac506e5f","updated":"2019-09-05 10:33:43.000000000","message":"Done","commit_id":"cdc5f556173cdb1fe738af7e95569bbf31a117b6"},{"author":{"_account_id":5754,"name":"Alex Xu","email":"hejie.xu@intel.com","username":"xuhj"},"change_message_id":"84efe652129c93cbf08b16dcfffb5d01fb9fbde5","unresolved":false,"context_lines":[{"line_number":489,"context_line":"                # when unclaiming the resource."},{"line_number":490,"context_line":"                self.assigned_resources[rp_uuid][rc].remove(resource)"},{"line_number":491,"context_line":"            except KeyError:"},{"line_number":492,"context_line":"                continue"},{"line_number":493,"context_line":""},{"line_number":494,"context_line":"    def _add_assigned_resources(self, resources):"},{"line_number":495,"context_line":"        \"\"\"Add resources to self.assigned_resources\"\"\""}],"source_content_type":"text/x-python","patch_set":17,"id":"7faddb67_4cf9ba4b","line":492,"updated":"2019-09-05 05:41:01.000000000","message":"we should send a warnning log at here?","commit_id":"cdc5f556173cdb1fe738af7e95569bbf31a117b6"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"85b2f588efdde35be606af490ec56d4988d19db9","unresolved":false,"context_lines":[{"line_number":489,"context_line":"                # when unclaiming the resource."},{"line_number":490,"context_line":"                self.assigned_resources[rp_uuid][rc].remove(resource)"},{"line_number":491,"context_line":"            except KeyError:"},{"line_number":492,"context_line":"                continue"},{"line_number":493,"context_line":""},{"line_number":494,"context_line":"    def _add_assigned_resources(self, resources):"},{"line_number":495,"context_line":"        \"\"\"Add resources to self.assigned_resources\"\"\""}],"source_content_type":"text/x-python","patch_set":17,"id":"7faddb67_bd23ba57","line":492,"in_reply_to":"7faddb67_4cf9ba4b","updated":"2019-09-05 10:33:43.000000000","message":"Done","commit_id":"cdc5f556173cdb1fe738af7e95569bbf31a117b6"},{"author":{"_account_id":5754,"name":"Alex Xu","email":"hejie.xu@intel.com","username":"xuhj"},"change_message_id":"519b8ce55a5e435b1cdbae91a80cb215ba1ad9ed","unresolved":false,"context_lines":[{"line_number":586,"context_line":"            self._drop_pci_devices(instance, nodename, prefix)"},{"line_number":587,"context_line":"            resources \u003d self._get_migration_context_resource("},{"line_number":588,"context_line":"                \u0027resources\u0027, instance, prefix\u003dprefix)"},{"line_number":589,"context_line":"            self._release_assigned_resources(resources)"},{"line_number":590,"context_line":"            self._update_usage(usage, nodename, sign\u003d-1)"},{"line_number":591,"context_line":""},{"line_number":592,"context_line":"            ctxt \u003d context.elevated()"}],"source_content_type":"text/x-python","patch_set":18,"id":"7faddb67_ebc96524","line":589,"updated":"2019-09-05 13:09:00.000000000","message":"it will be great to have test for this.","commit_id":"eb1366773471f004d06c51487fd670e1364bf2e6"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"a61fae10168ece6683ee6c6c1f5c91d1f2402aa4","unresolved":false,"context_lines":[{"line_number":586,"context_line":"            self._drop_pci_devices(instance, nodename, prefix)"},{"line_number":587,"context_line":"            resources \u003d self._get_migration_context_resource("},{"line_number":588,"context_line":"                \u0027resources\u0027, instance, prefix\u003dprefix)"},{"line_number":589,"context_line":"            self._release_assigned_resources(resources)"},{"line_number":590,"context_line":"            self._update_usage(usage, nodename, sign\u003d-1)"},{"line_number":591,"context_line":""},{"line_number":592,"context_line":"            ctxt \u003d context.elevated()"}],"source_content_type":"text/x-python","patch_set":18,"id":"5faad753_7f350ff7","line":589,"in_reply_to":"7faddb67_ebc96524","updated":"2019-09-06 14:41:24.000000000","message":"Done","commit_id":"eb1366773471f004d06c51487fd670e1364bf2e6"},{"author":{"_account_id":5754,"name":"Alex Xu","email":"hejie.xu@intel.com","username":"xuhj"},"change_message_id":"519b8ce55a5e435b1cdbae91a80cb215ba1ad9ed","unresolved":false,"context_lines":[{"line_number":1412,"context_line":""},{"line_number":1413,"context_line":"        if is_removed_instance:"},{"line_number":1414,"context_line":"            self.tracked_instances.remove(uuid)"},{"line_number":1415,"context_line":"            self._release_assigned_resources(instance.resources)"},{"line_number":1416,"context_line":"            sign \u003d -1"},{"line_number":1417,"context_line":""},{"line_number":1418,"context_line":"        cn \u003d self.compute_nodes[nodename]"}],"source_content_type":"text/x-python","patch_set":18,"id":"7faddb67_6bd575b6","line":1415,"updated":"2019-09-05 13:09:00.000000000","message":"also a test for this.","commit_id":"eb1366773471f004d06c51487fd670e1364bf2e6"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"a61fae10168ece6683ee6c6c1f5c91d1f2402aa4","unresolved":false,"context_lines":[{"line_number":1412,"context_line":""},{"line_number":1413,"context_line":"        if is_removed_instance:"},{"line_number":1414,"context_line":"            self.tracked_instances.remove(uuid)"},{"line_number":1415,"context_line":"            self._release_assigned_resources(instance.resources)"},{"line_number":1416,"context_line":"            sign \u003d -1"},{"line_number":1417,"context_line":""},{"line_number":1418,"context_line":"        cn \u003d self.compute_nodes[nodename]"}],"source_content_type":"text/x-python","patch_set":18,"id":"5faad753_1f3adbe6","line":1415,"in_reply_to":"7faddb67_6bd575b6","updated":"2019-09-06 14:41:24.000000000","message":"Done","commit_id":"eb1366773471f004d06c51487fd670e1364bf2e6"},{"author":{"_account_id":5754,"name":"Alex Xu","email":"hejie.xu@intel.com","username":"xuhj"},"change_message_id":"519b8ce55a5e435b1cdbae91a80cb215ba1ad9ed","unresolved":false,"context_lines":[{"line_number":451,"context_line":"        # Get resources assigned to instances not in migrating"},{"line_number":452,"context_line":"        instances \u003d objects.InstanceList.get_by_filters("},{"line_number":453,"context_line":"            context, {\u0027uuid\u0027: self.tracked_instances, \u0027deleted\u0027: False},"},{"line_number":454,"context_line":"            expected_attrs\u003d[\u0027resources\u0027])"},{"line_number":455,"context_line":"        for inst in instances:"},{"line_number":456,"context_line":"            resources.extend(inst.resources or [])"},{"line_number":457,"context_line":""}],"source_content_type":"text/x-python","patch_set":19,"id":"7faddb67_ab9dad09","line":454,"updated":"2019-09-05 13:09:00.000000000","message":"the Line 888 has a dict instance_by_uuid, can we use it directly instead of query this db again?","commit_id":"5a3ccc43a203759ba3e958a8d4f0513cbb6bc544"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"be869b5aebee91a62c64dac03a9248bb34d2d5a5","unresolved":false,"context_lines":[{"line_number":451,"context_line":"        # Get resources assigned to instances not in migrating"},{"line_number":452,"context_line":"        instances \u003d objects.InstanceList.get_by_filters("},{"line_number":453,"context_line":"            context, {\u0027uuid\u0027: self.tracked_instances, \u0027deleted\u0027: False},"},{"line_number":454,"context_line":"            expected_attrs\u003d[\u0027resources\u0027])"},{"line_number":455,"context_line":"        for inst in instances:"},{"line_number":456,"context_line":"            resources.extend(inst.resources or [])"},{"line_number":457,"context_line":""}],"source_content_type":"text/x-python","patch_set":19,"id":"5faad753_be45a972","line":454,"in_reply_to":"5faad753_3f26b7b9","updated":"2019-09-09 05:45:59.000000000","message":"I see now, will use instance_by_uuid instead.","commit_id":"5a3ccc43a203759ba3e958a8d4f0513cbb6bc544"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"a61fae10168ece6683ee6c6c1f5c91d1f2402aa4","unresolved":false,"context_lines":[{"line_number":451,"context_line":"        # Get resources assigned to instances not in migrating"},{"line_number":452,"context_line":"        instances \u003d objects.InstanceList.get_by_filters("},{"line_number":453,"context_line":"            context, {\u0027uuid\u0027: self.tracked_instances, \u0027deleted\u0027: False},"},{"line_number":454,"context_line":"            expected_attrs\u003d[\u0027resources\u0027])"},{"line_number":455,"context_line":"        for inst in instances:"},{"line_number":456,"context_line":"            resources.extend(inst.resources or [])"},{"line_number":457,"context_line":""}],"source_content_type":"text/x-python","patch_set":19,"id":"5faad753_3f26b7b9","line":454,"in_reply_to":"7faddb67_ab9dad09","updated":"2019-09-06 14:41:24.000000000","message":"instance_by_uuid \u003e\u003d self.tracked_instances.\nbecause self.tracked_instances has limit of \u0027instance.vm_state not in vm_states.ALLOW_RESOURCE_REMOVAL\u0027.\nsee line 1466.","commit_id":"5a3ccc43a203759ba3e958a8d4f0513cbb6bc544"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"ce75bfa28271513f83bb97396cdb7943a712e845","unresolved":false,"context_lines":[{"line_number":223,"context_line":""},{"line_number":224,"context_line":"        claimed_resources \u003d self._claim_resources(allocations)"},{"line_number":225,"context_line":"        if claimed_resources:"},{"line_number":226,"context_line":"            instance.resources \u003d claimed_resources"},{"line_number":227,"context_line":""},{"line_number":228,"context_line":"        # Mark resources in-use and update stats"},{"line_number":229,"context_line":"        self._update_usage_from_instance(context, instance, nodename)"}],"source_content_type":"text/x-python","patch_set":22,"id":"5faad753_b947f01d","line":226,"range":{"start_line":226,"start_character":12,"end_line":226,"end_character":50},"updated":"2019-09-09 21:45:34.000000000","message":"here you\u0027re only setting Instance.resources if something was claimed...","commit_id":"34317d58cee9597773f2a54c0634784e7cfd3e01"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"399e0df6c952f87d4191add3ac05588523731e2d","unresolved":false,"context_lines":[{"line_number":223,"context_line":""},{"line_number":224,"context_line":"        claimed_resources \u003d self._claim_resources(allocations)"},{"line_number":225,"context_line":"        if claimed_resources:"},{"line_number":226,"context_line":"            instance.resources \u003d claimed_resources"},{"line_number":227,"context_line":""},{"line_number":228,"context_line":"        # Mark resources in-use and update stats"},{"line_number":229,"context_line":"        self._update_usage_from_instance(context, instance, nodename)"}],"source_content_type":"text/x-python","patch_set":22,"id":"5faad753_a5aedf2b","line":226,"range":{"start_line":226,"start_character":12,"end_line":226,"end_character":50},"in_reply_to":"5faad753_b947f01d","updated":"2019-09-10 06:16:47.000000000","message":"I\u0027ll set instance.resources even if we have nothing claimed. resources field is nullable, so it will be okey.","commit_id":"34317d58cee9597773f2a54c0634784e7cfd3e01"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"ce75bfa28271513f83bb97396cdb7943a712e845","unresolved":false,"context_lines":[{"line_number":337,"context_line":"            new_pci_devices\u003dclaimed_pci_devices,"},{"line_number":338,"context_line":"            old_pci_requests\u003dinstance.pci_requests,"},{"line_number":339,"context_line":"            new_pci_requests\u003dnew_pci_requests,"},{"line_number":340,"context_line":"            old_resources\u003dold_resources,"},{"line_number":341,"context_line":"            new_resources\u003dclaimed_resources)"},{"line_number":342,"context_line":""},{"line_number":343,"context_line":"        instance.migration_context \u003d mig_context"},{"line_number":344,"context_line":"        instance.save()"}],"source_content_type":"text/x-python","patch_set":22,"id":"5faad753_196084a5","line":341,"range":{"start_line":340,"start_character":0,"end_line":341,"end_character":44},"updated":"2019-09-09 21:45:34.000000000","message":"...but here you\u0027re setting it no matter what -- possibly to None.\n\nThese should be consistent, unless there\u0027s some reason to do it otherwise.\n\nThat said, since all of the fields are nullable, you kind of have to do this horrible dance anyway:\n\n if \u0027resources\u0027 in inst and inst.resources is not None:\n     # At this point inst.resources could still be [] :(\n     ...","commit_id":"34317d58cee9597773f2a54c0634784e7cfd3e01"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"399e0df6c952f87d4191add3ac05588523731e2d","unresolved":false,"context_lines":[{"line_number":337,"context_line":"            new_pci_devices\u003dclaimed_pci_devices,"},{"line_number":338,"context_line":"            old_pci_requests\u003dinstance.pci_requests,"},{"line_number":339,"context_line":"            new_pci_requests\u003dnew_pci_requests,"},{"line_number":340,"context_line":"            old_resources\u003dold_resources,"},{"line_number":341,"context_line":"            new_resources\u003dclaimed_resources)"},{"line_number":342,"context_line":""},{"line_number":343,"context_line":"        instance.migration_context \u003d mig_context"},{"line_number":344,"context_line":"        instance.save()"}],"source_content_type":"text/x-python","patch_set":22,"id":"5faad753_251f4f6d","line":341,"range":{"start_line":340,"start_character":0,"end_line":341,"end_character":44},"in_reply_to":"5faad753_196084a5","updated":"2019-09-10 06:16:47.000000000","message":"I will update the setting for instance.resources above to keep consistent with here.\nChecking if \u0027resources\u0027 is in inst may not work well, because it\u0027s a lazy_load field.\ninst.resources will not be [], see the process and return of _claim_resources method.","commit_id":"34317d58cee9597773f2a54c0634784e7cfd3e01"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"ce75bfa28271513f83bb97396cdb7943a712e845","unresolved":false,"context_lines":[{"line_number":400,"context_line":"        for rp_uuid, alloc_dict in allocations.items():"},{"line_number":401,"context_line":"            allocated_resources \u003d alloc_dict[\u0027resources\u0027]"},{"line_number":402,"context_line":"            try:"},{"line_number":403,"context_line":"                # TODO(Luyao)"},{"line_number":404,"context_line":"                # In many functional tests, provider tree doesn\u0027t have"},{"line_number":405,"context_line":"                # rp uuids in allocations, we believe this won\u0027t happen"},{"line_number":406,"context_line":"                # in real OpenStack enviroment. Still need look into"},{"line_number":407,"context_line":"                # functional tests, this is not as we expected."},{"line_number":408,"context_line":"                provider_data \u003d self.provider_tree.data(rp_uuid)"},{"line_number":409,"context_line":"            except ValueError:"},{"line_number":410,"context_line":"                continue"}],"source_content_type":"text/x-python","patch_set":22,"id":"5faad753_b97a9021","line":407,"range":{"start_line":403,"start_character":0,"end_line":407,"end_character":63},"updated":"2019-09-09 21:45:34.000000000","message":"I put up [1] so I could see these for myself. Hopefully we\u0027ll be able to fix them so this try/except can be removed before we merge this.\n\n[1] https://review.opendev.org/681122","commit_id":"34317d58cee9597773f2a54c0634784e7cfd3e01"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"ce75bfa28271513f83bb97396cdb7943a712e845","unresolved":false,"context_lines":[{"line_number":414,"context_line":"                    # assign this kind of resource class, such as \u0027VCPU\u0027 for"},{"line_number":415,"context_line":"                    # now, otherwise the provider_data.resources will be"},{"line_number":416,"context_line":"                    # populated with this resource class when updating"},{"line_number":417,"context_line":"                    # provider tree."},{"line_number":418,"context_line":"                    continue"},{"line_number":419,"context_line":"                assigned \u003d self.assigned_resources[rp_uuid][rc]"},{"line_number":420,"context_line":"                free \u003d provider_data.resources[rc] - assigned"}],"source_content_type":"text/x-python","patch_set":22,"id":"5faad753_b9693026","line":417,"updated":"2019-09-09 21:45:34.000000000","message":"A debug log here... would probably be excessively verbose ✔","commit_id":"34317d58cee9597773f2a54c0634784e7cfd3e01"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"399e0df6c952f87d4191add3ac05588523731e2d","unresolved":false,"context_lines":[{"line_number":414,"context_line":"                    # assign this kind of resource class, such as \u0027VCPU\u0027 for"},{"line_number":415,"context_line":"                    # now, otherwise the provider_data.resources will be"},{"line_number":416,"context_line":"                    # populated with this resource class when updating"},{"line_number":417,"context_line":"                    # provider tree."},{"line_number":418,"context_line":"                    continue"},{"line_number":419,"context_line":"                assigned \u003d self.assigned_resources[rp_uuid][rc]"},{"line_number":420,"context_line":"                free \u003d provider_data.resources[rc] - assigned"}],"source_content_type":"text/x-python","patch_set":22,"id":"5faad753_50700aa6","line":417,"in_reply_to":"5faad753_b9693026","updated":"2019-09-10 06:16:47.000000000","message":"Done","commit_id":"34317d58cee9597773f2a54c0634784e7cfd3e01"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"ce75bfa28271513f83bb97396cdb7943a712e845","unresolved":false,"context_lines":[{"line_number":419,"context_line":"                assigned \u003d self.assigned_resources[rp_uuid][rc]"},{"line_number":420,"context_line":"                free \u003d provider_data.resources[rc] - assigned"},{"line_number":421,"context_line":"                if amount \u003e len(free):"},{"line_number":422,"context_line":"                    reason \u003d _(\"Resource Class: %s\") % rc"},{"line_number":423,"context_line":"                    raise exception.ComputeResourcesUnavailable(reason\u003dreason)"},{"line_number":424,"context_line":"                for i in range(amount):"},{"line_number":425,"context_line":"                    resource \u003d free.pop()"}],"source_content_type":"text/x-python","patch_set":22,"id":"5faad753_b9c85055","line":422,"range":{"start_line":422,"start_character":31,"end_line":422,"end_character":51},"updated":"2019-09-09 21:45:34.000000000","message":"This would be more useful if it included `amount` and `len(free)`. E.g.\n\n \"Needed %d units of resource class %s, but %d are available\"","commit_id":"34317d58cee9597773f2a54c0634784e7cfd3e01"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"399e0df6c952f87d4191add3ac05588523731e2d","unresolved":false,"context_lines":[{"line_number":419,"context_line":"                assigned \u003d self.assigned_resources[rp_uuid][rc]"},{"line_number":420,"context_line":"                free \u003d provider_data.resources[rc] - assigned"},{"line_number":421,"context_line":"                if amount \u003e len(free):"},{"line_number":422,"context_line":"                    reason \u003d _(\"Resource Class: %s\") % rc"},{"line_number":423,"context_line":"                    raise exception.ComputeResourcesUnavailable(reason\u003dreason)"},{"line_number":424,"context_line":"                for i in range(amount):"},{"line_number":425,"context_line":"                    resource \u003d free.pop()"}],"source_content_type":"text/x-python","patch_set":22,"id":"5faad753_90844260","line":422,"range":{"start_line":422,"start_character":31,"end_line":422,"end_character":51},"in_reply_to":"5faad753_b9c85055","updated":"2019-09-10 06:16:47.000000000","message":"Done","commit_id":"34317d58cee9597773f2a54c0634784e7cfd3e01"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"ce75bfa28271513f83bb97396cdb7943a712e845","unresolved":false,"context_lines":[{"line_number":422,"context_line":"                    reason \u003d _(\"Resource Class: %s\") % rc"},{"line_number":423,"context_line":"                    raise exception.ComputeResourcesUnavailable(reason\u003dreason)"},{"line_number":424,"context_line":"                for i in range(amount):"},{"line_number":425,"context_line":"                    resource \u003d free.pop()"},{"line_number":426,"context_line":"                    claimed_resources.append(resource)"},{"line_number":427,"context_line":""},{"line_number":428,"context_line":"        if claimed_resources:"},{"line_number":429,"context_line":"            self._add_assigned_resources(claimed_resources)"}],"source_content_type":"text/x-python","patch_set":22,"id":"5faad753_99d0f4f9","line":426,"range":{"start_line":425,"start_character":20,"end_line":426,"end_character":54},"updated":"2019-09-09 21:45:34.000000000","message":"another unnecessary local var.\n\n claimed_resources.append(free.pop())","commit_id":"34317d58cee9597773f2a54c0634784e7cfd3e01"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"399e0df6c952f87d4191add3ac05588523731e2d","unresolved":false,"context_lines":[{"line_number":422,"context_line":"                    reason \u003d _(\"Resource Class: %s\") % rc"},{"line_number":423,"context_line":"                    raise exception.ComputeResourcesUnavailable(reason\u003dreason)"},{"line_number":424,"context_line":"                for i in range(amount):"},{"line_number":425,"context_line":"                    resource \u003d free.pop()"},{"line_number":426,"context_line":"                    claimed_resources.append(resource)"},{"line_number":427,"context_line":""},{"line_number":428,"context_line":"        if claimed_resources:"},{"line_number":429,"context_line":"            self._add_assigned_resources(claimed_resources)"}],"source_content_type":"text/x-python","patch_set":22,"id":"5faad753_507eca6b","line":426,"range":{"start_line":425,"start_character":20,"end_line":426,"end_character":54},"in_reply_to":"5faad753_99d0f4f9","updated":"2019-09-10 06:16:47.000000000","message":"Done","commit_id":"34317d58cee9597773f2a54c0634784e7cfd3e01"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"ce75bfa28271513f83bb97396cdb7943a712e845","unresolved":false,"context_lines":[{"line_number":466,"context_line":"        if not notfound:"},{"line_number":467,"context_line":"            return"},{"line_number":468,"context_line":"        resources \u003d [(res.identifier, res.resource_class)"},{"line_number":469,"context_line":"            for res in notfound]"},{"line_number":470,"context_line":"        LOG.error("},{"line_number":471,"context_line":"            \"Assigned resources not found in provider tree: %s .\""},{"line_number":472,"context_line":"            \"Please check your configuration.\", resources)"}],"source_content_type":"text/x-python","patch_set":22,"id":"5faad753_399a2014","line":469,"updated":"2019-09-09 21:45:34.000000000","message":"join lines","commit_id":"34317d58cee9597773f2a54c0634784e7cfd3e01"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"399e0df6c952f87d4191add3ac05588523731e2d","unresolved":false,"context_lines":[{"line_number":466,"context_line":"        if not notfound:"},{"line_number":467,"context_line":"            return"},{"line_number":468,"context_line":"        resources \u003d [(res.identifier, res.resource_class)"},{"line_number":469,"context_line":"            for res in notfound]"},{"line_number":470,"context_line":"        LOG.error("},{"line_number":471,"context_line":"            \"Assigned resources not found in provider tree: %s .\""},{"line_number":472,"context_line":"            \"Please check your configuration.\", resources)"}],"source_content_type":"text/x-python","patch_set":22,"id":"5faad753_50f32a0b","line":469,"in_reply_to":"5faad753_399a2014","updated":"2019-09-10 06:16:47.000000000","message":"Done","commit_id":"34317d58cee9597773f2a54c0634784e7cfd3e01"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"ce75bfa28271513f83bb97396cdb7943a712e845","unresolved":false,"context_lines":[{"line_number":481,"context_line":"            rp_uuid \u003d resource.provider_uuid"},{"line_number":482,"context_line":"            rc \u003d resource.resource_class"},{"line_number":483,"context_line":"            try:"},{"line_number":484,"context_line":"                self.assigned_resources[rp_uuid][rc].remove(resource)"},{"line_number":485,"context_line":"            except KeyError:"},{"line_number":486,"context_line":"                LOG.warning(\"Release resource %(rc)s: %(id)s, not\""},{"line_number":487,"context_line":"                            \"tracked in ResourceTracker.assigned_resources.\","}],"source_content_type":"text/x-python","patch_set":22,"id":"5faad753_99031443","line":484,"range":{"start_line":484,"start_character":16,"end_line":484,"end_character":69},"updated":"2019-09-09 21:45:34.000000000","message":"nts: this can end up vivifying self.assigned_resources[rp_uuid] as an empty dict, and/or self.assigned_resources[rp_uuid][rc] as an empty set, if either/both didn\u0027t exist before. But that doesn\u0027t affect anything.","commit_id":"34317d58cee9597773f2a54c0634784e7cfd3e01"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"ce75bfa28271513f83bb97396cdb7943a712e845","unresolved":false,"context_lines":[{"line_number":483,"context_line":"            try:"},{"line_number":484,"context_line":"                self.assigned_resources[rp_uuid][rc].remove(resource)"},{"line_number":485,"context_line":"            except KeyError:"},{"line_number":486,"context_line":"                LOG.warning(\"Release resource %(rc)s: %(id)s, not\""},{"line_number":487,"context_line":"                            \"tracked in ResourceTracker.assigned_resources.\","},{"line_number":488,"context_line":"                            {\u0027rc\u0027: rc, \u0027id\u0027: resource.identifier})"},{"line_number":489,"context_line":"                continue"}],"source_content_type":"text/x-python","patch_set":22,"id":"5faad753_59fd9c38","line":486,"updated":"2019-09-09 21:45:34.000000000","message":"consider including rp_uuid in this message as well.","commit_id":"34317d58cee9597773f2a54c0634784e7cfd3e01"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"399e0df6c952f87d4191add3ac05588523731e2d","unresolved":false,"context_lines":[{"line_number":483,"context_line":"            try:"},{"line_number":484,"context_line":"                self.assigned_resources[rp_uuid][rc].remove(resource)"},{"line_number":485,"context_line":"            except KeyError:"},{"line_number":486,"context_line":"                LOG.warning(\"Release resource %(rc)s: %(id)s, not\""},{"line_number":487,"context_line":"                            \"tracked in ResourceTracker.assigned_resources.\","},{"line_number":488,"context_line":"                            {\u0027rc\u0027: rc, \u0027id\u0027: resource.identifier})"},{"line_number":489,"context_line":"                continue"}],"source_content_type":"text/x-python","patch_set":22,"id":"5faad753_10c6129c","line":486,"in_reply_to":"5faad753_59fd9c38","updated":"2019-09-10 06:16:47.000000000","message":"Done","commit_id":"34317d58cee9597773f2a54c0634784e7cfd3e01"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"ce75bfa28271513f83bb97396cdb7943a712e845","unresolved":false,"context_lines":[{"line_number":486,"context_line":"                LOG.warning(\"Release resource %(rc)s: %(id)s, not\""},{"line_number":487,"context_line":"                            \"tracked in ResourceTracker.assigned_resources.\","},{"line_number":488,"context_line":"                            {\u0027rc\u0027: rc, \u0027id\u0027: resource.identifier})"},{"line_number":489,"context_line":"                continue"},{"line_number":490,"context_line":""},{"line_number":491,"context_line":"    def _add_assigned_resources(self, resources):"},{"line_number":492,"context_line":"        \"\"\"Add resources to self.assigned_resources\"\"\""}],"source_content_type":"text/x-python","patch_set":22,"id":"5faad753_39678050","line":489,"range":{"start_line":489,"start_character":16,"end_line":489,"end_character":24},"updated":"2019-09-09 21:45:34.000000000","message":"redundant","commit_id":"34317d58cee9597773f2a54c0634784e7cfd3e01"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"399e0df6c952f87d4191add3ac05588523731e2d","unresolved":false,"context_lines":[{"line_number":486,"context_line":"                LOG.warning(\"Release resource %(rc)s: %(id)s, not\""},{"line_number":487,"context_line":"                            \"tracked in ResourceTracker.assigned_resources.\","},{"line_number":488,"context_line":"                            {\u0027rc\u0027: rc, \u0027id\u0027: resource.identifier})"},{"line_number":489,"context_line":"                continue"},{"line_number":490,"context_line":""},{"line_number":491,"context_line":"    def _add_assigned_resources(self, resources):"},{"line_number":492,"context_line":"        \"\"\"Add resources to self.assigned_resources\"\"\""}],"source_content_type":"text/x-python","patch_set":22,"id":"5faad753_10ddb26f","line":489,"range":{"start_line":489,"start_character":16,"end_line":489,"end_character":24},"in_reply_to":"5faad753_39678050","updated":"2019-09-10 06:16:47.000000000","message":"Done","commit_id":"34317d58cee9597773f2a54c0634784e7cfd3e01"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"ce75bfa28271513f83bb97396cdb7943a712e845","unresolved":false,"context_lines":[{"line_number":934,"context_line":"        # Check if there is any resource assigned but not found"},{"line_number":935,"context_line":"        # in provider tree"},{"line_number":936,"context_line":"        if startup:"},{"line_number":937,"context_line":"            self._check_resources(context)"},{"line_number":938,"context_line":""},{"line_number":939,"context_line":"    def _get_compute_node(self, context, nodename):"},{"line_number":940,"context_line":"        \"\"\"Returns compute node for the host and nodename.\"\"\""}],"source_content_type":"text/x-python","patch_set":22,"id":"5faad753_5677ab3b","line":937,"range":{"start_line":937,"start_character":11,"end_line":937,"end_character":42},"updated":"2019-09-09 21:45:34.000000000","message":"nts: This can raise an exception, but the main Exception trap in _update_available_resource_for_node will log it and carry on, so this won\u0027t blow up the compute service ✔","commit_id":"34317d58cee9597773f2a54c0634784e7cfd3e01"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"ce75bfa28271513f83bb97396cdb7943a712e845","unresolved":false,"context_lines":[{"line_number":1165,"context_line":""},{"line_number":1166,"context_line":"            prov_tree.update_inventory(nodename, inv_data)"},{"line_number":1167,"context_line":""},{"line_number":1168,"context_line":"        self.provider_tree \u003d prov_tree"},{"line_number":1169,"context_line":""},{"line_number":1170,"context_line":"        # Flush any changes. If we processed ReshapeNeeded above, allocs is not"},{"line_number":1171,"context_line":"        # None, and this will hit placement\u0027s POST /reshaper route."}],"source_content_type":"text/x-python","patch_set":22,"id":"5faad753_96f9a381","line":1168,"range":{"start_line":1168,"start_character":8,"end_line":1168,"end_character":38},"updated":"2019-09-09 21:45:34.000000000","message":"I really don\u0027t like the fact that we\u0027re storing another copy of the provider tree.\n\nAfter update_from_provider_tree finishes, self.provider_tree should be identical to self.reportclient._provider_tree. So we should simply be able to provide public access to the latter, perhaps via a reportclient @property.\n\nThis *would* be problematic because instance_claim and _move_claim can run asynchronously with _update_to_placement, so we would run the risk of getting the provider tree when it\u0027s in some intermediate state.\n\nBUT\n\nAll of these methods are guarded by COMPUTE_RESOURCE_SEMAPHORE, so we\u0027re guaranteed self.reportclient._provider_tree is in a consistent state while we\u0027re using it.\n\nThat said, I also don\u0027t like deliberately accessing the reportclient\u0027s cache.\n\nWhat to do, what to do?\n\n[Later]\n\nOkay, how about this:\n\nThe uses of self.provider_tree are in _claim_resources and _check_resources. Both of those are read-only accesses of the .resources for a given provider. So let\u0027s make a method in SchedulerReportClient itself that returns just that. E.g.\n\n def local_resources_for_provider(self, rp_uuid):\n     \"\"\"Real docstring here.\"\"\"\n     return self._provider_tree.data(rp_uuid).resources\n\nAnd then _claim_resources and _check_resources can simply ask for\n\n self.reportclient.local_resources_for_provider(rp_uuid)\n\nand you don\u0027t need self.provider_tree in the resource tracker.","commit_id":"34317d58cee9597773f2a54c0634784e7cfd3e01"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"20f5d1ec13193c34c4977de7a6986b0c6a680b72","unresolved":false,"context_lines":[{"line_number":1165,"context_line":""},{"line_number":1166,"context_line":"            prov_tree.update_inventory(nodename, inv_data)"},{"line_number":1167,"context_line":""},{"line_number":1168,"context_line":"        self.provider_tree \u003d prov_tree"},{"line_number":1169,"context_line":""},{"line_number":1170,"context_line":"        # Flush any changes. If we processed ReshapeNeeded above, allocs is not"},{"line_number":1171,"context_line":"        # None, and this will hit placement\u0027s POST /reshaper route."}],"source_content_type":"text/x-python","patch_set":22,"id":"5faad753_8a7e4269","line":1168,"range":{"start_line":1168,"start_character":8,"end_line":1168,"end_character":38},"in_reply_to":"5faad753_50ea4a75","updated":"2019-09-10 14:00:19.000000000","message":"Sorry Luyao, you\u0027re right. I was willing to blur the line and have the report client be aware of the local resources - but I overlooked the fact that the report client\u0027s provider tree never sees them at all.\n\nLet\u0027s leave this alone for now, but perhaps later we can trim the data structure so we\u0027re just storing the resources.","commit_id":"34317d58cee9597773f2a54c0634784e7cfd3e01"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"399e0df6c952f87d4191add3ac05588523731e2d","unresolved":false,"context_lines":[{"line_number":1165,"context_line":""},{"line_number":1166,"context_line":"            prov_tree.update_inventory(nodename, inv_data)"},{"line_number":1167,"context_line":""},{"line_number":1168,"context_line":"        self.provider_tree \u003d prov_tree"},{"line_number":1169,"context_line":""},{"line_number":1170,"context_line":"        # Flush any changes. If we processed ReshapeNeeded above, allocs is not"},{"line_number":1171,"context_line":"        # None, and this will hit placement\u0027s POST /reshaper route."}],"source_content_type":"text/x-python","patch_set":22,"id":"5faad753_50ea4a75","line":1168,"range":{"start_line":1168,"start_character":8,"end_line":1168,"end_character":38},"in_reply_to":"5faad753_96f9a381","updated":"2019-09-10 06:16:47.000000000","message":"I look through the SchedulerReportClient, it seems like almost operations are reporting to placement, such as  \u0027set_inventory_for_provider\u0027, and the self._provider_tree will be updated by the return from the placement.\n\nAnd self._provider_tree does not cache \u0027resources\u0027 now, we need to add a method, something like \u0027set_resources_for_provider\u0027, which will not be related to \u0027report to placement\u0027, just update _provider_tree. I\u0027m not sure if it is proper.","commit_id":"34317d58cee9597773f2a54c0634784e7cfd3e01"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"e5e8e98778e4c1b9f78b02945f1fb418d2099b87","unresolved":false,"context_lines":[{"line_number":399,"context_line":"        for rp_uuid, alloc_dict in allocations.items():"},{"line_number":400,"context_line":"            allocated_resources \u003d alloc_dict[\u0027resources\u0027]"},{"line_number":401,"context_line":"            try:"},{"line_number":402,"context_line":"                # TODO(Luyao)"},{"line_number":403,"context_line":"                # In many functional tests, provider tree doesn\u0027t have"},{"line_number":404,"context_line":"                # rp uuids in allocations, we believe this won\u0027t happen"},{"line_number":405,"context_line":"                # in real OpenStack enviroment. Still need look into"},{"line_number":406,"context_line":"                # functional tests, this is not as we expected."},{"line_number":407,"context_line":"                provider_data \u003d self.provider_tree.data(rp_uuid)"},{"line_number":408,"context_line":"            except ValueError:"},{"line_number":409,"context_line":"                continue"}],"source_content_type":"text/x-python","patch_set":23,"id":"5faad753_3651c663","line":406,"range":{"start_line":402,"start_character":16,"end_line":406,"end_character":63},"updated":"2019-09-10 07:30:49.000000000","message":"Actually, this will happen in real life. Because provider tree here will only keep the resources from virt driver, but ohther services except Nova will also report resources to placement, so allocations may also contain resources not in Nova.So let us just skip that and LOG it.","commit_id":"0dc8a1b449672feb1422900e8a6ec801ee8a5aa1"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"e500c3d45333915e979ed9f337425c6fe85f63eb","unresolved":false,"context_lines":[{"line_number":399,"context_line":"        for rp_uuid, alloc_dict in allocations.items():"},{"line_number":400,"context_line":"            allocated_resources \u003d alloc_dict[\u0027resources\u0027]"},{"line_number":401,"context_line":"            try:"},{"line_number":402,"context_line":"                # TODO(Luyao)"},{"line_number":403,"context_line":"                # In many functional tests, provider tree doesn\u0027t have"},{"line_number":404,"context_line":"                # rp uuids in allocations, we believe this won\u0027t happen"},{"line_number":405,"context_line":"                # in real OpenStack enviroment. Still need look into"},{"line_number":406,"context_line":"                # functional tests, this is not as we expected."},{"line_number":407,"context_line":"                provider_data \u003d self.provider_tree.data(rp_uuid)"},{"line_number":408,"context_line":"            except ValueError:"},{"line_number":409,"context_line":"                continue"}],"source_content_type":"text/x-python","patch_set":23,"id":"5faad753_a18a4e18","line":406,"range":{"start_line":402,"start_character":16,"end_line":406,"end_character":63},"in_reply_to":"5faad753_3651c663","updated":"2019-09-10 08:16:12.000000000","message":"Another scenario, when an instance is in evacuation, it will have two group of allocations, one from src, another one from dest.","commit_id":"0dc8a1b449672feb1422900e8a6ec801ee8a5aa1"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"20f5d1ec13193c34c4977de7a6986b0c6a680b72","unresolved":false,"context_lines":[{"line_number":399,"context_line":"        for rp_uuid, alloc_dict in allocations.items():"},{"line_number":400,"context_line":"            allocated_resources \u003d alloc_dict[\u0027resources\u0027]"},{"line_number":401,"context_line":"            try:"},{"line_number":402,"context_line":"                # TODO(Luyao)"},{"line_number":403,"context_line":"                # In many functional tests, provider tree doesn\u0027t have"},{"line_number":404,"context_line":"                # rp uuids in allocations, we believe this won\u0027t happen"},{"line_number":405,"context_line":"                # in real OpenStack enviroment. Still need look into"},{"line_number":406,"context_line":"                # functional tests, this is not as we expected."},{"line_number":407,"context_line":"                provider_data \u003d self.provider_tree.data(rp_uuid)"},{"line_number":408,"context_line":"            except ValueError:"},{"line_number":409,"context_line":"                continue"}],"source_content_type":"text/x-python","patch_set":23,"id":"5faad753_4accca69","line":406,"range":{"start_line":402,"start_character":16,"end_line":406,"end_character":63},"in_reply_to":"5faad753_393f7226","updated":"2019-09-10 14:00:19.000000000","message":"\u003e Because provider tree here\n \u003e will only keep the resources from virt driver, but ohther services\n \u003e except Nova will also report resources to placement, so allocations\n \u003e may also contain resources not in Nova.\n\nBy design, the provider tree should contain all providers associated with the allocations, even if those providers were reported by a different service.\n\n \u003e Another scenario, when an instance is in evacuation, it will have\n \u003e two group of allocations, one from src, another one from dest.\n\nYes, this is legit.\n\n \u003e 1. For reporting resources of other service, they will be in the\n \u003e compute node provider tree, related functional tests failed because\n \u003e the periodic update_available_resources don\u0027t update the provider\n \u003e tree yet when claiming resources.\n\nThis should not be able to happen. If the resources weren\u0027t there, then the inventories wouldn\u0027t be either.\n\n \u003e 2.For rebuild, one instance will have two groups of allocations,\n \u003e one is of src compute node provider, another one is of dest compute\n \u003e node provider, we still need skip this case.\n\nPer IRC [1], rebuild maintains the same set of allocations throughout the process, so we shouldn\u0027t be able to hit this in that case.\n\n \u003e So let us just skip that and\n \u003e LOG it.\n\nYes, and make sure the log message (and the comment) reflects that evacuate *should* be the only way this can happen. The log message should include the rp_uuid for debugging purposes, in case it turns out to be something *other* than an evacuate.\n\n[1] http://eavesdrop.openstack.org/irclogs/%23openstack-nova/%23openstack-nova.2019-09-10.log.html#t2019-09-10T13:36:12","commit_id":"0dc8a1b449672feb1422900e8a6ec801ee8a5aa1"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"96190592a5e3ca4d84a118a0fb45232573508bf8","unresolved":false,"context_lines":[{"line_number":399,"context_line":"        for rp_uuid, alloc_dict in allocations.items():"},{"line_number":400,"context_line":"            allocated_resources \u003d alloc_dict[\u0027resources\u0027]"},{"line_number":401,"context_line":"            try:"},{"line_number":402,"context_line":"                # TODO(Luyao)"},{"line_number":403,"context_line":"                # In many functional tests, provider tree doesn\u0027t have"},{"line_number":404,"context_line":"                # rp uuids in allocations, we believe this won\u0027t happen"},{"line_number":405,"context_line":"                # in real OpenStack enviroment. Still need look into"},{"line_number":406,"context_line":"                # functional tests, this is not as we expected."},{"line_number":407,"context_line":"                provider_data \u003d self.provider_tree.data(rp_uuid)"},{"line_number":408,"context_line":"            except ValueError:"},{"line_number":409,"context_line":"                continue"}],"source_content_type":"text/x-python","patch_set":23,"id":"5faad753_855ab5f0","line":406,"range":{"start_line":402,"start_character":16,"end_line":406,"end_character":63},"in_reply_to":"5faad753_393f7226","updated":"2019-09-10 13:52:40.000000000","message":"s/rebuild/evacuate","commit_id":"0dc8a1b449672feb1422900e8a6ec801ee8a5aa1"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"27a4e0491f1000fd1e279e732f92d5c0afca8c46","unresolved":false,"context_lines":[{"line_number":399,"context_line":"        for rp_uuid, alloc_dict in allocations.items():"},{"line_number":400,"context_line":"            allocated_resources \u003d alloc_dict[\u0027resources\u0027]"},{"line_number":401,"context_line":"            try:"},{"line_number":402,"context_line":"                # TODO(Luyao)"},{"line_number":403,"context_line":"                # In many functional tests, provider tree doesn\u0027t have"},{"line_number":404,"context_line":"                # rp uuids in allocations, we believe this won\u0027t happen"},{"line_number":405,"context_line":"                # in real OpenStack enviroment. Still need look into"},{"line_number":406,"context_line":"                # functional tests, this is not as we expected."},{"line_number":407,"context_line":"                provider_data \u003d self.provider_tree.data(rp_uuid)"},{"line_number":408,"context_line":"            except ValueError:"},{"line_number":409,"context_line":"                continue"}],"source_content_type":"text/x-python","patch_set":23,"id":"5faad753_393f7226","line":406,"range":{"start_line":402,"start_character":16,"end_line":406,"end_character":63},"in_reply_to":"5faad753_a18a4e18","updated":"2019-09-10 13:05:49.000000000","message":"Look through functional tests and code again. Correct something here.\n\n1. For reporting resources of other service, they will be in the compute node provider tree, related functional tests failed because the periodic update_available_resources don\u0027t update the provider tree yet when claiming resources.\n\n2.For rebuild, one instance will have two groups of allocations, one is of src compute node provider, another one is of dest compute node provider, we still need skip this case.\n\nThese are result from diving into failed functional tests, for 2. it isn\u0027t a bug, right?","commit_id":"0dc8a1b449672feb1422900e8a6ec801ee8a5aa1"},{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"1535b74d0b6a52fcdb1f24954844237c5d65f303","unresolved":false,"context_lines":[{"line_number":397,"context_line":"            return None"},{"line_number":398,"context_line":"        claimed_resources \u003d []"},{"line_number":399,"context_line":"        for rp_uuid, alloc_dict in allocations.items():"},{"line_number":400,"context_line":"            allocated_resources \u003d alloc_dict[\u0027resources\u0027]"},{"line_number":401,"context_line":"            try:"},{"line_number":402,"context_line":"                provider_data \u003d self.provider_tree.data(rp_uuid)"},{"line_number":403,"context_line":"            except ValueError:"}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_fbb8ea2a","line":400,"range":{"start_line":400,"start_character":0,"end_line":400,"end_character":57},"updated":"2019-09-10 15:10:36.000000000","message":"nit: Could move this after the try-except below","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"e97c52fb00a4d734e627c7d32fc7a8431c4c0fc6","unresolved":false,"context_lines":[{"line_number":397,"context_line":"            return None"},{"line_number":398,"context_line":"        claimed_resources \u003d []"},{"line_number":399,"context_line":"        for rp_uuid, alloc_dict in allocations.items():"},{"line_number":400,"context_line":"            allocated_resources \u003d alloc_dict[\u0027resources\u0027]"},{"line_number":401,"context_line":"            try:"},{"line_number":402,"context_line":"                provider_data \u003d self.provider_tree.data(rp_uuid)"},{"line_number":403,"context_line":"            except ValueError:"}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_38843a0c","line":400,"range":{"start_line":400,"start_character":0,"end_line":400,"end_character":57},"in_reply_to":"5faad753_fbb8ea2a","updated":"2019-09-11 08:13:28.000000000","message":"Done","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"1535b74d0b6a52fcdb1f24954844237c5d65f303","unresolved":false,"context_lines":[{"line_number":402,"context_line":"                provider_data \u003d self.provider_tree.data(rp_uuid)"},{"line_number":403,"context_line":"            except ValueError:"},{"line_number":404,"context_line":"                # If an instance is in evacuating, it will hold new and old"},{"line_number":405,"context_line":"                # allocations, the provider uuids in old allocations isn\u0027t"},{"line_number":406,"context_line":"                # existing in current provider tree, so skip it."},{"line_number":407,"context_line":"                LOG.debug(\"Skip claiming resources of provider %(rp_uuid)s, \""},{"line_number":408,"context_line":"                          \"since the provider uuid is not in provider tree.\","}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_3b6a02b3","line":405,"range":{"start_line":405,"start_character":44,"end_line":405,"end_character":49},"updated":"2019-09-10 15:10:36.000000000","message":"UUIDs","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"1535b74d0b6a52fcdb1f24954844237c5d65f303","unresolved":false,"context_lines":[{"line_number":402,"context_line":"                provider_data \u003d self.provider_tree.data(rp_uuid)"},{"line_number":403,"context_line":"            except ValueError:"},{"line_number":404,"context_line":"                # If an instance is in evacuating, it will hold new and old"},{"line_number":405,"context_line":"                # allocations, the provider uuids in old allocations isn\u0027t"},{"line_number":406,"context_line":"                # existing in current provider tree, so skip it."},{"line_number":407,"context_line":"                LOG.debug(\"Skip claiming resources of provider %(rp_uuid)s, \""},{"line_number":408,"context_line":"                          \"since the provider uuid is not in provider tree.\","}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_7b707aa6","line":405,"range":{"start_line":405,"start_character":29,"end_line":405,"end_character":31},"updated":"2019-09-10 15:10:36.000000000","message":"but","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"e97c52fb00a4d734e627c7d32fc7a8431c4c0fc6","unresolved":false,"context_lines":[{"line_number":402,"context_line":"                provider_data \u003d self.provider_tree.data(rp_uuid)"},{"line_number":403,"context_line":"            except ValueError:"},{"line_number":404,"context_line":"                # If an instance is in evacuating, it will hold new and old"},{"line_number":405,"context_line":"                # allocations, the provider uuids in old allocations isn\u0027t"},{"line_number":406,"context_line":"                # existing in current provider tree, so skip it."},{"line_number":407,"context_line":"                LOG.debug(\"Skip claiming resources of provider %(rp_uuid)s, \""},{"line_number":408,"context_line":"                          \"since the provider uuid is not in provider tree.\","}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_1d0e1032","line":405,"range":{"start_line":405,"start_character":44,"end_line":405,"end_character":49},"in_reply_to":"5faad753_3b6a02b3","updated":"2019-09-11 08:13:28.000000000","message":"Done","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"e97c52fb00a4d734e627c7d32fc7a8431c4c0fc6","unresolved":false,"context_lines":[{"line_number":402,"context_line":"                provider_data \u003d self.provider_tree.data(rp_uuid)"},{"line_number":403,"context_line":"            except ValueError:"},{"line_number":404,"context_line":"                # If an instance is in evacuating, it will hold new and old"},{"line_number":405,"context_line":"                # allocations, the provider uuids in old allocations isn\u0027t"},{"line_number":406,"context_line":"                # existing in current provider tree, so skip it."},{"line_number":407,"context_line":"                LOG.debug(\"Skip claiming resources of provider %(rp_uuid)s, \""},{"line_number":408,"context_line":"                          \"since the provider uuid is not in provider tree.\","}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_fd121458","line":405,"range":{"start_line":405,"start_character":29,"end_line":405,"end_character":31},"in_reply_to":"5faad753_7b707aa6","updated":"2019-09-11 08:13:28.000000000","message":"Done","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"1535b74d0b6a52fcdb1f24954844237c5d65f303","unresolved":false,"context_lines":[{"line_number":402,"context_line":"                provider_data \u003d self.provider_tree.data(rp_uuid)"},{"line_number":403,"context_line":"            except ValueError:"},{"line_number":404,"context_line":"                # If an instance is in evacuating, it will hold new and old"},{"line_number":405,"context_line":"                # allocations, the provider uuids in old allocations isn\u0027t"},{"line_number":406,"context_line":"                # existing in current provider tree, so skip it."},{"line_number":407,"context_line":"                LOG.debug(\"Skip claiming resources of provider %(rp_uuid)s, \""},{"line_number":408,"context_line":"                          \"since the provider uuid is not in provider tree.\","},{"line_number":409,"context_line":"                          {\u0027rp_uuid\u0027: rp_uuid})"}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_1b5f060f","line":406,"range":{"start_line":405,"start_character":70,"end_line":406,"end_character":26},"updated":"2019-09-10 15:10:36.000000000","message":"won\u0027t exist in the","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"20e04d471bcd33da0b5c3bf061786ecccefe901d","unresolved":false,"context_lines":[{"line_number":403,"context_line":"            except ValueError:"},{"line_number":404,"context_line":"                # If an instance is in evacuating, it will hold new and old"},{"line_number":405,"context_line":"                # allocations, the provider uuids in old allocations isn\u0027t"},{"line_number":406,"context_line":"                # existing in current provider tree, so skip it."},{"line_number":407,"context_line":"                LOG.debug(\"Skip claiming resources of provider %(rp_uuid)s, \""},{"line_number":408,"context_line":"                          \"since the provider uuid is not in provider tree.\","},{"line_number":409,"context_line":"                          {\u0027rp_uuid\u0027: rp_uuid})"}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_208e4fd0","line":406,"updated":"2019-09-10 14:34:40.000000000","message":"✔","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"e97c52fb00a4d734e627c7d32fc7a8431c4c0fc6","unresolved":false,"context_lines":[{"line_number":402,"context_line":"                provider_data \u003d self.provider_tree.data(rp_uuid)"},{"line_number":403,"context_line":"            except ValueError:"},{"line_number":404,"context_line":"                # If an instance is in evacuating, it will hold new and old"},{"line_number":405,"context_line":"                # allocations, the provider uuids in old allocations isn\u0027t"},{"line_number":406,"context_line":"                # existing in current provider tree, so skip it."},{"line_number":407,"context_line":"                LOG.debug(\"Skip claiming resources of provider %(rp_uuid)s, \""},{"line_number":408,"context_line":"                          \"since the provider uuid is not in provider tree.\","},{"line_number":409,"context_line":"                          {\u0027rp_uuid\u0027: rp_uuid})"}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_5d0c883a","line":406,"range":{"start_line":405,"start_character":70,"end_line":406,"end_character":26},"in_reply_to":"5faad753_1b5f060f","updated":"2019-09-11 08:13:28.000000000","message":"Done","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"1535b74d0b6a52fcdb1f24954844237c5d65f303","unresolved":false,"context_lines":[{"line_number":408,"context_line":"                          \"since the provider uuid is not in provider tree.\","},{"line_number":409,"context_line":"                          {\u0027rp_uuid\u0027: rp_uuid})"},{"line_number":410,"context_line":"                continue"},{"line_number":411,"context_line":"            for rc, amount in allocated_resources.items():"},{"line_number":412,"context_line":"                if rc not in provider_data.resources:"},{"line_number":413,"context_line":"                    # This means we don\u0027t use provider_data.resources to"},{"line_number":414,"context_line":"                    # assign this kind of resource class, such as \u0027VCPU\u0027 for"}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_bb84b25f","line":411,"range":{"start_line":411,"start_character":13,"end_line":411,"end_character":58},"updated":"2019-09-10 15:10:36.000000000","message":"nit:\n\n   for rc, amount in alloc_dict[\u0027resources\u0027].items():\n\nSince you don\u0027t seem to care about \u0027allocated_resources\u0027 elsewhere","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"e97c52fb00a4d734e627c7d32fc7a8431c4c0fc6","unresolved":false,"context_lines":[{"line_number":408,"context_line":"                          \"since the provider uuid is not in provider tree.\","},{"line_number":409,"context_line":"                          {\u0027rp_uuid\u0027: rp_uuid})"},{"line_number":410,"context_line":"                continue"},{"line_number":411,"context_line":"            for rc, amount in allocated_resources.items():"},{"line_number":412,"context_line":"                if rc not in provider_data.resources:"},{"line_number":413,"context_line":"                    # This means we don\u0027t use provider_data.resources to"},{"line_number":414,"context_line":"                    # assign this kind of resource class, such as \u0027VCPU\u0027 for"}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_3d098c2b","line":411,"range":{"start_line":411,"start_character":13,"end_line":411,"end_character":58},"in_reply_to":"5faad753_bb84b25f","updated":"2019-09-11 08:13:28.000000000","message":"Done","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"1535b74d0b6a52fcdb1f24954844237c5d65f303","unresolved":false,"context_lines":[{"line_number":415,"context_line":"                    # now, otherwise the provider_data.resources will be"},{"line_number":416,"context_line":"                    # populated with this resource class when updating"},{"line_number":417,"context_line":"                    # provider tree."},{"line_number":418,"context_line":"                    LOG.debug(\"Skip %(rc)s resource claiming, \""},{"line_number":419,"context_line":"                              \"we don\u0027t use _Provider.resources \""},{"line_number":420,"context_line":"                              \"to assign this resource now.\", {\u0027rc\u0027: rc})"},{"line_number":421,"context_line":"                    continue"},{"line_number":422,"context_line":"                assigned \u003d self.assigned_resources[rp_uuid][rc]"},{"line_number":423,"context_line":"                free \u003d provider_data.resources[rc] - assigned"}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_3bc6829c","line":420,"range":{"start_line":418,"start_character":0,"end_line":420,"end_character":73},"updated":"2019-09-10 15:10:36.000000000","message":"I suspect this is going to be rather noisy, even for a debug log. Could we eliminate the resource types we are 100% sure we won\u0027t touch here? Something like:\n\n  if rc in (orc.VCPU, orc.PCPU, orc.MEMORY_MB, orc.DISK_GB):\n      continue\n\n...before this?","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"8f8f93a3ccf113220895c17c3ced2dc6d748a22d","unresolved":false,"context_lines":[{"line_number":415,"context_line":"                    # now, otherwise the provider_data.resources will be"},{"line_number":416,"context_line":"                    # populated with this resource class when updating"},{"line_number":417,"context_line":"                    # provider tree."},{"line_number":418,"context_line":"                    LOG.debug(\"Skip %(rc)s resource claiming, \""},{"line_number":419,"context_line":"                              \"we don\u0027t use _Provider.resources \""},{"line_number":420,"context_line":"                              \"to assign this resource now.\", {\u0027rc\u0027: rc})"},{"line_number":421,"context_line":"                    continue"},{"line_number":422,"context_line":"                assigned \u003d self.assigned_resources[rp_uuid][rc]"},{"line_number":423,"context_line":"                free \u003d provider_data.resources[rc] - assigned"}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_7ed6272a","line":420,"range":{"start_line":418,"start_character":0,"end_line":420,"end_character":73},"in_reply_to":"5faad753_3bc6829c","updated":"2019-09-10 15:41:24.000000000","message":"It\u0027s my fault that this is here at all. I noted its absence in PS22 [1] as being a good thing, but I wasn\u0027t clear about that.\n\nI don\u0027t like the idea of hardcoding resource classes to skip. I would rather just remove the log.\n\n[1] https://review.opendev.org/#/c/678452/22/nova/compute/resource_tracker.py@417","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"e97c52fb00a4d734e627c7d32fc7a8431c4c0fc6","unresolved":false,"context_lines":[{"line_number":415,"context_line":"                    # now, otherwise the provider_data.resources will be"},{"line_number":416,"context_line":"                    # populated with this resource class when updating"},{"line_number":417,"context_line":"                    # provider tree."},{"line_number":418,"context_line":"                    LOG.debug(\"Skip %(rc)s resource claiming, \""},{"line_number":419,"context_line":"                              \"we don\u0027t use _Provider.resources \""},{"line_number":420,"context_line":"                              \"to assign this resource now.\", {\u0027rc\u0027: rc})"},{"line_number":421,"context_line":"                    continue"},{"line_number":422,"context_line":"                assigned \u003d self.assigned_resources[rp_uuid][rc]"},{"line_number":423,"context_line":"                free \u003d provider_data.resources[rc] - assigned"}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_9d2be080","line":420,"range":{"start_line":418,"start_character":0,"end_line":420,"end_character":73},"in_reply_to":"5faad753_7ed6272a","updated":"2019-09-11 08:13:28.000000000","message":"drop the LOG","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"1535b74d0b6a52fcdb1f24954844237c5d65f303","unresolved":false,"context_lines":[{"line_number":423,"context_line":"                free \u003d provider_data.resources[rc] - assigned"},{"line_number":424,"context_line":"                if amount \u003e len(free):"},{"line_number":425,"context_line":"                    reason \u003d (_(\"Needed %(amount)d units of resource class \""},{"line_number":426,"context_line":"                                \"%(rc)s, but %(avail)d are availble.\") %"},{"line_number":427,"context_line":"                                {\u0027amount\u0027: amount,"},{"line_number":428,"context_line":"                                 \u0027rc\u0027: rc,"},{"line_number":429,"context_line":"                                 \u0027avail\u0027: len(free)})"}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_6009a72f","line":426,"range":{"start_line":426,"start_character":59,"end_line":426,"end_character":67},"updated":"2019-09-10 15:10:36.000000000","message":"available","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"e97c52fb00a4d734e627c7d32fc7a8431c4c0fc6","unresolved":false,"context_lines":[{"line_number":423,"context_line":"                free \u003d provider_data.resources[rc] - assigned"},{"line_number":424,"context_line":"                if amount \u003e len(free):"},{"line_number":425,"context_line":"                    reason \u003d (_(\"Needed %(amount)d units of resource class \""},{"line_number":426,"context_line":"                                \"%(rc)s, but %(avail)d are availble.\") %"},{"line_number":427,"context_line":"                                {\u0027amount\u0027: amount,"},{"line_number":428,"context_line":"                                 \u0027rc\u0027: rc,"},{"line_number":429,"context_line":"                                 \u0027avail\u0027: len(free)})"}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_5d2568aa","line":426,"range":{"start_line":426,"start_character":59,"end_line":426,"end_character":67},"in_reply_to":"5faad753_6009a72f","updated":"2019-09-11 08:13:28.000000000","message":"Done","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"1535b74d0b6a52fcdb1f24954844237c5d65f303","unresolved":false,"context_lines":[{"line_number":470,"context_line":"                notfound |\u003d (assigned - provider_data.resources[rc])"},{"line_number":471,"context_line":""},{"line_number":472,"context_line":"        if not notfound:"},{"line_number":473,"context_line":"            return"},{"line_number":474,"context_line":"        resources \u003d [(res.identifier, res.resource_class) for res in notfound]"},{"line_number":475,"context_line":"        LOG.error("},{"line_number":476,"context_line":"            \"Assigned resources not found in provider tree: %s .\""}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_bb0592c4","line":473,"updated":"2019-09-10 15:10:36.000000000","message":"nit: newline after this to make it stand out","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"e97c52fb00a4d734e627c7d32fc7a8431c4c0fc6","unresolved":false,"context_lines":[{"line_number":470,"context_line":"                notfound |\u003d (assigned - provider_data.resources[rc])"},{"line_number":471,"context_line":""},{"line_number":472,"context_line":"        if not notfound:"},{"line_number":473,"context_line":"            return"},{"line_number":474,"context_line":"        resources \u003d [(res.identifier, res.resource_class) for res in notfound]"},{"line_number":475,"context_line":"        LOG.error("},{"line_number":476,"context_line":"            \"Assigned resources not found in provider tree: %s .\""}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_58aed698","line":473,"in_reply_to":"5faad753_bb0592c4","updated":"2019-09-11 08:13:28.000000000","message":"Done","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"1535b74d0b6a52fcdb1f24954844237c5d65f303","unresolved":false,"context_lines":[{"line_number":472,"context_line":"        if not notfound:"},{"line_number":473,"context_line":"            return"},{"line_number":474,"context_line":"        resources \u003d [(res.identifier, res.resource_class) for res in notfound]"},{"line_number":475,"context_line":"        LOG.error("},{"line_number":476,"context_line":"            \"Assigned resources not found in provider tree: %s .\""},{"line_number":477,"context_line":"            \"Please check your configuration.\", resources)"},{"line_number":478,"context_line":"        raise exception.AssignedResourceNotFound("},{"line_number":479,"context_line":"            resources\u003dresources)"},{"line_number":480,"context_line":""}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_3bf9a2c7","line":477,"range":{"start_line":475,"start_character":0,"end_line":477,"end_character":58},"updated":"2019-09-10 15:10:36.000000000","message":"I\u0027ve asked this in other reviews, but why do we need to log when we\u0027re raising an exception below? Surely that\u0027s good enough?","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"1535b74d0b6a52fcdb1f24954844237c5d65f303","unresolved":false,"context_lines":[{"line_number":474,"context_line":"        resources \u003d [(res.identifier, res.resource_class) for res in notfound]"},{"line_number":475,"context_line":"        LOG.error("},{"line_number":476,"context_line":"            \"Assigned resources not found in provider tree: %s .\""},{"line_number":477,"context_line":"            \"Please check your configuration.\", resources)"},{"line_number":478,"context_line":"        raise exception.AssignedResourceNotFound("},{"line_number":479,"context_line":"            resources\u003dresources)"},{"line_number":480,"context_line":""}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_3b220254","line":477,"range":{"start_line":477,"start_character":13,"end_line":477,"end_character":45},"updated":"2019-09-10 15:10:36.000000000","message":"This doesn\u0027t provide much information. What kind of configuration issue could cause this kind of issue? Perhaps we could provide a very brief description in a comment on in the exception/log?","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"a5b38ab420df306b9a318da1bac34564c5401d29","unresolved":false,"context_lines":[{"line_number":474,"context_line":"        resources \u003d [(res.identifier, res.resource_class) for res in notfound]"},{"line_number":475,"context_line":"        LOG.error("},{"line_number":476,"context_line":"            \"Assigned resources not found in provider tree: %s .\""},{"line_number":477,"context_line":"            \"Please check your configuration.\", resources)"},{"line_number":478,"context_line":"        raise exception.AssignedResourceNotFound("},{"line_number":479,"context_line":"            resources\u003dresources)"},{"line_number":480,"context_line":""}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_6478bb29","line":477,"range":{"start_line":477,"start_character":13,"end_line":477,"end_character":45},"in_reply_to":"5faad753_3790c443","updated":"2019-09-11 16:35:46.000000000","message":"I sure was (and for the LOG.error to be dropped)","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"94d08b28ea7c4215cd4712960afac7b1861724df","unresolved":false,"context_lines":[{"line_number":474,"context_line":"        resources \u003d [(res.identifier, res.resource_class) for res in notfound]"},{"line_number":475,"context_line":"        LOG.error("},{"line_number":476,"context_line":"            \"Assigned resources not found in provider tree: %s .\""},{"line_number":477,"context_line":"            \"Please check your configuration.\", resources)"},{"line_number":478,"context_line":"        raise exception.AssignedResourceNotFound("},{"line_number":479,"context_line":"            resources\u003dresources)"},{"line_number":480,"context_line":""}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_94e2d62e","line":477,"range":{"start_line":477,"start_character":13,"end_line":477,"end_character":45},"in_reply_to":"5faad753_3b220254","updated":"2019-09-11 08:21:18.000000000","message":"For example, we have vpmem_0 assigned to some instance, but admin delete the vpmem_0 in configuration file and restart the compute service. We can\u0027t know what kind of configuration, but \u0027resources\u0027 info may tell people.\nAnother configuration means hardware configuration on host, maybe some devices.","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"4f50892943d254ec9e092de6d45892f5865cade5","unresolved":false,"context_lines":[{"line_number":472,"context_line":"        if not notfound:"},{"line_number":473,"context_line":"            return"},{"line_number":474,"context_line":"        resources \u003d [(res.identifier, res.resource_class) for res in notfound]"},{"line_number":475,"context_line":"        LOG.error("},{"line_number":476,"context_line":"            \"Assigned resources not found in provider tree: %s .\""},{"line_number":477,"context_line":"            \"Please check your configuration.\", resources)"},{"line_number":478,"context_line":"        raise exception.AssignedResourceNotFound("},{"line_number":479,"context_line":"            resources\u003dresources)"},{"line_number":480,"context_line":""}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_ea1fad6d","line":477,"range":{"start_line":475,"start_character":0,"end_line":477,"end_character":58},"in_reply_to":"5faad753_3bf9a2c7","updated":"2019-09-10 19:04:04.000000000","message":"\u003e I\u0027ve asked this in other reviews, but why do we need to log when\n \u003e we\u0027re raising an exception below? Surely that\u0027s good enough?\n\nThe exception winds up here [1]. I know LOG.exception prints out a stack trace; does it also print out the exception that got us there? If so, I agree this LOG.error is redundant.\n\n[1] https://opendev.org/openstack/nova/src/branch/master/nova/compute/manager.py#L8315-L8316","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"9bdb36bbb3aa0ae7bc394452cc869df7376034b4","unresolved":false,"context_lines":[{"line_number":474,"context_line":"        resources \u003d [(res.identifier, res.resource_class) for res in notfound]"},{"line_number":475,"context_line":"        LOG.error("},{"line_number":476,"context_line":"            \"Assigned resources not found in provider tree: %s .\""},{"line_number":477,"context_line":"            \"Please check your configuration.\", resources)"},{"line_number":478,"context_line":"        raise exception.AssignedResourceNotFound("},{"line_number":479,"context_line":"            resources\u003dresources)"},{"line_number":480,"context_line":""}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_c25cfe7f","line":477,"range":{"start_line":477,"start_character":13,"end_line":477,"end_character":45},"in_reply_to":"5faad753_6478bb29","updated":"2019-09-11 18:55:38.000000000","message":"Done","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"6ba5c299e4c0bb28b25c89be47bb8c2bd4d4f9cf","unresolved":false,"context_lines":[{"line_number":474,"context_line":"        resources \u003d [(res.identifier, res.resource_class) for res in notfound]"},{"line_number":475,"context_line":"        LOG.error("},{"line_number":476,"context_line":"            \"Assigned resources not found in provider tree: %s .\""},{"line_number":477,"context_line":"            \"Please check your configuration.\", resources)"},{"line_number":478,"context_line":"        raise exception.AssignedResourceNotFound("},{"line_number":479,"context_line":"            resources\u003dresources)"},{"line_number":480,"context_line":""}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_3790c443","line":477,"range":{"start_line":477,"start_character":13,"end_line":477,"end_character":45},"in_reply_to":"5faad753_94e2d62e","updated":"2019-09-11 09:32:30.000000000","message":"\u003e For example, we have vpmem_0 assigned to some instance, but admin\n \u003e delete the vpmem_0 in configuration file and restart the compute\n \u003e service. We can\u0027t know what kind of configuration, but \u0027resources\u0027\n \u003e info may tell people.\n \u003e Another configuration means hardware configuration on host, maybe\n \u003e some devices.\n\nI think Stephen was asking for this to be explained either in a code comment or in the log message itself.","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"1535b74d0b6a52fcdb1f24954844237c5d65f303","unresolved":false,"context_lines":[{"line_number":480,"context_line":""},{"line_number":481,"context_line":"    def _release_assigned_resources(self, resources):"},{"line_number":482,"context_line":"        \"\"\"Remove resources from self.assigned_resources.\"\"\""},{"line_number":483,"context_line":"        if not resources:"},{"line_number":484,"context_line":"            return"},{"line_number":485,"context_line":"        for resource in resources:"},{"line_number":486,"context_line":"            rp_uuid \u003d resource.provider_uuid"},{"line_number":487,"context_line":"            rc \u003d resource.resource_class"}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_bba112ac","line":484,"range":{"start_line":483,"start_character":0,"end_line":484,"end_character":18},"updated":"2019-09-10 15:10:36.000000000","message":"yup, resources is generated from a call to \u0027_get_migration_context_resource\u0027 which can return \u0027None\u0027","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"1535b74d0b6a52fcdb1f24954844237c5d65f303","unresolved":false,"context_lines":[{"line_number":496,"context_line":""},{"line_number":497,"context_line":"    def _add_assigned_resources(self, resources):"},{"line_number":498,"context_line":"        \"\"\"Add resources to self.assigned_resources\"\"\""},{"line_number":499,"context_line":"        if not resources:"},{"line_number":500,"context_line":"            return"},{"line_number":501,"context_line":"        for resource in resources:"},{"line_number":502,"context_line":"            rp_uuid \u003d resource.provider_uuid"},{"line_number":503,"context_line":"            rc \u003d resource.resource_class"}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_5b901e4f","line":500,"range":{"start_line":499,"start_character":0,"end_line":500,"end_character":18},"updated":"2019-09-10 15:10:36.000000000","message":"As above (\u0027_get_migration_context_resource\u0027 can return \u0027None\u0027)","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"6ba5c299e4c0bb28b25c89be47bb8c2bd4d4f9cf","unresolved":false,"context_lines":[{"line_number":403,"context_line":"                # If an instance is in evacuating, it will hold new and old"},{"line_number":404,"context_line":"                # allocations, but the provider UUIDs in old allocations won\u0027t"},{"line_number":405,"context_line":"                # exist in the current provider tree, so skip it."},{"line_number":406,"context_line":"                LOG.debug(\"Skip claiming resources of provider %(rp_uuid)s, \""},{"line_number":407,"context_line":"                          \"since the provider UUIDs are not in provider tree.\","},{"line_number":408,"context_line":"                          {\u0027rp_uuid\u0027: rp_uuid})"},{"line_number":409,"context_line":"                continue"}],"source_content_type":"text/x-python","patch_set":25,"id":"5faad753_b7959442","line":406,"range":{"start_line":406,"start_character":20,"end_line":406,"end_character":25},"updated":"2019-09-11 09:32:30.000000000","message":"I wonder if this should be a higher log level. It should be rare, and if it\u0027s happening it should be in a pretty exceptional situation.","commit_id":"427088d4a3601ac2d14a579a08dc36bb34c1203f"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"508345f2b5a90afed1cae52679b1800bd0d0278d","unresolved":false,"context_lines":[{"line_number":403,"context_line":"                # If an instance is in evacuating, it will hold new and old"},{"line_number":404,"context_line":"                # allocations, but the provider UUIDs in old allocations won\u0027t"},{"line_number":405,"context_line":"                # exist in the current provider tree, so skip it."},{"line_number":406,"context_line":"                LOG.debug(\"Skip claiming resources of provider %(rp_uuid)s, \""},{"line_number":407,"context_line":"                          \"since the provider UUIDs are not in provider tree.\","},{"line_number":408,"context_line":"                          {\u0027rp_uuid\u0027: rp_uuid})"},{"line_number":409,"context_line":"                continue"}],"source_content_type":"text/x-python","patch_set":25,"id":"5faad753_c0e72412","line":406,"range":{"start_line":406,"start_character":20,"end_line":406,"end_character":25},"in_reply_to":"5faad753_b7959442","updated":"2019-09-11 11:11:48.000000000","message":"I have no idea about this.","commit_id":"427088d4a3601ac2d14a579a08dc36bb34c1203f"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"6ba5c299e4c0bb28b25c89be47bb8c2bd4d4f9cf","unresolved":false,"context_lines":[{"line_number":470,"context_line":""},{"line_number":471,"context_line":"        resources \u003d [(res.identifier, res.resource_class) for res in notfound]"},{"line_number":472,"context_line":"        LOG.error("},{"line_number":473,"context_line":"            \"Assigned resources not found in provider tree: %s .\""},{"line_number":474,"context_line":"            \"Please check your configuration.\", resources)"},{"line_number":475,"context_line":"        raise exception.AssignedResourceNotFound("},{"line_number":476,"context_line":"            resources\u003dresources)"},{"line_number":477,"context_line":""}],"source_content_type":"text/x-python","patch_set":25,"id":"5faad753_3a2f4940","line":474,"range":{"start_line":473,"start_character":12,"end_line":474,"end_character":46},"updated":"2019-09-11 09:32:30.000000000","message":"Pursuant to [1], this could say something like:\n\n # This only happens when assigned resources are removed\n # from the configuration and the compute services is SIGHUP\u0027d\n # or restarted.\n LOG.error(\"The following resources are assigned to instances, \"\n           \"but were not listed in the configuration: %s\",\n           resources)\n\nIt would be nice if the message could be more helpful, but I\u0027m not sure what it should say. At this point in the code, we can\u0027t get more specific than \"the configuration\" -- [libvirt]pmem_namespaces happens to be the only config opt in play right now, but this code will (automatically, without change) pick up others as they\u0027re added. An admonishment not to remove resources if they\u0027re assigned to instances seems... patronizing? And if we start talking about possible remediation (delete the instances? restore the configs an HUP/restart compute?), this message could get quite chatty.\n\n[1] https://review.opendev.org/#/c/678452/24/nova/compute/resource_tracker.py@477","commit_id":"427088d4a3601ac2d14a579a08dc36bb34c1203f"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"508345f2b5a90afed1cae52679b1800bd0d0278d","unresolved":false,"context_lines":[{"line_number":470,"context_line":""},{"line_number":471,"context_line":"        resources \u003d [(res.identifier, res.resource_class) for res in notfound]"},{"line_number":472,"context_line":"        LOG.error("},{"line_number":473,"context_line":"            \"Assigned resources not found in provider tree: %s .\""},{"line_number":474,"context_line":"            \"Please check your configuration.\", resources)"},{"line_number":475,"context_line":"        raise exception.AssignedResourceNotFound("},{"line_number":476,"context_line":"            resources\u003dresources)"},{"line_number":477,"context_line":""}],"source_content_type":"text/x-python","patch_set":25,"id":"5faad753_60a510b5","line":474,"range":{"start_line":473,"start_character":12,"end_line":474,"end_character":46},"in_reply_to":"5faad753_3a2f4940","updated":"2019-09-11 11:11:48.000000000","message":"rewrite, please check it again. I can\u0027t find a word better than configuration. \u0027configuration\u0027 is abstract, it can be a file, a hardware or anything. I think admin will know about it when seeing this log.","commit_id":"427088d4a3601ac2d14a579a08dc36bb34c1203f"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"3e98b625177d4722b03851c6c8e2b821b78060a6","unresolved":false,"context_lines":[{"line_number":469,"context_line":"            return"},{"line_number":470,"context_line":""},{"line_number":471,"context_line":"        resources \u003d [(res.identifier, res.resource_class) for res in notfound]"},{"line_number":472,"context_line":"        # This only happens when assigned resources are removed"},{"line_number":473,"context_line":"        # from the configuration and the compute services is SIGHUP\u0027d"},{"line_number":474,"context_line":"        # or restarted."},{"line_number":475,"context_line":"        LOG.error(\"The following resources are assigned to instances, \""}],"source_content_type":"text/x-python","patch_set":27,"id":"5faad753_4b8b551e","line":472,"updated":"2019-09-11 11:52:13.000000000","message":"Yeah, this is better, thanks.","commit_id":"3d9b11dca1884c2c8e41f00ad3fed97fb1468fbe"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"23fb81b18dda30e118f0640d6c9206fac3c82a47","unresolved":false,"context_lines":[{"line_number":472,"context_line":"        # This only happens when assigned resources are removed"},{"line_number":473,"context_line":"        # from the configuration and the compute services is SIGHUP\u0027d"},{"line_number":474,"context_line":"        # or restarted."},{"line_number":475,"context_line":"        LOG.error(\"The following resources are assigned to instances, \""},{"line_number":476,"context_line":"                  \"but were not listed in the configuration: %s .\""},{"line_number":477,"context_line":"                  \"Please check if this will influence your instances, \""},{"line_number":478,"context_line":"                  \"and restore your configuration if necessary\", resources)"},{"line_number":479,"context_line":"        raise exception.AssignedResourceNotFound(resources\u003dresources)"},{"line_number":480,"context_line":""},{"line_number":481,"context_line":"    def _release_assigned_resources(self, resources):"}],"source_content_type":"text/x-python","patch_set":27,"id":"5faad753_25663c53","line":478,"range":{"start_line":475,"start_character":0,"end_line":478,"end_character":75},"updated":"2019-09-11 19:17:41.000000000","message":"If we\u0027re dropping this, it would be nice to put this improved text into the AssignedResourceNotFound exception itself.\n\nThat can be done later.","commit_id":"3d9b11dca1884c2c8e41f00ad3fed97fb1468fbe"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"1534eb63037eb71032e5853b7628b2444f32c527","unresolved":false,"context_lines":[{"line_number":472,"context_line":"        # This only happens when assigned resources are removed"},{"line_number":473,"context_line":"        # from the configuration and the compute services is SIGHUP\u0027d"},{"line_number":474,"context_line":"        # or restarted."},{"line_number":475,"context_line":"        LOG.error(\"The following resources are assigned to instances, \""},{"line_number":476,"context_line":"                  \"but were not listed in the configuration: %s .\""},{"line_number":477,"context_line":"                  \"Please check if this will influence your instances, \""},{"line_number":478,"context_line":"                  \"and restore your configuration if necessary\", resources)"},{"line_number":479,"context_line":"        raise exception.AssignedResourceNotFound(resources\u003dresources)"},{"line_number":480,"context_line":""},{"line_number":481,"context_line":"    def _release_assigned_resources(self, resources):"}],"source_content_type":"text/x-python","patch_set":27,"id":"5faad753_08f4705a","line":478,"range":{"start_line":475,"start_character":0,"end_line":478,"end_character":75},"in_reply_to":"5faad753_25663c53","updated":"2019-09-12 03:13:35.000000000","message":"Done","commit_id":"3d9b11dca1884c2c8e41f00ad3fed97fb1468fbe"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"a54d6462f548e42dbf8a5460f12c4f6fcddfb1cb","unresolved":false,"context_lines":[{"line_number":504,"context_line":"        # from the configuration and the compute service is SIGHUP\u0027d"},{"line_number":505,"context_line":"        # or restarted."},{"line_number":506,"context_line":"        resources \u003d [(res.identifier, res.resource_class) for res in notfound]"},{"line_number":507,"context_line":"        reason \u003d _(\"The following resources are assigned to instances, \""},{"line_number":508,"context_line":"                   \"but were not listed in the configuration: %s \""},{"line_number":509,"context_line":"                   \"Please check if this will influence your instances, \""},{"line_number":510,"context_line":"                   \"and restore your configuration if necessary\") % resources"},{"line_number":511,"context_line":"        raise exception.AssignedResourceNotFound(reason\u003dreason)"},{"line_number":512,"context_line":""},{"line_number":513,"context_line":"    def _release_assigned_resources(self, resources):"}],"source_content_type":"text/x-python","patch_set":32,"id":"5faad753_186119d4","line":510,"range":{"start_line":507,"start_character":0,"end_line":510,"end_character":77},"updated":"2019-09-12 10:32:30.000000000","message":"✔\n\nArguably the text could have been put into the exception itself, but this is fine.","commit_id":"ce14f7a6ba0f979a18aed285600fd41162618e31"},{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"9e346b97c4385a1fb345448196f712ec8501c42b","unresolved":false,"context_lines":[{"line_number":504,"context_line":"        # from the configuration and the compute service is SIGHUP\u0027d"},{"line_number":505,"context_line":"        # or restarted."},{"line_number":506,"context_line":"        resources \u003d [(res.identifier, res.resource_class) for res in notfound]"},{"line_number":507,"context_line":"        reason \u003d _(\"The following resources are assigned to instances, \""},{"line_number":508,"context_line":"                   \"but were not listed in the configuration: %s \""},{"line_number":509,"context_line":"                   \"Please check if this will influence your instances, \""},{"line_number":510,"context_line":"                   \"and restore your configuration if necessary\") % resources"},{"line_number":511,"context_line":"        raise exception.AssignedResourceNotFound(reason\u003dreason)"},{"line_number":512,"context_line":""},{"line_number":513,"context_line":"    def _release_assigned_resources(self, resources):"}],"source_content_type":"text/x-python","patch_set":32,"id":"5faad753_54ebd5da","line":510,"range":{"start_line":507,"start_character":0,"end_line":510,"end_character":77},"in_reply_to":"5faad753_186119d4","updated":"2019-09-12 15:57:33.000000000","message":"Good point. Would be a good follow-up post FF","commit_id":"ce14f7a6ba0f979a18aed285600fd41162618e31"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"5fd320ea6719504c67b96f104a3bc05a0c726b1e","unresolved":false,"context_lines":[{"line_number":476,"context_line":""},{"line_number":477,"context_line":"        # Get resources assigned to migrations"},{"line_number":478,"context_line":"        for mig in self.tracked_migrations.values():"},{"line_number":479,"context_line":"            mig_ctx \u003d mig.instance.migration_context"},{"line_number":480,"context_line":"            if mig.source_compute \u003d\u003d self.host and \u0027old_resources\u0027 in mig_ctx:"},{"line_number":481,"context_line":"                resources.extend(mig_ctx.old_resources or [])"},{"line_number":482,"context_line":"            if mig.dest_compute \u003d\u003d self.host and \u0027new_resources\u0027 in mig_ctx:"}],"source_content_type":"text/x-python","patch_set":33,"id":"3fa7e38b_f9081492","line":479,"range":{"start_line":479,"start_character":12,"end_line":479,"end_character":19},"updated":"2019-10-21 16:48:33.000000000","message":"There is a race window where this can be None resulting in a NoneType TypeError, see bug 1849165.","commit_id":"04231112d96d80bf85892e8717cf290681ba9a46"}],"nova/exception.py":[{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"b16dd01a6ca36642942098e21057db3a7d899ffe","unresolved":false,"context_lines":[{"line_number":2488,"context_line":""},{"line_number":2489,"context_line":""},{"line_number":2490,"context_line":"class AssignedResourceNotFound(NovaException):"},{"line_number":2491,"context_line":"    msg_fmt \u003d _(\"Assigned resource not found: %(resources)s\")"}],"source_content_type":"text/x-python","patch_set":7,"id":"7faddb67_9c673d25","line":2491,"range":{"start_line":2491,"start_character":26,"end_line":2491,"end_character":34},"updated":"2019-08-29 23:02:16.000000000","message":"resources","commit_id":"fc0d1b1258d42a20044504a7ee6a1791183e3dd2"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"3d7eb310beac331848500982bb51dbd15256160b","unresolved":false,"context_lines":[{"line_number":2488,"context_line":""},{"line_number":2489,"context_line":""},{"line_number":2490,"context_line":"class AssignedResourceNotFound(NovaException):"},{"line_number":2491,"context_line":"    msg_fmt \u003d _(\"Assigned resource not found: %(resources)s\")"}],"source_content_type":"text/x-python","patch_set":10,"id":"7faddb67_e45488c8","line":2491,"range":{"start_line":2491,"start_character":26,"end_line":2491,"end_character":34},"updated":"2019-08-30 18:01:28.000000000","message":"resources","commit_id":"3263c8915f740ac3f311e743ddac63151055114e"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"2277fceb9be589ebbcea73aa254c7576c3587dae","unresolved":false,"context_lines":[{"line_number":2488,"context_line":""},{"line_number":2489,"context_line":""},{"line_number":2490,"context_line":"class AssignedResourceNotFound(NovaException):"},{"line_number":2491,"context_line":"    msg_fmt \u003d _(\"Assigned resource not found: %(resources)s\")"}],"source_content_type":"text/x-python","patch_set":10,"id":"7faddb67_1ae25102","line":2491,"range":{"start_line":2491,"start_character":26,"end_line":2491,"end_character":34},"in_reply_to":"7faddb67_e45488c8","updated":"2019-09-02 07:10:33.000000000","message":"Done","commit_id":"3263c8915f740ac3f311e743ddac63151055114e"}],"nova/tests/unit/compute/test_resource_tracker.py":[{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"b16dd01a6ca36642942098e21057db3a7d899ffe","unresolved":false,"context_lines":[{"line_number":1885,"context_line":"        self._setup_rt()"},{"line_number":1886,"context_line":"        cn \u003d _COMPUTE_NODE_FIXTURES[0].obj_clone()"},{"line_number":1887,"context_line":"        self.rt.compute_nodes[_NODENAME] \u003d cn"},{"line_number":1888,"context_line":"        self.rt.prov_tree \u003d self._setup_ptree(cn)"},{"line_number":1889,"context_line":""},{"line_number":1890,"context_line":"        # not using mock.sentinel.ctx because instance_claim calls #elevated"},{"line_number":1891,"context_line":"        self.ctx \u003d mock.MagicMock()"}],"source_content_type":"text/x-python","patch_set":7,"id":"7faddb67_1c290d9b","line":1888,"range":{"start_line":1888,"start_character":8,"end_line":1888,"end_character":49},"updated":"2019-08-29 23:02:16.000000000","message":"You might as well just do this in the one test where you use it.","commit_id":"fc0d1b1258d42a20044504a7ee6a1791183e3dd2"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"3d7eb310beac331848500982bb51dbd15256160b","unresolved":false,"context_lines":[{"line_number":2173,"context_line":"        self.assertEqual(self.rt.host, self.instance.launched_on)"},{"line_number":2174,"context_line":"        self.assertEqual(_NODENAME, self.instance.node)"},{"line_number":2175,"context_line":"        self.assertEqual(\"RESOURCE_CLASS_0\","},{"line_number":2176,"context_line":"                         self.instance.resources[0].resource_class)"},{"line_number":2177,"context_line":""},{"line_number":2178,"context_line":"    @mock.patch(\u0027nova.compute.utils.is_volume_backed_instance\u0027)"},{"line_number":2179,"context_line":"    @mock.patch(\u0027nova.objects.InstancePCIRequests.get_by_instance_uuid\u0027)"}],"source_content_type":"text/x-python","patch_set":10,"id":"7faddb67_aae5f90b","line":2176,"updated":"2019-08-30 18:01:28.000000000","message":"We need waaay more testing than this.\n\nUnit tests ought to cover every code path.","commit_id":"3263c8915f740ac3f311e743ddac63151055114e"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"2277fceb9be589ebbcea73aa254c7576c3587dae","unresolved":false,"context_lines":[{"line_number":2173,"context_line":"        self.assertEqual(self.rt.host, self.instance.launched_on)"},{"line_number":2174,"context_line":"        self.assertEqual(_NODENAME, self.instance.node)"},{"line_number":2175,"context_line":"        self.assertEqual(\"RESOURCE_CLASS_0\","},{"line_number":2176,"context_line":"                         self.instance.resources[0].resource_class)"},{"line_number":2177,"context_line":""},{"line_number":2178,"context_line":"    @mock.patch(\u0027nova.compute.utils.is_volume_backed_instance\u0027)"},{"line_number":2179,"context_line":"    @mock.patch(\u0027nova.objects.InstancePCIRequests.get_by_instance_uuid\u0027)"}],"source_content_type":"text/x-python","patch_set":10,"id":"7faddb67_7aba65e1","line":2176,"in_reply_to":"7faddb67_aae5f90b","updated":"2019-09-02 07:10:33.000000000","message":"add one more test for claim failed","commit_id":"3263c8915f740ac3f311e743ddac63151055114e"},{"author":{"_account_id":5754,"name":"Alex Xu","email":"hejie.xu@intel.com","username":"xuhj"},"change_message_id":"519b8ce55a5e435b1cdbae91a80cb215ba1ad9ed","unresolved":false,"context_lines":[{"line_number":1113,"context_line":"    @mock.patch(\u0027nova.objects.InstanceList.get_by_filters\u0027)"},{"line_number":1114,"context_line":"    @mock.patch(\u0027nova.compute.utils.is_volume_backed_instance\u0027)"},{"line_number":1115,"context_line":"    @mock.patch(\u0027nova.objects.InstancePCIRequests.get_by_instance\u0027,"},{"line_number":1116,"context_line":"                return_value\u003dobjects.InstancePCIRequests(requests\u003d[]))"},{"line_number":1117,"context_line":"    @mock.patch(\u0027nova.objects.PciDeviceList.get_by_compute_node\u0027,"},{"line_number":1118,"context_line":"                return_value\u003dobjects.PciDeviceList())"},{"line_number":1119,"context_line":"    @mock.patch(\u0027nova.objects.MigrationContext.get_by_instance_uuid\u0027,"}],"source_content_type":"text/x-python","patch_set":18,"id":"7faddb67_cba029a8","line":1116,"updated":"2019-09-05 13:09:00.000000000","message":"we don\u0027t need this mock","commit_id":"eb1366773471f004d06c51487fd670e1364bf2e6"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"a61fae10168ece6683ee6c6c1f5c91d1f2402aa4","unresolved":false,"context_lines":[{"line_number":1113,"context_line":"    @mock.patch(\u0027nova.objects.InstanceList.get_by_filters\u0027)"},{"line_number":1114,"context_line":"    @mock.patch(\u0027nova.compute.utils.is_volume_backed_instance\u0027)"},{"line_number":1115,"context_line":"    @mock.patch(\u0027nova.objects.InstancePCIRequests.get_by_instance\u0027,"},{"line_number":1116,"context_line":"                return_value\u003dobjects.InstancePCIRequests(requests\u003d[]))"},{"line_number":1117,"context_line":"    @mock.patch(\u0027nova.objects.PciDeviceList.get_by_compute_node\u0027,"},{"line_number":1118,"context_line":"                return_value\u003dobjects.PciDeviceList())"},{"line_number":1119,"context_line":"    @mock.patch(\u0027nova.objects.MigrationContext.get_by_instance_uuid\u0027,"}],"source_content_type":"text/x-python","patch_set":18,"id":"5faad753_143ac2e6","line":1116,"in_reply_to":"7faddb67_cba029a8","updated":"2019-09-06 14:41:24.000000000","message":"Done","commit_id":"eb1366773471f004d06c51487fd670e1364bf2e6"},{"author":{"_account_id":5754,"name":"Alex Xu","email":"hejie.xu@intel.com","username":"xuhj"},"change_message_id":"519b8ce55a5e435b1cdbae91a80cb215ba1ad9ed","unresolved":false,"context_lines":[{"line_number":1120,"context_line":"                return_value\u003dNone)"},{"line_number":1121,"context_line":"    @mock.patch(\u0027nova.objects.ComputeNode.get_by_host_and_nodename\u0027)"},{"line_number":1122,"context_line":"    @mock.patch(\u0027nova.objects.MigrationList.get_in_progress_by_host_and_node\u0027)"},{"line_number":1123,"context_line":"    @mock.patch(\u0027nova.objects.Instance.get_by_uuid\u0027)"},{"line_number":1124,"context_line":"    @mock.patch(\u0027nova.objects.InstanceList.get_by_host_and_node\u0027)"},{"line_number":1125,"context_line":"    def test_populate_assigned_resources(self, get_mock,"},{"line_number":1126,"context_line":"                                         get_inst_mock, migr_mock,"}],"source_content_type":"text/x-python","patch_set":18,"id":"7faddb67_aba92d8f","line":1123,"updated":"2019-09-05 13:09:00.000000000","message":"we needn\u0027t this mock also","commit_id":"eb1366773471f004d06c51487fd670e1364bf2e6"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"a61fae10168ece6683ee6c6c1f5c91d1f2402aa4","unresolved":false,"context_lines":[{"line_number":1120,"context_line":"                return_value\u003dNone)"},{"line_number":1121,"context_line":"    @mock.patch(\u0027nova.objects.ComputeNode.get_by_host_and_nodename\u0027)"},{"line_number":1122,"context_line":"    @mock.patch(\u0027nova.objects.MigrationList.get_in_progress_by_host_and_node\u0027)"},{"line_number":1123,"context_line":"    @mock.patch(\u0027nova.objects.Instance.get_by_uuid\u0027)"},{"line_number":1124,"context_line":"    @mock.patch(\u0027nova.objects.InstanceList.get_by_host_and_node\u0027)"},{"line_number":1125,"context_line":"    def test_populate_assigned_resources(self, get_mock,"},{"line_number":1126,"context_line":"                                         get_inst_mock, migr_mock,"}],"source_content_type":"text/x-python","patch_set":18,"id":"5faad753_d45e6a44","line":1123,"in_reply_to":"7faddb67_aba92d8f","updated":"2019-09-06 14:41:24.000000000","message":"I need this, for migration.instance I think.","commit_id":"eb1366773471f004d06c51487fd670e1364bf2e6"},{"author":{"_account_id":5754,"name":"Alex Xu","email":"hejie.xu@intel.com","username":"xuhj"},"change_message_id":"519b8ce55a5e435b1cdbae91a80cb215ba1ad9ed","unresolved":false,"context_lines":[{"line_number":1162,"context_line":"    @mock.patch(\u0027nova.objects.InstanceList.get_by_filters\u0027)"},{"line_number":1163,"context_line":"    @mock.patch(\u0027nova.compute.utils.is_volume_backed_instance\u0027)"},{"line_number":1164,"context_line":"    @mock.patch(\u0027nova.objects.InstancePCIRequests.get_by_instance\u0027,"},{"line_number":1165,"context_line":"                return_value\u003dobjects.InstancePCIRequests(requests\u003d[]))"},{"line_number":1166,"context_line":"    @mock.patch(\u0027nova.objects.PciDeviceList.get_by_compute_node\u0027,"},{"line_number":1167,"context_line":"                return_value\u003dobjects.PciDeviceList())"},{"line_number":1168,"context_line":"    @mock.patch(\u0027nova.objects.MigrationContext.get_by_instance_uuid\u0027,"}],"source_content_type":"text/x-python","patch_set":18,"id":"7faddb67_eb8c0536","line":1165,"updated":"2019-09-05 13:09:00.000000000","message":"ditto","commit_id":"eb1366773471f004d06c51487fd670e1364bf2e6"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"a61fae10168ece6683ee6c6c1f5c91d1f2402aa4","unresolved":false,"context_lines":[{"line_number":1162,"context_line":"    @mock.patch(\u0027nova.objects.InstanceList.get_by_filters\u0027)"},{"line_number":1163,"context_line":"    @mock.patch(\u0027nova.compute.utils.is_volume_backed_instance\u0027)"},{"line_number":1164,"context_line":"    @mock.patch(\u0027nova.objects.InstancePCIRequests.get_by_instance\u0027,"},{"line_number":1165,"context_line":"                return_value\u003dobjects.InstancePCIRequests(requests\u003d[]))"},{"line_number":1166,"context_line":"    @mock.patch(\u0027nova.objects.PciDeviceList.get_by_compute_node\u0027,"},{"line_number":1167,"context_line":"                return_value\u003dobjects.PciDeviceList())"},{"line_number":1168,"context_line":"    @mock.patch(\u0027nova.objects.MigrationContext.get_by_instance_uuid\u0027,"}],"source_content_type":"text/x-python","patch_set":18,"id":"5faad753_f42046b3","line":1165,"in_reply_to":"7faddb67_eb8c0536","updated":"2019-09-06 14:41:24.000000000","message":"Done","commit_id":"eb1366773471f004d06c51487fd670e1364bf2e6"},{"author":{"_account_id":5754,"name":"Alex Xu","email":"hejie.xu@intel.com","username":"xuhj"},"change_message_id":"519b8ce55a5e435b1cdbae91a80cb215ba1ad9ed","unresolved":false,"context_lines":[{"line_number":1169,"context_line":"                return_value\u003dNone)"},{"line_number":1170,"context_line":"    @mock.patch(\u0027nova.objects.ComputeNode.get_by_host_and_nodename\u0027)"},{"line_number":1171,"context_line":"    @mock.patch(\u0027nova.objects.MigrationList.get_in_progress_by_host_and_node\u0027)"},{"line_number":1172,"context_line":"    @mock.patch(\u0027nova.objects.Instance.get_by_uuid\u0027)"},{"line_number":1173,"context_line":"    @mock.patch(\u0027nova.objects.InstanceList.get_by_host_and_node\u0027)"},{"line_number":1174,"context_line":"    def test_check_resources_startup_success(self, get_mock,"},{"line_number":1175,"context_line":"                                             get_inst_mock, migr_mock,"}],"source_content_type":"text/x-python","patch_set":18,"id":"7faddb67_8b7f9115","line":1172,"updated":"2019-09-05 13:09:00.000000000","message":"ditto","commit_id":"eb1366773471f004d06c51487fd670e1364bf2e6"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"a61fae10168ece6683ee6c6c1f5c91d1f2402aa4","unresolved":false,"context_lines":[{"line_number":1169,"context_line":"                return_value\u003dNone)"},{"line_number":1170,"context_line":"    @mock.patch(\u0027nova.objects.ComputeNode.get_by_host_and_nodename\u0027)"},{"line_number":1171,"context_line":"    @mock.patch(\u0027nova.objects.MigrationList.get_in_progress_by_host_and_node\u0027)"},{"line_number":1172,"context_line":"    @mock.patch(\u0027nova.objects.Instance.get_by_uuid\u0027)"},{"line_number":1173,"context_line":"    @mock.patch(\u0027nova.objects.InstanceList.get_by_host_and_node\u0027)"},{"line_number":1174,"context_line":"    def test_check_resources_startup_success(self, get_mock,"},{"line_number":1175,"context_line":"                                             get_inst_mock, migr_mock,"}],"source_content_type":"text/x-python","patch_set":18,"id":"5faad753_54191a86","line":1172,"in_reply_to":"7faddb67_8b7f9115","updated":"2019-09-06 14:41:24.000000000","message":"need this for migration.instance I think","commit_id":"eb1366773471f004d06c51487fd670e1364bf2e6"},{"author":{"_account_id":5754,"name":"Alex Xu","email":"hejie.xu@intel.com","username":"xuhj"},"change_message_id":"519b8ce55a5e435b1cdbae91a80cb215ba1ad9ed","unresolved":false,"context_lines":[{"line_number":1171,"context_line":"    @mock.patch(\u0027nova.objects.MigrationList.get_in_progress_by_host_and_node\u0027)"},{"line_number":1172,"context_line":"    @mock.patch(\u0027nova.objects.Instance.get_by_uuid\u0027)"},{"line_number":1173,"context_line":"    @mock.patch(\u0027nova.objects.InstanceList.get_by_host_and_node\u0027)"},{"line_number":1174,"context_line":"    def test_check_resources_startup_success(self, get_mock,"},{"line_number":1175,"context_line":"                                             get_inst_mock, migr_mock,"},{"line_number":1176,"context_line":"                                             get_cn_mock,"},{"line_number":1177,"context_line":"                                             get_mig_ctxt_mock,"}],"source_content_type":"text/x-python","patch_set":18,"id":"7faddb67_cbdca919","line":1174,"updated":"2019-09-05 13:09:00.000000000","message":"emm....Did the above test already cover this?","commit_id":"eb1366773471f004d06c51487fd670e1364bf2e6"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"a61fae10168ece6683ee6c6c1f5c91d1f2402aa4","unresolved":false,"context_lines":[{"line_number":1171,"context_line":"    @mock.patch(\u0027nova.objects.MigrationList.get_in_progress_by_host_and_node\u0027)"},{"line_number":1172,"context_line":"    @mock.patch(\u0027nova.objects.Instance.get_by_uuid\u0027)"},{"line_number":1173,"context_line":"    @mock.patch(\u0027nova.objects.InstanceList.get_by_host_and_node\u0027)"},{"line_number":1174,"context_line":"    def test_check_resources_startup_success(self, get_mock,"},{"line_number":1175,"context_line":"                                             get_inst_mock, migr_mock,"},{"line_number":1176,"context_line":"                                             get_cn_mock,"},{"line_number":1177,"context_line":"                                             get_mig_ctxt_mock,"}],"source_content_type":"text/x-python","patch_set":18,"id":"5faad753_544b5a86","line":1174,"in_reply_to":"7faddb67_cbdca919","updated":"2019-09-06 14:41:24.000000000","message":"No, check_resources will be called when startup\u003d\u003dTrue, see line 1203","commit_id":"eb1366773471f004d06c51487fd670e1364bf2e6"},{"author":{"_account_id":5754,"name":"Alex Xu","email":"hejie.xu@intel.com","username":"xuhj"},"change_message_id":"519b8ce55a5e435b1cdbae91a80cb215ba1ad9ed","unresolved":false,"context_lines":[{"line_number":1206,"context_line":"    @mock.patch(\u0027nova.objects.InstanceList.get_by_filters\u0027)"},{"line_number":1207,"context_line":"    @mock.patch(\u0027nova.compute.utils.is_volume_backed_instance\u0027)"},{"line_number":1208,"context_line":"    @mock.patch(\u0027nova.objects.InstancePCIRequests.get_by_instance\u0027,"},{"line_number":1209,"context_line":"                return_value\u003dobjects.InstancePCIRequests(requests\u003d[]))"},{"line_number":1210,"context_line":"    @mock.patch(\u0027nova.objects.PciDeviceList.get_by_compute_node\u0027,"},{"line_number":1211,"context_line":"                return_value\u003dobjects.PciDeviceList())"},{"line_number":1212,"context_line":"    @mock.patch(\u0027nova.objects.ComputeNode.get_by_host_and_nodename\u0027)"}],"source_content_type":"text/x-python","patch_set":18,"id":"7faddb67_cbb7c9d7","line":1209,"updated":"2019-09-05 13:09:00.000000000","message":"ditto","commit_id":"eb1366773471f004d06c51487fd670e1364bf2e6"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"a61fae10168ece6683ee6c6c1f5c91d1f2402aa4","unresolved":false,"context_lines":[{"line_number":1206,"context_line":"    @mock.patch(\u0027nova.objects.InstanceList.get_by_filters\u0027)"},{"line_number":1207,"context_line":"    @mock.patch(\u0027nova.compute.utils.is_volume_backed_instance\u0027)"},{"line_number":1208,"context_line":"    @mock.patch(\u0027nova.objects.InstancePCIRequests.get_by_instance\u0027,"},{"line_number":1209,"context_line":"                return_value\u003dobjects.InstancePCIRequests(requests\u003d[]))"},{"line_number":1210,"context_line":"    @mock.patch(\u0027nova.objects.PciDeviceList.get_by_compute_node\u0027,"},{"line_number":1211,"context_line":"                return_value\u003dobjects.PciDeviceList())"},{"line_number":1212,"context_line":"    @mock.patch(\u0027nova.objects.ComputeNode.get_by_host_and_nodename\u0027)"}],"source_content_type":"text/x-python","patch_set":18,"id":"5faad753_741e9671","line":1209,"in_reply_to":"7faddb67_cbb7c9d7","updated":"2019-09-06 14:41:24.000000000","message":"Done","commit_id":"eb1366773471f004d06c51487fd670e1364bf2e6"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"ce75bfa28271513f83bb97396cdb7943a712e845","unresolved":false,"context_lines":[{"line_number":2284,"context_line":"                }"},{"line_number":2285,"context_line":"            }"},{"line_number":2286,"context_line":"        }"},{"line_number":2287,"context_line":"        expected_resources_0 \u003d {self.resource_0}"},{"line_number":2288,"context_line":"        expected_resources_1 \u003d {self.resource_1, self.resource_2}"},{"line_number":2289,"context_line":"        with mock.patch.object(self.rt, \u0027_update\u0027):"},{"line_number":2290,"context_line":"            with mock.patch.object(self.instance, \u0027save\u0027):"},{"line_number":2291,"context_line":"                self.rt.instance_claim(self.ctx, self.instance, _NODENAME,"}],"source_content_type":"text/x-python","patch_set":22,"id":"5faad753_541b231a","line":2288,"range":{"start_line":2287,"start_character":8,"end_line":2288,"end_character":65},"updated":"2019-09-09 21:45:34.000000000","message":"not sure why you need two vars here","commit_id":"34317d58cee9597773f2a54c0634784e7cfd3e01"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"399e0df6c952f87d4191add3ac05588523731e2d","unresolved":false,"context_lines":[{"line_number":2284,"context_line":"                }"},{"line_number":2285,"context_line":"            }"},{"line_number":2286,"context_line":"        }"},{"line_number":2287,"context_line":"        expected_resources_0 \u003d {self.resource_0}"},{"line_number":2288,"context_line":"        expected_resources_1 \u003d {self.resource_1, self.resource_2}"},{"line_number":2289,"context_line":"        with mock.patch.object(self.rt, \u0027_update\u0027):"},{"line_number":2290,"context_line":"            with mock.patch.object(self.instance, \u0027save\u0027):"},{"line_number":2291,"context_line":"                self.rt.instance_claim(self.ctx, self.instance, _NODENAME,"}],"source_content_type":"text/x-python","patch_set":22,"id":"5faad753_133cdcc6","line":2288,"range":{"start_line":2287,"start_character":8,"end_line":2288,"end_character":65},"in_reply_to":"5faad753_541b231a","updated":"2019-09-10 06:16:47.000000000","message":"I just want to make a diff between two resource class\nCUSTOM_RESOURCE_0 and CUSTOM_RESOURCE_1.","commit_id":"34317d58cee9597773f2a54c0634784e7cfd3e01"},{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"1535b74d0b6a52fcdb1f24954844237c5d65f303","unresolved":false,"context_lines":[{"line_number":503,"context_line":"        (self.rt, self.sched_client_mock, self.report_client_mock,"},{"line_number":504,"context_line":"         self.driver_mock) \u003d setup_rt(_HOSTNAME, virt_resources)"},{"line_number":505,"context_line":""},{"line_number":506,"context_line":"    def _setup_ptree(self, compute):"},{"line_number":507,"context_line":"        \"\"\"Set up a ProviderTree with a compute node root, and mock the"},{"line_number":508,"context_line":"        ReportClient\u0027s get_provider_tree_and_ensure_root() to return"},{"line_number":509,"context_line":"        it."}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_5bc7be46","line":506,"range":{"start_line":506,"start_character":27,"end_line":506,"end_character":34},"updated":"2019-09-10 15:10:36.000000000","message":"nit: perhaps rework this to not accept a parameter and instead use \u0027self.compute\u0027? I mean, you\u0027re relying on \u0027self.resource_N\u0027 so it\u0027s already pretty static","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"e97c52fb00a4d734e627c7d32fc7a8431c4c0fc6","unresolved":false,"context_lines":[{"line_number":503,"context_line":"        (self.rt, self.sched_client_mock, self.report_client_mock,"},{"line_number":504,"context_line":"         self.driver_mock) \u003d setup_rt(_HOSTNAME, virt_resources)"},{"line_number":505,"context_line":""},{"line_number":506,"context_line":"    def _setup_ptree(self, compute):"},{"line_number":507,"context_line":"        \"\"\"Set up a ProviderTree with a compute node root, and mock the"},{"line_number":508,"context_line":"        ReportClient\u0027s get_provider_tree_and_ensure_root() to return"},{"line_number":509,"context_line":"        it."}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_bdb81c2a","line":506,"range":{"start_line":506,"start_character":27,"end_line":506,"end_character":34},"in_reply_to":"5faad753_5bc7be46","updated":"2019-09-11 08:13:28.000000000","message":"I will use these resources many times，so I would like to make them static,  then I don\u0027t need to create them every time.\n\nIf I want a different resource, it\u0027s simple, just create new resources and update the provider tree.","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"1535b74d0b6a52fcdb1f24954844237c5d65f303","unresolved":false,"context_lines":[{"line_number":1101,"context_line":"                                                 actual_resources))"},{"line_number":1102,"context_line":"        update_mock.assert_called_once()"},{"line_number":1103,"context_line":""},{"line_number":1104,"context_line":"    @mock.patch(\u0027nova.compute.utils.is_volume_backed_instance\u0027)"},{"line_number":1105,"context_line":"    @mock.patch(\u0027nova.objects.PciDeviceList.get_by_compute_node\u0027,"},{"line_number":1106,"context_line":"                return_value\u003dobjects.PciDeviceList())"},{"line_number":1107,"context_line":"    @mock.patch(\u0027nova.objects.MigrationContext.get_by_instance_uuid\u0027,"}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_bb31120e","line":1104,"range":{"start_line":1104,"start_character":62,"end_line":1104,"end_character":63},"updated":"2019-09-10 15:10:36.000000000","message":"Try:\n\n  new\u003dmock.Mock(return_value\u003dFalse)\n\nand remove the \u0027bfv_check_mock\u0027 parameter","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"e97c52fb00a4d734e627c7d32fc7a8431c4c0fc6","unresolved":false,"context_lines":[{"line_number":1101,"context_line":"                                                 actual_resources))"},{"line_number":1102,"context_line":"        update_mock.assert_called_once()"},{"line_number":1103,"context_line":""},{"line_number":1104,"context_line":"    @mock.patch(\u0027nova.compute.utils.is_volume_backed_instance\u0027)"},{"line_number":1105,"context_line":"    @mock.patch(\u0027nova.objects.PciDeviceList.get_by_compute_node\u0027,"},{"line_number":1106,"context_line":"                return_value\u003dobjects.PciDeviceList())"},{"line_number":1107,"context_line":"    @mock.patch(\u0027nova.objects.MigrationContext.get_by_instance_uuid\u0027,"}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_18937ea5","line":1104,"range":{"start_line":1104,"start_character":62,"end_line":1104,"end_character":63},"in_reply_to":"5faad753_bb31120e","updated":"2019-09-11 08:13:28.000000000","message":"Done","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"1535b74d0b6a52fcdb1f24954844237c5d65f303","unresolved":false,"context_lines":[{"line_number":1103,"context_line":""},{"line_number":1104,"context_line":"    @mock.patch(\u0027nova.compute.utils.is_volume_backed_instance\u0027)"},{"line_number":1105,"context_line":"    @mock.patch(\u0027nova.objects.PciDeviceList.get_by_compute_node\u0027,"},{"line_number":1106,"context_line":"                return_value\u003dobjects.PciDeviceList())"},{"line_number":1107,"context_line":"    @mock.patch(\u0027nova.objects.MigrationContext.get_by_instance_uuid\u0027,"},{"line_number":1108,"context_line":"                return_value\u003dNone)"},{"line_number":1109,"context_line":"    @mock.patch(\u0027nova.objects.ComputeNode.get_by_host_and_nodename\u0027)"}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_db664e2a","line":1106,"range":{"start_line":1106,"start_character":16,"end_line":1106,"end_character":52},"updated":"2019-09-10 15:10:36.000000000","message":"Try:\n\n  new\u003dmock.Mock(return_value\u003dobjects.PciDeviceList())\n\nand remove the \u0027pci_mock\u0027 parameter","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"e97c52fb00a4d734e627c7d32fc7a8431c4c0fc6","unresolved":false,"context_lines":[{"line_number":1103,"context_line":""},{"line_number":1104,"context_line":"    @mock.patch(\u0027nova.compute.utils.is_volume_backed_instance\u0027)"},{"line_number":1105,"context_line":"    @mock.patch(\u0027nova.objects.PciDeviceList.get_by_compute_node\u0027,"},{"line_number":1106,"context_line":"                return_value\u003dobjects.PciDeviceList())"},{"line_number":1107,"context_line":"    @mock.patch(\u0027nova.objects.MigrationContext.get_by_instance_uuid\u0027,"},{"line_number":1108,"context_line":"                return_value\u003dNone)"},{"line_number":1109,"context_line":"    @mock.patch(\u0027nova.objects.ComputeNode.get_by_host_and_nodename\u0027)"}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_f897828f","line":1106,"range":{"start_line":1106,"start_character":16,"end_line":1106,"end_character":52},"in_reply_to":"5faad753_db664e2a","updated":"2019-09-11 08:13:28.000000000","message":"Done","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"1535b74d0b6a52fcdb1f24954844237c5d65f303","unresolved":false,"context_lines":[{"line_number":1105,"context_line":"    @mock.patch(\u0027nova.objects.PciDeviceList.get_by_compute_node\u0027,"},{"line_number":1106,"context_line":"                return_value\u003dobjects.PciDeviceList())"},{"line_number":1107,"context_line":"    @mock.patch(\u0027nova.objects.MigrationContext.get_by_instance_uuid\u0027,"},{"line_number":1108,"context_line":"                return_value\u003dNone)"},{"line_number":1109,"context_line":"    @mock.patch(\u0027nova.objects.ComputeNode.get_by_host_and_nodename\u0027)"},{"line_number":1110,"context_line":"    @mock.patch(\u0027nova.objects.MigrationList.get_in_progress_by_host_and_node\u0027)"},{"line_number":1111,"context_line":"    @mock.patch(\u0027nova.objects.Instance.get_by_uuid\u0027)"}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_bb63521a","line":1108,"range":{"start_line":1108,"start_character":16,"end_line":1108,"end_character":33},"updated":"2019-09-10 15:10:36.000000000","message":"Try:\n\n  new\u003dmock.Mock(return_value\u003dNone)\n\nand remove the \u0027get_mig_ctxt_mock\u0027 param","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"e97c52fb00a4d734e627c7d32fc7a8431c4c0fc6","unresolved":false,"context_lines":[{"line_number":1105,"context_line":"    @mock.patch(\u0027nova.objects.PciDeviceList.get_by_compute_node\u0027,"},{"line_number":1106,"context_line":"                return_value\u003dobjects.PciDeviceList())"},{"line_number":1107,"context_line":"    @mock.patch(\u0027nova.objects.MigrationContext.get_by_instance_uuid\u0027,"},{"line_number":1108,"context_line":"                return_value\u003dNone)"},{"line_number":1109,"context_line":"    @mock.patch(\u0027nova.objects.ComputeNode.get_by_host_and_nodename\u0027)"},{"line_number":1110,"context_line":"    @mock.patch(\u0027nova.objects.MigrationList.get_in_progress_by_host_and_node\u0027)"},{"line_number":1111,"context_line":"    @mock.patch(\u0027nova.objects.Instance.get_by_uuid\u0027)"}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_5881f649","line":1108,"range":{"start_line":1108,"start_character":16,"end_line":1108,"end_character":33},"in_reply_to":"5faad753_bb63521a","updated":"2019-09-11 08:13:28.000000000","message":"Done","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"1535b74d0b6a52fcdb1f24954844237c5d65f303","unresolved":false,"context_lines":[{"line_number":1110,"context_line":"    @mock.patch(\u0027nova.objects.MigrationList.get_in_progress_by_host_and_node\u0027)"},{"line_number":1111,"context_line":"    @mock.patch(\u0027nova.objects.Instance.get_by_uuid\u0027)"},{"line_number":1112,"context_line":"    @mock.patch(\u0027nova.objects.InstanceList.get_by_host_and_node\u0027)"},{"line_number":1113,"context_line":"    def test_populate_assigned_resources(self, get_mock,"},{"line_number":1114,"context_line":"                                         get_inst_mock, migr_mock,"},{"line_number":1115,"context_line":"                                         get_cn_mock,"},{"line_number":1116,"context_line":"                                         get_mig_ctxt_mock,"}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_1bf9464c","line":1113,"range":{"start_line":1113,"start_character":47,"end_line":1113,"end_character":55},"updated":"2019-09-10 15:10:36.000000000","message":"mock_get_instances","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"e97c52fb00a4d734e627c7d32fc7a8431c4c0fc6","unresolved":false,"context_lines":[{"line_number":1110,"context_line":"    @mock.patch(\u0027nova.objects.MigrationList.get_in_progress_by_host_and_node\u0027)"},{"line_number":1111,"context_line":"    @mock.patch(\u0027nova.objects.Instance.get_by_uuid\u0027)"},{"line_number":1112,"context_line":"    @mock.patch(\u0027nova.objects.InstanceList.get_by_host_and_node\u0027)"},{"line_number":1113,"context_line":"    def test_populate_assigned_resources(self, get_mock,"},{"line_number":1114,"context_line":"                                         get_inst_mock, migr_mock,"},{"line_number":1115,"context_line":"                                         get_cn_mock,"},{"line_number":1116,"context_line":"                                         get_mig_ctxt_mock,"}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_387e7a6b","line":1113,"range":{"start_line":1113,"start_character":47,"end_line":1113,"end_character":55},"in_reply_to":"5faad753_1bf9464c","updated":"2019-09-11 08:13:28.000000000","message":"Done","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"1535b74d0b6a52fcdb1f24954844237c5d65f303","unresolved":false,"context_lines":[{"line_number":1111,"context_line":"    @mock.patch(\u0027nova.objects.Instance.get_by_uuid\u0027)"},{"line_number":1112,"context_line":"    @mock.patch(\u0027nova.objects.InstanceList.get_by_host_and_node\u0027)"},{"line_number":1113,"context_line":"    def test_populate_assigned_resources(self, get_mock,"},{"line_number":1114,"context_line":"                                         get_inst_mock, migr_mock,"},{"line_number":1115,"context_line":"                                         get_cn_mock,"},{"line_number":1116,"context_line":"                                         get_mig_ctxt_mock,"},{"line_number":1117,"context_line":"                                         pci_mock,"}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_7b9f1a03","line":1114,"range":{"start_line":1114,"start_character":41,"end_line":1114,"end_character":54},"updated":"2019-09-10 15:10:36.000000000","message":"mock_get_instance","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"1535b74d0b6a52fcdb1f24954844237c5d65f303","unresolved":false,"context_lines":[{"line_number":1111,"context_line":"    @mock.patch(\u0027nova.objects.Instance.get_by_uuid\u0027)"},{"line_number":1112,"context_line":"    @mock.patch(\u0027nova.objects.InstanceList.get_by_host_and_node\u0027)"},{"line_number":1113,"context_line":"    def test_populate_assigned_resources(self, get_mock,"},{"line_number":1114,"context_line":"                                         get_inst_mock, migr_mock,"},{"line_number":1115,"context_line":"                                         get_cn_mock,"},{"line_number":1116,"context_line":"                                         get_mig_ctxt_mock,"},{"line_number":1117,"context_line":"                                         pci_mock,"}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_fb922af6","line":1114,"range":{"start_line":1114,"start_character":56,"end_line":1114,"end_character":65},"updated":"2019-09-10 15:10:36.000000000","message":"mock_get_migrations\n\netc.","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"e97c52fb00a4d734e627c7d32fc7a8431c4c0fc6","unresolved":false,"context_lines":[{"line_number":1111,"context_line":"    @mock.patch(\u0027nova.objects.Instance.get_by_uuid\u0027)"},{"line_number":1112,"context_line":"    @mock.patch(\u0027nova.objects.InstanceList.get_by_host_and_node\u0027)"},{"line_number":1113,"context_line":"    def test_populate_assigned_resources(self, get_mock,"},{"line_number":1114,"context_line":"                                         get_inst_mock, migr_mock,"},{"line_number":1115,"context_line":"                                         get_cn_mock,"},{"line_number":1116,"context_line":"                                         get_mig_ctxt_mock,"},{"line_number":1117,"context_line":"                                         pci_mock,"}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_7884f25e","line":1114,"range":{"start_line":1114,"start_character":41,"end_line":1114,"end_character":54},"in_reply_to":"5faad753_7b9f1a03","updated":"2019-09-11 08:13:28.000000000","message":"Done","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"e97c52fb00a4d734e627c7d32fc7a8431c4c0fc6","unresolved":false,"context_lines":[{"line_number":1111,"context_line":"    @mock.patch(\u0027nova.objects.Instance.get_by_uuid\u0027)"},{"line_number":1112,"context_line":"    @mock.patch(\u0027nova.objects.InstanceList.get_by_host_and_node\u0027)"},{"line_number":1113,"context_line":"    def test_populate_assigned_resources(self, get_mock,"},{"line_number":1114,"context_line":"                                         get_inst_mock, migr_mock,"},{"line_number":1115,"context_line":"                                         get_cn_mock,"},{"line_number":1116,"context_line":"                                         get_mig_ctxt_mock,"},{"line_number":1117,"context_line":"                                         pci_mock,"}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_98876e62","line":1114,"range":{"start_line":1114,"start_character":56,"end_line":1114,"end_character":65},"in_reply_to":"5faad753_fb922af6","updated":"2019-09-11 08:13:28.000000000","message":"Done","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"1535b74d0b6a52fcdb1f24954844237c5d65f303","unresolved":false,"context_lines":[{"line_number":1115,"context_line":"                                         get_cn_mock,"},{"line_number":1116,"context_line":"                                         get_mig_ctxt_mock,"},{"line_number":1117,"context_line":"                                         pci_mock,"},{"line_number":1118,"context_line":"                                         bfv_check_mock):"},{"line_number":1119,"context_line":"        self._setup_rt()"},{"line_number":1120,"context_line":"        migr_obj \u003d migr_obj \u003d _MIGRATION_FIXTURES[\u0027source-and-dest\u0027]"},{"line_number":1121,"context_line":"        inst_uuid \u003d migr_obj.instance_uuid"}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_bbf03269","line":1118,"updated":"2019-09-10 15:10:36.000000000","message":"This whole test is extremely dense and very tough to read. A docstring and some inline comments explaining what you\u0027re trying to do would help massively. Ditto for the rest of these","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"e97c52fb00a4d734e627c7d32fc7a8431c4c0fc6","unresolved":false,"context_lines":[{"line_number":1115,"context_line":"                                         get_cn_mock,"},{"line_number":1116,"context_line":"                                         get_mig_ctxt_mock,"},{"line_number":1117,"context_line":"                                         pci_mock,"},{"line_number":1118,"context_line":"                                         bfv_check_mock):"},{"line_number":1119,"context_line":"        self._setup_rt()"},{"line_number":1120,"context_line":"        migr_obj \u003d migr_obj \u003d _MIGRATION_FIXTURES[\u0027source-and-dest\u0027]"},{"line_number":1121,"context_line":"        inst_uuid \u003d migr_obj.instance_uuid"}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_5d12480b","line":1118,"in_reply_to":"5faad753_bbf03269","updated":"2019-09-11 08:13:28.000000000","message":"Done","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"1535b74d0b6a52fcdb1f24954844237c5d65f303","unresolved":false,"context_lines":[{"line_number":1117,"context_line":"                                         pci_mock,"},{"line_number":1118,"context_line":"                                         bfv_check_mock):"},{"line_number":1119,"context_line":"        self._setup_rt()"},{"line_number":1120,"context_line":"        migr_obj \u003d migr_obj \u003d _MIGRATION_FIXTURES[\u0027source-and-dest\u0027]"},{"line_number":1121,"context_line":"        inst_uuid \u003d migr_obj.instance_uuid"},{"line_number":1122,"context_line":"        resizing_inst \u003d _MIGRATION_INSTANCE_FIXTURES[inst_uuid].obj_clone()"},{"line_number":1123,"context_line":"        mig_ctxt \u003d _MIGRATION_CONTEXT_FIXTURES[resizing_inst.uuid]"}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_5b681e20","line":1120,"range":{"start_line":1120,"start_character":19,"end_line":1120,"end_character":29},"updated":"2019-09-10 15:10:36.000000000","message":"drop","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"e97c52fb00a4d734e627c7d32fc7a8431c4c0fc6","unresolved":false,"context_lines":[{"line_number":1117,"context_line":"                                         pci_mock,"},{"line_number":1118,"context_line":"                                         bfv_check_mock):"},{"line_number":1119,"context_line":"        self._setup_rt()"},{"line_number":1120,"context_line":"        migr_obj \u003d migr_obj \u003d _MIGRATION_FIXTURES[\u0027source-and-dest\u0027]"},{"line_number":1121,"context_line":"        inst_uuid \u003d migr_obj.instance_uuid"},{"line_number":1122,"context_line":"        resizing_inst \u003d _MIGRATION_INSTANCE_FIXTURES[inst_uuid].obj_clone()"},{"line_number":1123,"context_line":"        mig_ctxt \u003d _MIGRATION_CONTEXT_FIXTURES[resizing_inst.uuid]"}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_1df4d0ce","line":1120,"range":{"start_line":1120,"start_character":19,"end_line":1120,"end_character":29},"in_reply_to":"5faad753_5b681e20","updated":"2019-09-11 08:13:28.000000000","message":"Done","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"1535b74d0b6a52fcdb1f24954844237c5d65f303","unresolved":false,"context_lines":[{"line_number":1127,"context_line":"                objects\u003d[self.resource_2])"},{"line_number":1128,"context_line":"        resizing_inst.migration_context \u003d mig_ctxt"},{"line_number":1129,"context_line":"        inst \u003d _INSTANCE_FIXTURES[0]"},{"line_number":1130,"context_line":"        inst.resources \u003d objects.ResourceList(objects\u003d[self.resource_0])"},{"line_number":1131,"context_line":""},{"line_number":1132,"context_line":"        get_mock.return_value \u003d [inst, resizing_inst]"},{"line_number":1133,"context_line":"        get_inst_mock.return_value \u003d resizing_inst"}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_db408d38","line":1130,"updated":"2019-09-10 15:10:36.000000000","message":"so what I think is happening is that you\u0027re creating a compute node record, a migration record and two instance records, such that it looks like the compute node has two instances, one of which is in the middle of a same-host cold migration. Because of the migration, one of these instances (resizing_inst) is consuming two resources, \u0027resource_1\u0027 and \u0027resource_2\u0027, while the other is only consuming one resource, \u0027resource_0\u0027.\n\nIs that correct? If so, please annotate the test with a description of each step.","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"e97c52fb00a4d734e627c7d32fc7a8431c4c0fc6","unresolved":false,"context_lines":[{"line_number":1127,"context_line":"                objects\u003d[self.resource_2])"},{"line_number":1128,"context_line":"        resizing_inst.migration_context \u003d mig_ctxt"},{"line_number":1129,"context_line":"        inst \u003d _INSTANCE_FIXTURES[0]"},{"line_number":1130,"context_line":"        inst.resources \u003d objects.ResourceList(objects\u003d[self.resource_0])"},{"line_number":1131,"context_line":""},{"line_number":1132,"context_line":"        get_mock.return_value \u003d [inst, resizing_inst]"},{"line_number":1133,"context_line":"        get_inst_mock.return_value \u003d resizing_inst"}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_3d0f4ce2","line":1130,"in_reply_to":"5faad753_db408d38","updated":"2019-09-11 08:13:28.000000000","message":"correct.","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"1535b74d0b6a52fcdb1f24954844237c5d65f303","unresolved":false,"context_lines":[{"line_number":1144,"context_line":"        self.assertEqual(expected_assigned_resources,"},{"line_number":1145,"context_line":"                         self.rt.assigned_resources)"},{"line_number":1146,"context_line":""},{"line_number":1147,"context_line":"    @mock.patch(\u0027nova.compute.utils.is_volume_backed_instance\u0027)"},{"line_number":1148,"context_line":"    @mock.patch(\u0027nova.objects.PciDeviceList.get_by_compute_node\u0027,"},{"line_number":1149,"context_line":"                return_value\u003dobjects.PciDeviceList())"},{"line_number":1150,"context_line":"    @mock.patch(\u0027nova.objects.MigrationContext.get_by_instance_uuid\u0027,"}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_1b7065a5","line":1147,"updated":"2019-09-10 15:10:36.000000000","message":"Same comments as above RE: using \u0027new\u0027","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"1535b74d0b6a52fcdb1f24954844237c5d65f303","unresolved":false,"context_lines":[{"line_number":1159,"context_line":"                                             get_mig_ctxt_mock,"},{"line_number":1160,"context_line":"                                             pci_mock,"},{"line_number":1161,"context_line":"                                             bfv_check_mock):"},{"line_number":1162,"context_line":"        self._setup_rt()"},{"line_number":1163,"context_line":"        self.rt.provider_tree \u003d self._setup_ptree(self.compute)"},{"line_number":1164,"context_line":"        migr_obj \u003d migr_obj \u003d _MIGRATION_FIXTURES[\u0027source-and-dest\u0027]"},{"line_number":1165,"context_line":"        inst_uuid \u003d migr_obj.instance_uuid"}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_dbae4de6","line":1162,"updated":"2019-09-10 15:10:36.000000000","message":"And documenting what we\u0027re trying to do here. fwict, the setup is very similar. The only difference is that one tests behavior of the call to \u0027_update_available_resources\u0027 with \u0027startup\u003dFalse\u0027 and other with \u0027startup\u003dTrue\u0027, yeah?","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"e97c52fb00a4d734e627c7d32fc7a8431c4c0fc6","unresolved":false,"context_lines":[{"line_number":1159,"context_line":"                                             get_mig_ctxt_mock,"},{"line_number":1160,"context_line":"                                             pci_mock,"},{"line_number":1161,"context_line":"                                             bfv_check_mock):"},{"line_number":1162,"context_line":"        self._setup_rt()"},{"line_number":1163,"context_line":"        self.rt.provider_tree \u003d self._setup_ptree(self.compute)"},{"line_number":1164,"context_line":"        migr_obj \u003d migr_obj \u003d _MIGRATION_FIXTURES[\u0027source-and-dest\u0027]"},{"line_number":1165,"context_line":"        inst_uuid \u003d migr_obj.instance_uuid"}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_fd21b44e","line":1162,"in_reply_to":"5faad753_dbae4de6","updated":"2019-09-11 08:13:28.000000000","message":"correct.","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"1535b74d0b6a52fcdb1f24954844237c5d65f303","unresolved":false,"context_lines":[{"line_number":1182,"context_line":"        update_mock \u003d self._update_available_resources(startup\u003dTrue)"},{"line_number":1183,"context_line":"        update_mock.assert_called_once()"},{"line_number":1184,"context_line":""},{"line_number":1185,"context_line":"    @mock.patch(\u0027nova.compute.utils.is_volume_backed_instance\u0027)"},{"line_number":1186,"context_line":"    @mock.patch(\u0027nova.objects.PciDeviceList.get_by_compute_node\u0027,"},{"line_number":1187,"context_line":"                return_value\u003dobjects.PciDeviceList())"},{"line_number":1188,"context_line":"    @mock.patch(\u0027nova.objects.ComputeNode.get_by_host_and_nodename\u0027)"}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_9b91b59c","line":1185,"updated":"2019-09-10 15:10:36.000000000","message":"Again, use \u0027new\u0027","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"e97c52fb00a4d734e627c7d32fc7a8431c4c0fc6","unresolved":false,"context_lines":[{"line_number":1182,"context_line":"        update_mock \u003d self._update_available_resources(startup\u003dTrue)"},{"line_number":1183,"context_line":"        update_mock.assert_called_once()"},{"line_number":1184,"context_line":""},{"line_number":1185,"context_line":"    @mock.patch(\u0027nova.compute.utils.is_volume_backed_instance\u0027)"},{"line_number":1186,"context_line":"    @mock.patch(\u0027nova.objects.PciDeviceList.get_by_compute_node\u0027,"},{"line_number":1187,"context_line":"                return_value\u003dobjects.PciDeviceList())"},{"line_number":1188,"context_line":"    @mock.patch(\u0027nova.objects.ComputeNode.get_by_host_and_nodename\u0027)"}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_18d85e7d","line":1185,"in_reply_to":"5faad753_9b91b59c","updated":"2019-09-11 08:13:28.000000000","message":"Done","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"1535b74d0b6a52fcdb1f24954844237c5d65f303","unresolved":false,"context_lines":[{"line_number":1190,"context_line":"    @mock.patch(\u0027nova.objects.InstanceList.get_by_host_and_node\u0027)"},{"line_number":1191,"context_line":"    def test_check_resources_startup_fail(self, get_mock, migr_mock,"},{"line_number":1192,"context_line":"                                          get_cn_mock, pci_mock,"},{"line_number":1193,"context_line":"                                          bfv_check_mock):"},{"line_number":1194,"context_line":""},{"line_number":1195,"context_line":"        resource \u003d objects.Resource(provider_uuid\u003dself.compute.uuid,"},{"line_number":1196,"context_line":"                                    resource_class\u003d\"CUSTOM_RESOURCE_0\","}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_bb8cb17f","line":1193,"updated":"2019-09-10 15:10:36.000000000","message":"And add docstrings","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"e97c52fb00a4d734e627c7d32fc7a8431c4c0fc6","unresolved":false,"context_lines":[{"line_number":1190,"context_line":"    @mock.patch(\u0027nova.objects.InstanceList.get_by_host_and_node\u0027)"},{"line_number":1191,"context_line":"    def test_check_resources_startup_fail(self, get_mock, migr_mock,"},{"line_number":1192,"context_line":"                                          get_cn_mock, pci_mock,"},{"line_number":1193,"context_line":"                                          bfv_check_mock):"},{"line_number":1194,"context_line":""},{"line_number":1195,"context_line":"        resource \u003d objects.Resource(provider_uuid\u003dself.compute.uuid,"},{"line_number":1196,"context_line":"                                    resource_class\u003d\"CUSTOM_RESOURCE_0\","}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_b8e6ea43","line":1193,"in_reply_to":"5faad753_bb8cb17f","updated":"2019-09-11 08:13:28.000000000","message":"Done","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"1535b74d0b6a52fcdb1f24954844237c5d65f303","unresolved":false,"context_lines":[{"line_number":1194,"context_line":""},{"line_number":1195,"context_line":"        resource \u003d objects.Resource(provider_uuid\u003dself.compute.uuid,"},{"line_number":1196,"context_line":"                                    resource_class\u003d\"CUSTOM_RESOURCE_0\","},{"line_number":1197,"context_line":"                                    identifier\u003d\"notfound\")"},{"line_number":1198,"context_line":"        self._setup_rt()"},{"line_number":1199,"context_line":"        self.rt.provider_tree \u003d self._setup_ptree(self.compute)"},{"line_number":1200,"context_line":""}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_5be9fd17","line":1197,"updated":"2019-09-10 15:10:36.000000000","message":"and comments","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"e97c52fb00a4d734e627c7d32fc7a8431c4c0fc6","unresolved":false,"context_lines":[{"line_number":1194,"context_line":""},{"line_number":1195,"context_line":"        resource \u003d objects.Resource(provider_uuid\u003dself.compute.uuid,"},{"line_number":1196,"context_line":"                                    resource_class\u003d\"CUSTOM_RESOURCE_0\","},{"line_number":1197,"context_line":"                                    identifier\u003d\"notfound\")"},{"line_number":1198,"context_line":"        self._setup_rt()"},{"line_number":1199,"context_line":"        self.rt.provider_tree \u003d self._setup_ptree(self.compute)"},{"line_number":1200,"context_line":""}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_d8e1662c","line":1197,"in_reply_to":"5faad753_5be9fd17","updated":"2019-09-11 08:13:28.000000000","message":"Done","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"1535b74d0b6a52fcdb1f24954844237c5d65f303","unresolved":false,"context_lines":[{"line_number":2265,"context_line":"            pci_stats_mock.assert_called_once_with([request])"},{"line_number":2266,"context_line":"            self.assertTrue(obj_base.obj_equal_prims(expected, cn))"},{"line_number":2267,"context_line":""},{"line_number":2268,"context_line":"    @mock.patch(\u0027nova.compute.utils.is_volume_backed_instance\u0027)"},{"line_number":2269,"context_line":"    @mock.patch(\u0027nova.objects.InstancePCIRequests.get_by_instance_uuid\u0027)"},{"line_number":2270,"context_line":"    @mock.patch(\u0027nova.objects.MigrationList.get_in_progress_by_host_and_node\u0027)"},{"line_number":2271,"context_line":"    def test_claim_with_resources(self, migr_mock, pci_mock, check_bfv_mock):"},{"line_number":2272,"context_line":"        pci_mock.return_value \u003d objects.InstancePCIRequests(requests\u003d[])"},{"line_number":2273,"context_line":"        check_bfv_mock.return_value \u003d False"}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_7b3ab998","line":2270,"range":{"start_line":2268,"start_character":0,"end_line":2270,"end_character":78},"updated":"2019-09-10 15:10:36.000000000","message":"use \u0027new\u0027 for all of these","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"e97c52fb00a4d734e627c7d32fc7a8431c4c0fc6","unresolved":false,"context_lines":[{"line_number":2265,"context_line":"            pci_stats_mock.assert_called_once_with([request])"},{"line_number":2266,"context_line":"            self.assertTrue(obj_base.obj_equal_prims(expected, cn))"},{"line_number":2267,"context_line":""},{"line_number":2268,"context_line":"    @mock.patch(\u0027nova.compute.utils.is_volume_backed_instance\u0027)"},{"line_number":2269,"context_line":"    @mock.patch(\u0027nova.objects.InstancePCIRequests.get_by_instance_uuid\u0027)"},{"line_number":2270,"context_line":"    @mock.patch(\u0027nova.objects.MigrationList.get_in_progress_by_host_and_node\u0027)"},{"line_number":2271,"context_line":"    def test_claim_with_resources(self, migr_mock, pci_mock, check_bfv_mock):"},{"line_number":2272,"context_line":"        pci_mock.return_value \u003d objects.InstancePCIRequests(requests\u003d[])"},{"line_number":2273,"context_line":"        check_bfv_mock.return_value \u003d False"}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_d8688688","line":2270,"range":{"start_line":2268,"start_character":0,"end_line":2270,"end_character":78},"in_reply_to":"5faad753_7b3ab998","updated":"2019-09-11 08:13:28.000000000","message":"Done","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"1535b74d0b6a52fcdb1f24954844237c5d65f303","unresolved":false,"context_lines":[{"line_number":2316,"context_line":"                }"},{"line_number":2317,"context_line":"            }"},{"line_number":2318,"context_line":"        }"},{"line_number":2319,"context_line":"        # resource_1 is assigned to other instances,"},{"line_number":2320,"context_line":"        # so only resource_2 is available"},{"line_number":2321,"context_line":"        expected_resources \u003d {self.resource_2}"},{"line_number":2322,"context_line":"        with mock.patch.object(self.rt, \u0027_update\u0027):"},{"line_number":2323,"context_line":"            with mock.patch.object(self.instance, \u0027save\u0027):"}],"source_content_type":"text/x-python","patch_set":24,"id":"5faad753_9b6d359a","line":2320,"range":{"start_line":2319,"start_character":0,"end_line":2320,"end_character":41},"updated":"2019-09-10 15:10:36.000000000","message":"++","commit_id":"7368314db9cca88c2d1aa3c36703a5282840b805"},{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"a5b38ab420df306b9a318da1bac34564c5401d29","unresolved":false,"context_lines":[{"line_number":1120,"context_line":"        # and instances will be tracked in rt.assigned_resources."},{"line_number":1121,"context_line":"        self._setup_rt()"},{"line_number":1122,"context_line":""},{"line_number":1123,"context_line":"        # resource_1 and resource_2 are assigned to resizing inst"},{"line_number":1124,"context_line":"        migr_obj \u003d _MIGRATION_FIXTURES[\u0027source-and-dest\u0027]"},{"line_number":1125,"context_line":"        inst_uuid \u003d migr_obj.instance_uuid"},{"line_number":1126,"context_line":"        resizing_inst \u003d _MIGRATION_INSTANCE_FIXTURES[inst_uuid].obj_clone()"}],"source_content_type":"text/x-python","patch_set":27,"id":"5faad753_e4e7cbe3","line":1123,"range":{"start_line":1123,"start_character":8,"end_line":1123,"end_character":65},"updated":"2019-09-11 16:35:46.000000000","message":"one instance is in the middle of being \"resized\" to the same host, meaning there are two related resource allocations - one against the instance and one against the migration record","commit_id":"3d9b11dca1884c2c8e41f00ad3fed97fb1468fbe"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"9bdb36bbb3aa0ae7bc394452cc869df7376034b4","unresolved":false,"context_lines":[{"line_number":1120,"context_line":"        # and instances will be tracked in rt.assigned_resources."},{"line_number":1121,"context_line":"        self._setup_rt()"},{"line_number":1122,"context_line":""},{"line_number":1123,"context_line":"        # resource_1 and resource_2 are assigned to resizing inst"},{"line_number":1124,"context_line":"        migr_obj \u003d _MIGRATION_FIXTURES[\u0027source-and-dest\u0027]"},{"line_number":1125,"context_line":"        inst_uuid \u003d migr_obj.instance_uuid"},{"line_number":1126,"context_line":"        resizing_inst \u003d _MIGRATION_INSTANCE_FIXTURES[inst_uuid].obj_clone()"}],"source_content_type":"text/x-python","patch_set":27,"id":"5faad753_e2a25a4b","line":1123,"range":{"start_line":1123,"start_character":8,"end_line":1123,"end_character":65},"in_reply_to":"5faad753_e4e7cbe3","updated":"2019-09-11 18:55:38.000000000","message":"Done","commit_id":"3d9b11dca1884c2c8e41f00ad3fed97fb1468fbe"},{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"a5b38ab420df306b9a318da1bac34564c5401d29","unresolved":false,"context_lines":[{"line_number":1130,"context_line":"        mig_ctxt.new_resources \u003d objects.ResourceList("},{"line_number":1131,"context_line":"                objects\u003d[self.resource_2])"},{"line_number":1132,"context_line":"        resizing_inst.migration_context \u003d mig_ctxt"},{"line_number":1133,"context_line":"        # resource_0 is assigned to inst"},{"line_number":1134,"context_line":"        inst \u003d _INSTANCE_FIXTURES[0]"},{"line_number":1135,"context_line":"        inst.resources \u003d objects.ResourceList(objects\u003d[self.resource_0])"},{"line_number":1136,"context_line":""}],"source_content_type":"text/x-python","patch_set":27,"id":"5faad753_c4f5ef84","line":1133,"range":{"start_line":1133,"start_character":8,"end_line":1133,"end_character":40},"updated":"2019-09-11 16:35:46.000000000","message":"the other instance is not being resized and only has the single resource allocation for itself","commit_id":"3d9b11dca1884c2c8e41f00ad3fed97fb1468fbe"},{"author":{"_account_id":23598,"name":"Zhong Luyao","email":"luyao.zhong@intel.com","username":"ZhongLuyao"},"change_message_id":"9bdb36bbb3aa0ae7bc394452cc869df7376034b4","unresolved":false,"context_lines":[{"line_number":1130,"context_line":"        mig_ctxt.new_resources \u003d objects.ResourceList("},{"line_number":1131,"context_line":"                objects\u003d[self.resource_2])"},{"line_number":1132,"context_line":"        resizing_inst.migration_context \u003d mig_ctxt"},{"line_number":1133,"context_line":"        # resource_0 is assigned to inst"},{"line_number":1134,"context_line":"        inst \u003d _INSTANCE_FIXTURES[0]"},{"line_number":1135,"context_line":"        inst.resources \u003d objects.ResourceList(objects\u003d[self.resource_0])"},{"line_number":1136,"context_line":""}],"source_content_type":"text/x-python","patch_set":27,"id":"5faad753_c29f1e01","line":1133,"range":{"start_line":1133,"start_character":8,"end_line":1133,"end_character":40},"in_reply_to":"5faad753_c4f5ef84","updated":"2019-09-11 18:55:38.000000000","message":"Done","commit_id":"3d9b11dca1884c2c8e41f00ad3fed97fb1468fbe"}]}
