)]}'
{"/COMMIT_MSG":[{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"8534a71fd6a4995007f8cefc5793946fcb9382de","unresolved":false,"context_lines":[{"line_number":4,"context_line":"Commit:     zhu.boxiang \u003czhu.boxiang@99cloud.net\u003e"},{"line_number":5,"context_line":"CommitDate: 2019-05-31 16:02:36 +0800"},{"line_number":6,"context_line":""},{"line_number":7,"context_line":"Add valid compute nodes with host and/or node in api layer"},{"line_number":8,"context_line":""},{"line_number":9,"context_line":"This patch adds valid compute nodes with host and/or node"},{"line_number":10,"context_line":"in api layer."}],"source_content_type":"text/x-gerrit-commit-message","patch_set":3,"id":"bfb3d3c7_02ce1062","line":7,"updated":"2019-05-31 13:30:49.000000000","message":"I would word this as something like, \"Validate requested host/node during server create\"","commit_id":"4454be399168773a597cb2cabf53246566d64b70"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"8534a71fd6a4995007f8cefc5793946fcb9382de","unresolved":false,"context_lines":[{"line_number":6,"context_line":""},{"line_number":7,"context_line":"Add valid compute nodes with host and/or node in api layer"},{"line_number":8,"context_line":""},{"line_number":9,"context_line":"This patch adds valid compute nodes with host and/or node"},{"line_number":10,"context_line":"in api layer."},{"line_number":11,"context_line":""},{"line_number":12,"context_line":"Change-Id: I009761162817c6ed1035d2208605268dc82d430f"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":3,"id":"bfb3d3c7_e2d3bcff","line":10,"range":{"start_line":9,"start_character":0,"end_line":10,"end_character":13},"updated":"2019-05-31 13:30:49.000000000","message":"I would also re-write this as something like:\n\n\"This change adds a method to validate a requested host\nand/or hypervisor_hostname (node) during server create.\nWe are simply checking for existence of the resource, so\nthe host is validated by checking for the HostMapping\nand the node is validated by checking for the related\nresource provider in the placement service (rather than\ntrying to find the ComputeNode in a cell which may not\nperform well in a multi-cell deployment).\n\nPart of blueprint add-host-and-hypervisor-hostname-flag-to-create-server\"","commit_id":"4454be399168773a597cb2cabf53246566d64b70"}],"nova/compute/api.py":[{"author":{"_account_id":9708,"name":"Balazs Gibizer","display_name":"gibi","email":"gibizer@gmail.com","username":"gibi"},"change_message_id":"630da68f36f29722295163d78136769e81dd9314","unresolved":false,"context_lines":[{"line_number":974,"context_line":"        im.create()"},{"line_number":975,"context_line":""},{"line_number":976,"context_line":"    @staticmethod"},{"line_number":977,"context_line":"    def _validate_host_or_node_and_return_compute_nodes("},{"line_number":978,"context_line":"            context, host\u003dNone, hypervisor_hostname\u003dNone):"},{"line_number":979,"context_line":"        \"\"\"Validate with host and/or hypervisor_hostname."},{"line_number":980,"context_line":""},{"line_number":981,"context_line":"        :param host: Target host."}],"source_content_type":"text/x-python","patch_set":2,"id":"bfb3d3c7_9c2a80d8","line":978,"range":{"start_line":977,"start_character":7,"end_line":978,"end_character":56},"updated":"2019-05-30 11:40:21.000000000","message":"It feels strange that this function can be called like _validate_host_or_node_and_return_compute_nodes(context) and it expected to does nothing. I would make the parameters mandatory instead","commit_id":"573767f9c41ccd99a150a33c469bf5a1abfa5f25"},{"author":{"_account_id":28706,"name":"Boxiang Zhu","email":"bxzhu_5355@163.com","username":"ZhuBoxiang"},"change_message_id":"2feeabe3375c81dd2a2f15435052698c9f4bff33","unresolved":false,"context_lines":[{"line_number":974,"context_line":"        im.create()"},{"line_number":975,"context_line":""},{"line_number":976,"context_line":"    @staticmethod"},{"line_number":977,"context_line":"    def _validate_host_or_node_and_return_compute_nodes("},{"line_number":978,"context_line":"            context, host\u003dNone, hypervisor_hostname\u003dNone):"},{"line_number":979,"context_line":"        \"\"\"Validate with host and/or hypervisor_hostname."},{"line_number":980,"context_line":""},{"line_number":981,"context_line":"        :param host: Target host."}],"source_content_type":"text/x-python","patch_set":2,"id":"bfb3d3c7_92a01544","line":978,"range":{"start_line":977,"start_character":7,"end_line":978,"end_character":56},"in_reply_to":"bfb3d3c7_9c2a80d8","updated":"2019-05-31 08:43:55.000000000","message":"Done","commit_id":"573767f9c41ccd99a150a33c469bf5a1abfa5f25"},{"author":{"_account_id":9708,"name":"Balazs Gibizer","display_name":"gibi","email":"gibizer@gmail.com","username":"gibi"},"change_message_id":"630da68f36f29722295163d78136769e81dd9314","unresolved":false,"context_lines":[{"line_number":976,"context_line":"    @staticmethod"},{"line_number":977,"context_line":"    def _validate_host_or_node_and_return_compute_nodes("},{"line_number":978,"context_line":"            context, host\u003dNone, hypervisor_hostname\u003dNone):"},{"line_number":979,"context_line":"        \"\"\"Validate with host and/or hypervisor_hostname."},{"line_number":980,"context_line":""},{"line_number":981,"context_line":"        :param host: Target host."},{"line_number":982,"context_line":"        :param hypervisor_hostname: Target node."}],"source_content_type":"text/x-python","patch_set":2,"id":"bfb3d3c7_7cd46ce9","line":979,"range":{"start_line":979,"start_character":11,"end_line":979,"end_character":57},"updated":"2019-05-30 11:40:21.000000000","message":"Validate the host and/or the hypervisor_hostname","commit_id":"573767f9c41ccd99a150a33c469bf5a1abfa5f25"},{"author":{"_account_id":28706,"name":"Boxiang Zhu","email":"bxzhu_5355@163.com","username":"ZhuBoxiang"},"change_message_id":"2feeabe3375c81dd2a2f15435052698c9f4bff33","unresolved":false,"context_lines":[{"line_number":976,"context_line":"    @staticmethod"},{"line_number":977,"context_line":"    def _validate_host_or_node_and_return_compute_nodes("},{"line_number":978,"context_line":"            context, host\u003dNone, hypervisor_hostname\u003dNone):"},{"line_number":979,"context_line":"        \"\"\"Validate with host and/or hypervisor_hostname."},{"line_number":980,"context_line":""},{"line_number":981,"context_line":"        :param host: Target host."},{"line_number":982,"context_line":"        :param hypervisor_hostname: Target node."}],"source_content_type":"text/x-python","patch_set":2,"id":"bfb3d3c7_b7baebbd","line":979,"range":{"start_line":979,"start_character":11,"end_line":979,"end_character":57},"in_reply_to":"bfb3d3c7_7cd46ce9","updated":"2019-05-31 08:43:55.000000000","message":"Done","commit_id":"573767f9c41ccd99a150a33c469bf5a1abfa5f25"},{"author":{"_account_id":9708,"name":"Balazs Gibizer","display_name":"gibi","email":"gibizer@gmail.com","username":"gibi"},"change_message_id":"630da68f36f29722295163d78136769e81dd9314","unresolved":false,"context_lines":[{"line_number":982,"context_line":"        :param hypervisor_hostname: Target node."},{"line_number":983,"context_line":"        :returns: List of ComputeNode object."},{"line_number":984,"context_line":"        :raises: nova.exception.ComputeHostNotFound: If we find no compute"},{"line_number":985,"context_line":"            nodes with host and/or hypervisor_hostname in all cells db, we"},{"line_number":986,"context_line":"            will raise this exception."},{"line_number":987,"context_line":"        \"\"\""},{"line_number":988,"context_line":"        load_cells()"},{"line_number":989,"context_line":""}],"source_content_type":"text/x-python","patch_set":2,"id":"bfb3d3c7_9cfcc070","line":986,"range":{"start_line":985,"start_character":70,"end_line":986,"end_character":38},"updated":"2019-05-30 11:40:21.000000000","message":"you can delete this part of the sentence as \"raises\" already express this.","commit_id":"573767f9c41ccd99a150a33c469bf5a1abfa5f25"},{"author":{"_account_id":28706,"name":"Boxiang Zhu","email":"bxzhu_5355@163.com","username":"ZhuBoxiang"},"change_message_id":"2feeabe3375c81dd2a2f15435052698c9f4bff33","unresolved":false,"context_lines":[{"line_number":982,"context_line":"        :param hypervisor_hostname: Target node."},{"line_number":983,"context_line":"        :returns: List of ComputeNode object."},{"line_number":984,"context_line":"        :raises: nova.exception.ComputeHostNotFound: If we find no compute"},{"line_number":985,"context_line":"            nodes with host and/or hypervisor_hostname in all cells db, we"},{"line_number":986,"context_line":"            will raise this exception."},{"line_number":987,"context_line":"        \"\"\""},{"line_number":988,"context_line":"        load_cells()"},{"line_number":989,"context_line":""}],"source_content_type":"text/x-python","patch_set":2,"id":"bfb3d3c7_77b0f3dd","line":986,"range":{"start_line":985,"start_character":70,"end_line":986,"end_character":38},"in_reply_to":"bfb3d3c7_9cfcc070","updated":"2019-05-31 08:43:55.000000000","message":"Done","commit_id":"573767f9c41ccd99a150a33c469bf5a1abfa5f25"},{"author":{"_account_id":9708,"name":"Balazs Gibizer","display_name":"gibi","email":"gibizer@gmail.com","username":"gibi"},"change_message_id":"630da68f36f29722295163d78136769e81dd9314","unresolved":false,"context_lines":[{"line_number":992,"context_line":"                host_mapping \u003d objects.HostMapping.get_by_host(context, host)"},{"line_number":993,"context_line":"                cells \u003d [host_mapping.cell_mapping]"},{"line_number":994,"context_line":"            except exception.HostMappingNotFound:"},{"line_number":995,"context_line":"                LOG.warning(\u0027No host-to-cell mapping found for selected \u0027"},{"line_number":996,"context_line":"                            \u0027host %(host)s.\u0027, {\u0027host\u0027: host})"},{"line_number":997,"context_line":"                cells \u003d CELLS"},{"line_number":998,"context_line":"        else:"}],"source_content_type":"text/x-python","patch_set":2,"id":"bfb3d3c7_7c422cad","line":995,"range":{"start_line":995,"start_character":63,"end_line":995,"end_character":71},"updated":"2019-05-30 11:40:21.000000000","message":"remove \"selected\"","commit_id":"573767f9c41ccd99a150a33c469bf5a1abfa5f25"},{"author":{"_account_id":28706,"name":"Boxiang Zhu","email":"bxzhu_5355@163.com","username":"ZhuBoxiang"},"change_message_id":"2feeabe3375c81dd2a2f15435052698c9f4bff33","unresolved":false,"context_lines":[{"line_number":992,"context_line":"                host_mapping \u003d objects.HostMapping.get_by_host(context, host)"},{"line_number":993,"context_line":"                cells \u003d [host_mapping.cell_mapping]"},{"line_number":994,"context_line":"            except exception.HostMappingNotFound:"},{"line_number":995,"context_line":"                LOG.warning(\u0027No host-to-cell mapping found for selected \u0027"},{"line_number":996,"context_line":"                            \u0027host %(host)s.\u0027, {\u0027host\u0027: host})"},{"line_number":997,"context_line":"                cells \u003d CELLS"},{"line_number":998,"context_line":"        else:"}],"source_content_type":"text/x-python","patch_set":2,"id":"bfb3d3c7_97b327e9","line":995,"range":{"start_line":995,"start_character":63,"end_line":995,"end_character":71},"in_reply_to":"bfb3d3c7_7c422cad","updated":"2019-05-31 08:43:55.000000000","message":"Done","commit_id":"573767f9c41ccd99a150a33c469bf5a1abfa5f25"},{"author":{"_account_id":9708,"name":"Balazs Gibizer","display_name":"gibi","email":"gibizer@gmail.com","username":"gibi"},"change_message_id":"630da68f36f29722295163d78136769e81dd9314","unresolved":false,"context_lines":[{"line_number":991,"context_line":"            try:"},{"line_number":992,"context_line":"                host_mapping \u003d objects.HostMapping.get_by_host(context, host)"},{"line_number":993,"context_line":"                cells \u003d [host_mapping.cell_mapping]"},{"line_number":994,"context_line":"            except exception.HostMappingNotFound:"},{"line_number":995,"context_line":"                LOG.warning(\u0027No host-to-cell mapping found for selected \u0027"},{"line_number":996,"context_line":"                            \u0027host %(host)s.\u0027, {\u0027host\u0027: host})"},{"line_number":997,"context_line":"                cells \u003d CELLS"},{"line_number":998,"context_line":"        else:"},{"line_number":999,"context_line":"            cells \u003d CELLS"},{"line_number":1000,"context_line":""}],"source_content_type":"text/x-python","patch_set":2,"id":"bfb3d3c7_dc5a3881","line":997,"range":{"start_line":994,"start_character":0,"end_line":997,"end_character":29},"updated":"2019-05-30 11:40:21.000000000","message":"If the requested host is not found in the db then I don\u0027t think we want to continue.","commit_id":"573767f9c41ccd99a150a33c469bf5a1abfa5f25"},{"author":{"_account_id":28706,"name":"Boxiang Zhu","email":"bxzhu_5355@163.com","username":"ZhuBoxiang"},"change_message_id":"2feeabe3375c81dd2a2f15435052698c9f4bff33","unresolved":false,"context_lines":[{"line_number":991,"context_line":"            try:"},{"line_number":992,"context_line":"                host_mapping \u003d objects.HostMapping.get_by_host(context, host)"},{"line_number":993,"context_line":"                cells \u003d [host_mapping.cell_mapping]"},{"line_number":994,"context_line":"            except exception.HostMappingNotFound:"},{"line_number":995,"context_line":"                LOG.warning(\u0027No host-to-cell mapping found for selected \u0027"},{"line_number":996,"context_line":"                            \u0027host %(host)s.\u0027, {\u0027host\u0027: host})"},{"line_number":997,"context_line":"                cells \u003d CELLS"},{"line_number":998,"context_line":"        else:"},{"line_number":999,"context_line":"            cells \u003d CELLS"},{"line_number":1000,"context_line":""}],"source_content_type":"text/x-python","patch_set":2,"id":"bfb3d3c7_57c92f56","line":997,"range":{"start_line":994,"start_character":0,"end_line":997,"end_character":29},"in_reply_to":"bfb3d3c7_dc5a3881","updated":"2019-05-31 08:43:55.000000000","message":"Done","commit_id":"573767f9c41ccd99a150a33c469bf5a1abfa5f25"},{"author":{"_account_id":9708,"name":"Balazs Gibizer","display_name":"gibi","email":"gibizer@gmail.com","username":"gibi"},"change_message_id":"630da68f36f29722295163d78136769e81dd9314","unresolved":false,"context_lines":[{"line_number":999,"context_line":"            cells \u003d CELLS"},{"line_number":1000,"context_line":""},{"line_number":1001,"context_line":"        for cell in cells:"},{"line_number":1002,"context_line":"            if cell.uuid \u003d\u003d objects.CellMapping.CELL0_UUID or cell.disabled:"},{"line_number":1003,"context_line":"                continue"},{"line_number":1004,"context_line":"            with nova_context.target_cell(context, cell) as cctxt:"},{"line_number":1005,"context_line":"                try:"}],"source_content_type":"text/x-python","patch_set":2,"id":"bfb3d3c7_5c2088f7","line":1002,"range":{"start_line":1002,"start_character":62,"end_line":1002,"end_character":75},"updated":"2019-05-30 11:40:21.000000000","message":"Why we are filtering out disabled cells?\nAnd even if we do this, then raising ComputeHostNotFound in a case when the host is found in a disable cells is misleading.","commit_id":"573767f9c41ccd99a150a33c469bf5a1abfa5f25"},{"author":{"_account_id":28706,"name":"Boxiang Zhu","email":"bxzhu_5355@163.com","username":"ZhuBoxiang"},"change_message_id":"2feeabe3375c81dd2a2f15435052698c9f4bff33","unresolved":false,"context_lines":[{"line_number":999,"context_line":"            cells \u003d CELLS"},{"line_number":1000,"context_line":""},{"line_number":1001,"context_line":"        for cell in cells:"},{"line_number":1002,"context_line":"            if cell.uuid \u003d\u003d objects.CellMapping.CELL0_UUID or cell.disabled:"},{"line_number":1003,"context_line":"                continue"},{"line_number":1004,"context_line":"            with nova_context.target_cell(context, cell) as cctxt:"},{"line_number":1005,"context_line":"                try:"}],"source_content_type":"text/x-python","patch_set":2,"id":"bfb3d3c7_37627b0b","line":1002,"range":{"start_line":1002,"start_character":62,"end_line":1002,"end_character":75},"in_reply_to":"bfb3d3c7_5c2088f7","updated":"2019-05-31 08:43:55.000000000","message":"\u003e Why we are filtering out disabled cells?\n\nDisabled cells are not available for us to create instances.\n\n \u003e And even if we do this, then raising ComputeHostNotFound in a case\n \u003e when the host is found in a disable cells is misleading.\n\nI don\u0027t think it\u0027s misleading for us. Disabled cells is unavailable so that even the required host is in disabled celss and it can\u0027t be used for use. So we raise ComputeHostNotFound exception.\n-pending-\nmy humble opinion","commit_id":"573767f9c41ccd99a150a33c469bf5a1abfa5f25"},{"author":{"_account_id":9708,"name":"Balazs Gibizer","display_name":"gibi","email":"gibizer@gmail.com","username":"gibi"},"change_message_id":"630da68f36f29722295163d78136769e81dd9314","unresolved":false,"context_lines":[{"line_number":1015,"context_line":"                except exception.ComputeHostNotFound:"},{"line_number":1016,"context_line":"                    continue"},{"line_number":1017,"context_line":""},{"line_number":1018,"context_line":"        host \u003d host if host else hypervisor_hostname"},{"line_number":1019,"context_line":"        raise exception.ComputeHostNotFound(host\u003dhost)"},{"line_number":1020,"context_line":""},{"line_number":1021,"context_line":"    def _provision_instances(self, context, instance_type, min_count,"}],"source_content_type":"text/x-python","patch_set":2,"id":"bfb3d3c7_bc6ae416","line":1018,"updated":"2019-05-30 11:40:21.000000000","message":"This can also lead to potentially misleading error message in case of host \u003d hypervisor_hostname.","commit_id":"573767f9c41ccd99a150a33c469bf5a1abfa5f25"},{"author":{"_account_id":28706,"name":"Boxiang Zhu","email":"bxzhu_5355@163.com","username":"ZhuBoxiang"},"change_message_id":"2feeabe3375c81dd2a2f15435052698c9f4bff33","unresolved":false,"context_lines":[{"line_number":1015,"context_line":"                except exception.ComputeHostNotFound:"},{"line_number":1016,"context_line":"                    continue"},{"line_number":1017,"context_line":""},{"line_number":1018,"context_line":"        host \u003d host if host else hypervisor_hostname"},{"line_number":1019,"context_line":"        raise exception.ComputeHostNotFound(host\u003dhost)"},{"line_number":1020,"context_line":""},{"line_number":1021,"context_line":"    def _provision_instances(self, context, instance_type, min_count,"}],"source_content_type":"text/x-python","patch_set":2,"id":"bfb3d3c7_97eb2776","line":1018,"in_reply_to":"bfb3d3c7_bc6ae416","updated":"2019-05-31 08:43:55.000000000","message":"\u003e This can also lead to potentially misleading error message in case\n \u003e of host \u003d hypervisor_hostname.\n\nYeah, I agree with you. But now the exception(ComputeHostNotFound) handles all the no compute nodes[0].\n\n[0] https://review.opendev.org/#/c/650877/6/nova/db/sqlalchemy/api.py","commit_id":"573767f9c41ccd99a150a33c469bf5a1abfa5f25"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"8534a71fd6a4995007f8cefc5793946fcb9382de","unresolved":false,"context_lines":[{"line_number":975,"context_line":""},{"line_number":976,"context_line":"    @staticmethod"},{"line_number":977,"context_line":"    def _validate_host_or_node(context, host, hypervisor_hostname):"},{"line_number":978,"context_line":"        \"\"\"Validate the host and/or the hypervisor_hostname."},{"line_number":979,"context_line":""},{"line_number":980,"context_line":"        :param host: Target host."},{"line_number":981,"context_line":"        :param hypervisor_hostname: Target node."}],"source_content_type":"text/x-python","patch_set":3,"id":"bfb3d3c7_22255409","line":978,"range":{"start_line":978,"start_character":8,"end_line":978,"end_character":60},"updated":"2019-05-31 13:30:49.000000000","message":"nit: this doesn\u0027t really say what it\u0027s validating, so I\u0027d mention something about how it\u0027s validating that they exist (it\u0027s not validating something like capacity - that\u0027s what the scheduler will do).","commit_id":"4454be399168773a597cb2cabf53246566d64b70"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"8534a71fd6a4995007f8cefc5793946fcb9382de","unresolved":false,"context_lines":[{"line_number":996,"context_line":"        else:"},{"line_number":997,"context_line":"            cells \u003d CELLS"},{"line_number":998,"context_line":""},{"line_number":999,"context_line":"        for cell in cells:"},{"line_number":1000,"context_line":"            if cell.uuid \u003d\u003d objects.CellMapping.CELL0_UUID or cell.disabled:"},{"line_number":1001,"context_line":"                continue"},{"line_number":1002,"context_line":"            with nova_context.target_cell(context, cell) as cctxt:"}],"source_content_type":"text/x-python","patch_set":3,"id":"bfb3d3c7_226a3419","line":999,"updated":"2019-05-31 13:30:49.000000000","message":"We discussed in the mailing list that you wouldn\u0027t iterate the cells looking for the compute node in the cells (in the case that only hypervisor_hostname is specified and not the host). You can simply lookup the resource provider from placement by name, something like this:\n\nrps \u003d self.placementclient.get(\n    \u0027/resource_providers?name\u003d%s\u0027 % hypervisor_hostname,\n    global_request_id\u003dcontext.global_id)\nif not rps[\u0027resource_providers\u0027]:\n    exception.ComputeHostNotFound(host\u003dhypervisor_hostname)\n\nWe could add a new method to SchedulerReportClient to pretty that up, but it\u0027s the general idea.","commit_id":"4454be399168773a597cb2cabf53246566d64b70"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"d680f223c8d2dfcee856c965c9b7ecd0d79dfdca","unresolved":false,"context_lines":[{"line_number":996,"context_line":"        else:"},{"line_number":997,"context_line":"            cells \u003d CELLS"},{"line_number":998,"context_line":""},{"line_number":999,"context_line":"        for cell in cells:"},{"line_number":1000,"context_line":"            if cell.uuid \u003d\u003d objects.CellMapping.CELL0_UUID or cell.disabled:"},{"line_number":1001,"context_line":"                continue"},{"line_number":1002,"context_line":"            with nova_context.target_cell(context, cell) as cctxt:"}],"source_content_type":"text/x-python","patch_set":3,"id":"9fb8cfa7_6c34784b","line":999,"in_reply_to":"9fb8cfa7_93d6bf4f","updated":"2019-06-03 19:52:01.000000000","message":"\u003e But when we try to set destination object to RequestedSpec, we still need host for destination object but we don\u0027t have it now.\n\nYou\u0027re talking about a later optimization right? I\u0027m not sure we need the host/node values on the Destination object if we have a compute node uuid field added to the Destination object which would be used to determine the in_tree value in the resources_from_request_spec code. As Alex pointed out, the scheduler will find the ComputeNode based on the node name later:\n\nhttps://github.com/openstack/nova/blob/36e75028799ef1f504b1027ea06358188ee71775/nova/scheduler/utils.py#L527\n\nThat is the performance downside I pointed out in the mailing list:\n\nhttp://lists.openstack.org/pipermail/openstack-discuss/2019-May/006518.html\n\n\u003e Note that if we do find the ComputeNode in the API, we could also \n(later?) make a change to the Destination object to add a node_uuid \nfield so we can pass that through on the RequestSpec from \nAPI-\u003econductor-\u003escheduler and that should remove the need for the \nduplicate query in the scheduler code for the in_tree logic.\n\nMy idea is that if we determine the compute node uuid here in the API, then we would have an else block to this condition:\n\nhttps://github.com/openstack/nova/blob/master/nova/scheduler/utils.py#L527\n\nwhich would set in_tree directly.\n\nI think the case of only passing hypervisor_hostname is low right now and would only be for baremetal instances and we can optimize that later. The main thing we want in the API is fast validation.","commit_id":"4454be399168773a597cb2cabf53246566d64b70"},{"author":{"_account_id":5754,"name":"Alex Xu","email":"hejie.xu@intel.com","username":"xuhj"},"change_message_id":"429fedd0e0f800c9e4d51b764bbf500d0a7fc6d8","unresolved":false,"context_lines":[{"line_number":996,"context_line":"        else:"},{"line_number":997,"context_line":"            cells \u003d CELLS"},{"line_number":998,"context_line":""},{"line_number":999,"context_line":"        for cell in cells:"},{"line_number":1000,"context_line":"            if cell.uuid \u003d\u003d objects.CellMapping.CELL0_UUID or cell.disabled:"},{"line_number":1001,"context_line":"                continue"},{"line_number":1002,"context_line":"            with nova_context.target_cell(context, cell) as cctxt:"}],"source_content_type":"text/x-python","patch_set":3,"id":"9fb8cfa7_15214fb5","line":999,"in_reply_to":"9fb8cfa7_93d6bf4f","updated":"2019-06-03 07:00:39.000000000","message":"later, we can get the host for the node at https://github.com/openstack/nova/blob/master/nova/scheduler/utils.py#L527","commit_id":"4454be399168773a597cb2cabf53246566d64b70"},{"author":{"_account_id":28706,"name":"Boxiang Zhu","email":"bxzhu_5355@163.com","username":"ZhuBoxiang"},"change_message_id":"631ce6e684987101a152b0c2487bdeb66c922a2a","unresolved":false,"context_lines":[{"line_number":996,"context_line":"        else:"},{"line_number":997,"context_line":"            cells \u003d CELLS"},{"line_number":998,"context_line":""},{"line_number":999,"context_line":"        for cell in cells:"},{"line_number":1000,"context_line":"            if cell.uuid \u003d\u003d objects.CellMapping.CELL0_UUID or cell.disabled:"},{"line_number":1001,"context_line":"                continue"},{"line_number":1002,"context_line":"            with nova_context.target_cell(context, cell) as cctxt:"}],"source_content_type":"text/x-python","patch_set":3,"id":"9fb8cfa7_93d6bf4f","line":999,"in_reply_to":"bfb3d3c7_226a3419","updated":"2019-06-01 05:17:25.000000000","message":"Hi matt, I thought about the scene that we only specify the hypervisor_hostname(node) again. Even we can lookup the resource provider from placement by name and we can judge whether the compute nodes exist. But when we try to set destination object to RequestedSpec, we still need host for destination object but we don\u0027t have it now. We only can get it by iterating the cells to look for it.\nIs my understanding wrong?","commit_id":"4454be399168773a597cb2cabf53246566d64b70"},{"author":{"_account_id":27336,"name":"XiaojueGuan","email":"xiaojueguan@gmail.com","username":"XiaojueGuan"},"change_message_id":"b93eb329203c511896ec5d1ccdaa717099ad0bbd","unresolved":false,"context_lines":[{"line_number":973,"context_line":"        br.create()"},{"line_number":974,"context_line":"        im.create()"},{"line_number":975,"context_line":""},{"line_number":976,"context_line":"    def _validate_host_or_node(self, context, host, hypervisor_hostname):"},{"line_number":977,"context_line":"        \"\"\"Check whether compute nodes exist by validating the host"},{"line_number":978,"context_line":"        and/or the hypervisor_hostname. There are three scenes:"},{"line_number":979,"context_line":"        1. If only host is supplied, we can lookup the HostMapping in"}],"source_content_type":"text/x-python","patch_set":4,"id":"9fb8cfa7_e3b617da","line":976,"range":{"start_line":976,"start_character":8,"end_line":976,"end_character":30},"updated":"2019-06-05 07:35:51.000000000","message":"i am confused when will we invoke the function","commit_id":"43366743b1d82d13c73fc8cc25c254f1a187e5fe"},{"author":{"_account_id":27336,"name":"XiaojueGuan","email":"xiaojueguan@gmail.com","username":"XiaojueGuan"},"change_message_id":"b93eb329203c511896ec5d1ccdaa717099ad0bbd","unresolved":false,"context_lines":[{"line_number":973,"context_line":"        br.create()"},{"line_number":974,"context_line":"        im.create()"},{"line_number":975,"context_line":""},{"line_number":976,"context_line":"    def _validate_host_or_node(self, context, host, hypervisor_hostname):"},{"line_number":977,"context_line":"        \"\"\"Check whether compute nodes exist by validating the host"},{"line_number":978,"context_line":"        and/or the hypervisor_hostname. There are three scenes:"},{"line_number":979,"context_line":"        1. If only host is supplied, we can lookup the HostMapping in"}],"source_content_type":"text/x-python","patch_set":4,"id":"9fb8cfa7_436363dd","line":976,"range":{"start_line":976,"start_character":36,"end_line":976,"end_character":44},"updated":"2019-06-05 07:35:51.000000000","message":"may we add param spec for the context field","commit_id":"43366743b1d82d13c73fc8cc25c254f1a187e5fe"},{"author":{"_account_id":28706,"name":"Boxiang Zhu","email":"bxzhu_5355@163.com","username":"ZhuBoxiang"},"change_message_id":"2f7c549394814bf52915e1c585b1a5d4f5abc84c","unresolved":false,"context_lines":[{"line_number":973,"context_line":"        br.create()"},{"line_number":974,"context_line":"        im.create()"},{"line_number":975,"context_line":""},{"line_number":976,"context_line":"    def _validate_host_or_node(self, context, host, hypervisor_hostname):"},{"line_number":977,"context_line":"        \"\"\"Check whether compute nodes exist by validating the host"},{"line_number":978,"context_line":"        and/or the hypervisor_hostname. There are three scenes:"},{"line_number":979,"context_line":"        1. If only host is supplied, we can lookup the HostMapping in"}],"source_content_type":"text/x-python","patch_set":4,"id":"9fb8cfa7_4307e31d","line":976,"range":{"start_line":976,"start_character":36,"end_line":976,"end_character":44},"in_reply_to":"9fb8cfa7_436363dd","updated":"2019-06-05 08:10:23.000000000","message":"Done","commit_id":"43366743b1d82d13c73fc8cc25c254f1a187e5fe"},{"author":{"_account_id":28706,"name":"Boxiang Zhu","email":"bxzhu_5355@163.com","username":"ZhuBoxiang"},"change_message_id":"2f7c549394814bf52915e1c585b1a5d4f5abc84c","unresolved":false,"context_lines":[{"line_number":973,"context_line":"        br.create()"},{"line_number":974,"context_line":"        im.create()"},{"line_number":975,"context_line":""},{"line_number":976,"context_line":"    def _validate_host_or_node(self, context, host, hypervisor_hostname):"},{"line_number":977,"context_line":"        \"\"\"Check whether compute nodes exist by validating the host"},{"line_number":978,"context_line":"        and/or the hypervisor_hostname. There are three scenes:"},{"line_number":979,"context_line":"        1. If only host is supplied, we can lookup the HostMapping in"}],"source_content_type":"text/x-python","patch_set":4,"id":"9fb8cfa7_ef17d944","line":976,"range":{"start_line":976,"start_character":8,"end_line":976,"end_character":30},"in_reply_to":"9fb8cfa7_e3b617da","updated":"2019-06-05 08:10:23.000000000","message":"We will use the function here[0].\n\n[0] https://review.opendev.org/#/c/645520/23/nova/compute/api.py","commit_id":"43366743b1d82d13c73fc8cc25c254f1a187e5fe"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"a847c808701c9d4509e07e3abb7d50a0cefc2ef0","unresolved":false,"context_lines":[{"line_number":973,"context_line":"        br.create()"},{"line_number":974,"context_line":"        im.create()"},{"line_number":975,"context_line":""},{"line_number":976,"context_line":"    def _validate_host_or_node(self, context, host, hypervisor_hostname):"},{"line_number":977,"context_line":"        \"\"\"Check whether compute nodes exist by validating the host"},{"line_number":978,"context_line":"        and/or the hypervisor_hostname. There are three scenes:"},{"line_number":979,"context_line":"        1. If only host is supplied, we can lookup the HostMapping in"}],"source_content_type":"text/x-python","patch_set":4,"id":"9fb8cfa7_b50c953b","line":976,"range":{"start_line":976,"start_character":8,"end_line":976,"end_character":30},"in_reply_to":"9fb8cfa7_ef17d944","updated":"2019-06-07 20:20:48.000000000","message":"I asked that this validation change be split off from the bigger API change that adds the change to the request schema, docs, API samples tests, etc. It\u0027s easier to review in isolation when you break a large change into smaller pieces in a series.","commit_id":"43366743b1d82d13c73fc8cc25c254f1a187e5fe"},{"author":{"_account_id":6167,"name":"Ken\u0027ichi Ohmichi","email":"ken1ohmichi@gmail.com","username":"oomichi"},"change_message_id":"0db2a91548e290f4671122fe0bf6687e0f3ca5d8","unresolved":false,"context_lines":[{"line_number":986,"context_line":""},{"line_number":987,"context_line":"        :param host: Target host."},{"line_number":988,"context_line":"        :param hypervisor_hostname: Target node."},{"line_number":989,"context_line":"        :returns: List of ComputeNode object."},{"line_number":990,"context_line":"        :raises: nova.exception.ComputeHostNotFound: We find no compute"},{"line_number":991,"context_line":"            nodes with host and/or hypervisor_hostname."},{"line_number":992,"context_line":"        \"\"\""}],"source_content_type":"text/x-python","patch_set":4,"id":"9fb8cfa7_3e7e8ae4","line":989,"range":{"start_line":989,"start_character":0,"end_line":989,"end_character":45},"updated":"2019-06-04 21:47:52.000000000","message":"This function doesn\u0027t seem to return it.","commit_id":"43366743b1d82d13c73fc8cc25c254f1a187e5fe"},{"author":{"_account_id":28706,"name":"Boxiang Zhu","email":"bxzhu_5355@163.com","username":"ZhuBoxiang"},"change_message_id":"2f7c549394814bf52915e1c585b1a5d4f5abc84c","unresolved":false,"context_lines":[{"line_number":986,"context_line":""},{"line_number":987,"context_line":"        :param host: Target host."},{"line_number":988,"context_line":"        :param hypervisor_hostname: Target node."},{"line_number":989,"context_line":"        :returns: List of ComputeNode object."},{"line_number":990,"context_line":"        :raises: nova.exception.ComputeHostNotFound: We find no compute"},{"line_number":991,"context_line":"            nodes with host and/or hypervisor_hostname."},{"line_number":992,"context_line":"        \"\"\""}],"source_content_type":"text/x-python","patch_set":4,"id":"9fb8cfa7_e304d77d","line":989,"range":{"start_line":989,"start_character":0,"end_line":989,"end_character":45},"in_reply_to":"9fb8cfa7_3e7e8ae4","updated":"2019-06-05 08:10:23.000000000","message":"Done","commit_id":"43366743b1d82d13c73fc8cc25c254f1a187e5fe"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"947e900040cb6452b87f7dd485477b3459210dc8","unresolved":false,"context_lines":[{"line_number":954,"context_line":""},{"line_number":955,"context_line":"    def _validate_host_or_node(self, context, host, hypervisor_hostname):"},{"line_number":956,"context_line":"        \"\"\"Check whether compute nodes exist by validating the host"},{"line_number":957,"context_line":"        and/or the hypervisor_hostname. There are three scenes:"},{"line_number":958,"context_line":"        1. If only host is supplied, we can lookup the HostMapping in"},{"line_number":959,"context_line":"        the API DB."},{"line_number":960,"context_line":"        2. If only node is supplied, we can query a resource provider"}],"source_content_type":"text/x-python","patch_set":6,"id":"9fb8cfa7_f52bed7e","line":957,"range":{"start_line":957,"start_character":56,"end_line":957,"end_character":62},"updated":"2019-06-07 20:36:19.000000000","message":"\"cases\" or \"scenarios\"","commit_id":"c69ca3ef7da3782ac1388bbcc8ec502abdc70307"},{"author":{"_account_id":28706,"name":"Boxiang Zhu","email":"bxzhu_5355@163.com","username":"ZhuBoxiang"},"change_message_id":"52723c56bdc4db0b9c7cd5e5c83aa5d1d5092337","unresolved":false,"context_lines":[{"line_number":954,"context_line":""},{"line_number":955,"context_line":"    def _validate_host_or_node(self, context, host, hypervisor_hostname):"},{"line_number":956,"context_line":"        \"\"\"Check whether compute nodes exist by validating the host"},{"line_number":957,"context_line":"        and/or the hypervisor_hostname. There are three scenes:"},{"line_number":958,"context_line":"        1. If only host is supplied, we can lookup the HostMapping in"},{"line_number":959,"context_line":"        the API DB."},{"line_number":960,"context_line":"        2. If only node is supplied, we can query a resource provider"}],"source_content_type":"text/x-python","patch_set":6,"id":"9fb8cfa7_60297399","line":957,"range":{"start_line":957,"start_character":56,"end_line":957,"end_character":62},"in_reply_to":"9fb8cfa7_f52bed7e","updated":"2019-06-10 06:34:09.000000000","message":"Done","commit_id":"c69ca3ef7da3782ac1388bbcc8ec502abdc70307"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"947e900040cb6452b87f7dd485477b3459210dc8","unresolved":false,"context_lines":[{"line_number":974,"context_line":"            # Only host is specified."},{"line_number":975,"context_line":"            try:"},{"line_number":976,"context_line":"                host_mapping \u003d objects.HostMapping.get_by_host(context, host)"},{"line_number":977,"context_line":"                cell \u003d host_mapping.cell_mapping"},{"line_number":978,"context_line":"            except exception.HostMappingNotFound:"},{"line_number":979,"context_line":"                LOG.warning(\u0027No host-to-cell mapping found for host \u0027"},{"line_number":980,"context_line":"                            \u0027%(host)s.\u0027, {\u0027host\u0027: host})"}],"source_content_type":"text/x-python","patch_set":6,"id":"9fb8cfa7_b55a5527","line":977,"range":{"start_line":977,"start_character":16,"end_line":977,"end_character":48},"updated":"2019-06-07 20:36:19.000000000","message":"nit: you can reserve this until later when you actually need to use it (if hypervisor_hostname is also specified).","commit_id":"c69ca3ef7da3782ac1388bbcc8ec502abdc70307"},{"author":{"_account_id":28706,"name":"Boxiang Zhu","email":"bxzhu_5355@163.com","username":"ZhuBoxiang"},"change_message_id":"52723c56bdc4db0b9c7cd5e5c83aa5d1d5092337","unresolved":false,"context_lines":[{"line_number":974,"context_line":"            # Only host is specified."},{"line_number":975,"context_line":"            try:"},{"line_number":976,"context_line":"                host_mapping \u003d objects.HostMapping.get_by_host(context, host)"},{"line_number":977,"context_line":"                cell \u003d host_mapping.cell_mapping"},{"line_number":978,"context_line":"            except exception.HostMappingNotFound:"},{"line_number":979,"context_line":"                LOG.warning(\u0027No host-to-cell mapping found for host \u0027"},{"line_number":980,"context_line":"                            \u0027%(host)s.\u0027, {\u0027host\u0027: host})"}],"source_content_type":"text/x-python","patch_set":6,"id":"9fb8cfa7_001c3776","line":977,"range":{"start_line":977,"start_character":16,"end_line":977,"end_character":48},"in_reply_to":"9fb8cfa7_b55a5527","updated":"2019-06-10 06:34:09.000000000","message":"Done","commit_id":"c69ca3ef7da3782ac1388bbcc8ec502abdc70307"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"947e900040cb6452b87f7dd485477b3459210dc8","unresolved":false,"context_lines":[{"line_number":982,"context_line":"            # Both host and node are specified."},{"line_number":983,"context_line":"            if hypervisor_hostname:"},{"line_number":984,"context_line":"                with nova_context.target_cell(context, cell) as cctxt:"},{"line_number":985,"context_line":"                    objects.ComputeNode.get_by_host_and_nodename("},{"line_number":986,"context_line":"                        cctxt, host, hypervisor_hostname)"},{"line_number":987,"context_line":"        elif hypervisor_hostname:"},{"line_number":988,"context_line":"            # Only node is specified."}],"source_content_type":"text/x-python","patch_set":6,"id":"9fb8cfa7_154b2159","line":985,"updated":"2019-06-07 20:36:19.000000000","message":"I would add a comment here that we are intentionally not storing the return value into a variable, this is only used as an existence check.","commit_id":"c69ca3ef7da3782ac1388bbcc8ec502abdc70307"},{"author":{"_account_id":28706,"name":"Boxiang Zhu","email":"bxzhu_5355@163.com","username":"ZhuBoxiang"},"change_message_id":"52723c56bdc4db0b9c7cd5e5c83aa5d1d5092337","unresolved":false,"context_lines":[{"line_number":982,"context_line":"            # Both host and node are specified."},{"line_number":983,"context_line":"            if hypervisor_hostname:"},{"line_number":984,"context_line":"                with nova_context.target_cell(context, cell) as cctxt:"},{"line_number":985,"context_line":"                    objects.ComputeNode.get_by_host_and_nodename("},{"line_number":986,"context_line":"                        cctxt, host, hypervisor_hostname)"},{"line_number":987,"context_line":"        elif hypervisor_hostname:"},{"line_number":988,"context_line":"            # Only node is specified."}],"source_content_type":"text/x-python","patch_set":6,"id":"9fb8cfa7_c0113f5f","line":985,"in_reply_to":"9fb8cfa7_154b2159","updated":"2019-06-10 06:34:09.000000000","message":"Done","commit_id":"c69ca3ef7da3782ac1388bbcc8ec502abdc70307"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"947e900040cb6452b87f7dd485477b3459210dc8","unresolved":false,"context_lines":[{"line_number":987,"context_line":"        elif hypervisor_hostname:"},{"line_number":988,"context_line":"            # Only node is specified."},{"line_number":989,"context_line":"            try:"},{"line_number":990,"context_line":"                self.placementclient._get_provider_by_name("},{"line_number":991,"context_line":"                    context, hypervisor_hostname)"},{"line_number":992,"context_line":"            except exception.ResourceProviderNotFound:"},{"line_number":993,"context_line":"                raise exception.ComputeHostNotFound(host\u003dhypervisor_hostname)"}],"source_content_type":"text/x-python","patch_set":6,"id":"9fb8cfa7_b581f54c","line":990,"updated":"2019-06-07 20:36:19.000000000","message":"Unfortunately because of the @safe_connect decorator on the _get_provider_by_name method this technically could return None if there was a problem connecting to placement, like if nova-api weren\u0027t configured to talk to placement.\n\nCould we put a change before this in the series (yes, sorry) which adds a public get_provider_by_name method in SchedulerReportClient that does not use the @safe_connect decorator but simply calls _get_provider_by_name and if _get_provider_by_name returns None will raise PlacementAPIConnectFailure, just like in here:\n\nhttps://github.com/openstack/nova/blob/729bf14892631644167b0df1da89107c34c0657f/nova/scheduler/client/report.py#L2256\n\nand here:\n\nhttps://github.com/openstack/nova/blob/729bf14892631644167b0df1da89107c34c0657f/nova/scheduler/client/report.py#L2303\n\nThat PlacementAPIConnectFailure would go unhandled in the API and result in a 500 response which is what we\u0027d want since it\u0027s a server error.","commit_id":"c69ca3ef7da3782ac1388bbcc8ec502abdc70307"},{"author":{"_account_id":28706,"name":"Boxiang Zhu","email":"bxzhu_5355@163.com","username":"ZhuBoxiang"},"change_message_id":"52723c56bdc4db0b9c7cd5e5c83aa5d1d5092337","unresolved":false,"context_lines":[{"line_number":987,"context_line":"        elif hypervisor_hostname:"},{"line_number":988,"context_line":"            # Only node is specified."},{"line_number":989,"context_line":"            try:"},{"line_number":990,"context_line":"                self.placementclient._get_provider_by_name("},{"line_number":991,"context_line":"                    context, hypervisor_hostname)"},{"line_number":992,"context_line":"            except exception.ResourceProviderNotFound:"},{"line_number":993,"context_line":"                raise exception.ComputeHostNotFound(host\u003dhypervisor_hostname)"}],"source_content_type":"text/x-python","patch_set":6,"id":"9fb8cfa7_23daa54b","line":990,"in_reply_to":"9fb8cfa7_351745f0","updated":"2019-06-10 06:34:09.000000000","message":"Done","commit_id":"c69ca3ef7da3782ac1388bbcc8ec502abdc70307"},{"author":{"_account_id":28706,"name":"Boxiang Zhu","email":"bxzhu_5355@163.com","username":"ZhuBoxiang"},"change_message_id":"52723c56bdc4db0b9c7cd5e5c83aa5d1d5092337","unresolved":false,"context_lines":[{"line_number":987,"context_line":"        elif hypervisor_hostname:"},{"line_number":988,"context_line":"            # Only node is specified."},{"line_number":989,"context_line":"            try:"},{"line_number":990,"context_line":"                self.placementclient._get_provider_by_name("},{"line_number":991,"context_line":"                    context, hypervisor_hostname)"},{"line_number":992,"context_line":"            except exception.ResourceProviderNotFound:"},{"line_number":993,"context_line":"                raise exception.ComputeHostNotFound(host\u003dhypervisor_hostname)"}],"source_content_type":"text/x-python","patch_set":6,"id":"9fb8cfa7_03d5211c","line":990,"in_reply_to":"9fb8cfa7_b581f54c","updated":"2019-06-10 06:34:09.000000000","message":"Done","commit_id":"c69ca3ef7da3782ac1388bbcc8ec502abdc70307"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"aba2a9c83a78e4ec4a2a33b4c5d0332fe8a7cf0a","unresolved":false,"context_lines":[{"line_number":987,"context_line":"        elif hypervisor_hostname:"},{"line_number":988,"context_line":"            # Only node is specified."},{"line_number":989,"context_line":"            try:"},{"line_number":990,"context_line":"                self.placementclient._get_provider_by_name("},{"line_number":991,"context_line":"                    context, hypervisor_hostname)"},{"line_number":992,"context_line":"            except exception.ResourceProviderNotFound:"},{"line_number":993,"context_line":"                raise exception.ComputeHostNotFound(host\u003dhypervisor_hostname)"}],"source_content_type":"text/x-python","patch_set":6,"id":"9fb8cfa7_351745f0","line":990,"in_reply_to":"9fb8cfa7_b581f54c","updated":"2019-06-07 20:48:48.000000000","message":"You can rebase on top of this: https://review.opendev.org/664062","commit_id":"c69ca3ef7da3782ac1388bbcc8ec502abdc70307"},{"author":{"_account_id":8556,"name":"Ghanshyam Maan","display_name":"Ghanshyam Maan","email":"gmaan.os14@gmail.com","username":"ghanshyam"},"change_message_id":"f0d38eb432940207480b86b6ddb7331cdca3f8ad","unresolved":false,"context_lines":[{"line_number":980,"context_line":"                            \u0027%(host)s.\u0027, {\u0027host\u0027: host})"},{"line_number":981,"context_line":"                raise exception.ComputeHostNotFound(host\u003dhost)"},{"line_number":982,"context_line":"            # Both host and node are specified."},{"line_number":983,"context_line":"            if hypervisor_hostname:"},{"line_number":984,"context_line":"                with nova_context.target_cell(context, cell) as cctxt:"},{"line_number":985,"context_line":"                    objects.ComputeNode.get_by_host_and_nodename("},{"line_number":986,"context_line":"                        cctxt, host, hypervisor_hostname)"},{"line_number":987,"context_line":"        elif hypervisor_hostname:"},{"line_number":988,"context_line":"            # Only node is specified."},{"line_number":989,"context_line":"            try:"},{"line_number":990,"context_line":"                self.placementclient._get_provider_by_name("},{"line_number":991,"context_line":"                    context, hypervisor_hostname)"},{"line_number":992,"context_line":"            except exception.ResourceProviderNotFound:"},{"line_number":993,"context_line":"                raise exception.ComputeHostNotFound(host\u003dhypervisor_hostname)"},{"line_number":994,"context_line":""},{"line_number":995,"context_line":"    def _provision_instances(self, context, instance_type, min_count,"},{"line_number":996,"context_line":"            max_count, base_options, boot_meta, security_groups,"}],"source_content_type":"text/x-python","patch_set":6,"id":"9fb8cfa7_d9fde4b1","line":993,"range":{"start_line":983,"start_character":0,"end_line":993,"end_character":77},"updated":"2019-06-06 12:56:59.000000000","message":"can we skip these for non-baremetal case ? assuming if HostMapping is there then node will be ok. But not sure if that assumption is ok to avoid NoValidHost error.","commit_id":"c69ca3ef7da3782ac1388bbcc8ec502abdc70307"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"540cd9f050721a42aab4fc7e62ab7583b721a1b8","unresolved":false,"context_lines":[{"line_number":980,"context_line":"                            \u0027%(host)s.\u0027, {\u0027host\u0027: host})"},{"line_number":981,"context_line":"                raise exception.ComputeHostNotFound(host\u003dhost)"},{"line_number":982,"context_line":"            # Both host and node are specified."},{"line_number":983,"context_line":"            if hypervisor_hostname:"},{"line_number":984,"context_line":"                with nova_context.target_cell(context, cell) as cctxt:"},{"line_number":985,"context_line":"                    objects.ComputeNode.get_by_host_and_nodename("},{"line_number":986,"context_line":"                        cctxt, host, hypervisor_hostname)"},{"line_number":987,"context_line":"        elif hypervisor_hostname:"},{"line_number":988,"context_line":"            # Only node is specified."},{"line_number":989,"context_line":"            try:"},{"line_number":990,"context_line":"                self.placementclient._get_provider_by_name("},{"line_number":991,"context_line":"                    context, hypervisor_hostname)"},{"line_number":992,"context_line":"            except exception.ResourceProviderNotFound:"},{"line_number":993,"context_line":"                raise exception.ComputeHostNotFound(host\u003dhypervisor_hostname)"},{"line_number":994,"context_line":""},{"line_number":995,"context_line":"    def _provision_instances(self, context, instance_type, min_count,"},{"line_number":996,"context_line":"            max_count, base_options, boot_meta, security_groups,"}],"source_content_type":"text/x-python","patch_set":6,"id":"9fb8cfa7_ff08acd9","line":993,"range":{"start_line":983,"start_character":0,"end_line":993,"end_character":77},"in_reply_to":"9fb8cfa7_7914f8a0","updated":"2019-06-07 18:52:50.000000000","message":"As noted in the ML, you wouldn\u0027t know if you\u0027re doing baremetal until you get the ComputeNode and can check the hypervisor_type at which point we\u0027ve already validated whether or not the node exists.","commit_id":"c69ca3ef7da3782ac1388bbcc8ec502abdc70307"},{"author":{"_account_id":28706,"name":"Boxiang Zhu","email":"bxzhu_5355@163.com","username":"ZhuBoxiang"},"change_message_id":"40cad8de6f0011bed065e3fd15e251fcdafcdd51","unresolved":false,"context_lines":[{"line_number":980,"context_line":"                            \u0027%(host)s.\u0027, {\u0027host\u0027: host})"},{"line_number":981,"context_line":"                raise exception.ComputeHostNotFound(host\u003dhost)"},{"line_number":982,"context_line":"            # Both host and node are specified."},{"line_number":983,"context_line":"            if hypervisor_hostname:"},{"line_number":984,"context_line":"                with nova_context.target_cell(context, cell) as cctxt:"},{"line_number":985,"context_line":"                    objects.ComputeNode.get_by_host_and_nodename("},{"line_number":986,"context_line":"                        cctxt, host, hypervisor_hostname)"},{"line_number":987,"context_line":"        elif hypervisor_hostname:"},{"line_number":988,"context_line":"            # Only node is specified."},{"line_number":989,"context_line":"            try:"},{"line_number":990,"context_line":"                self.placementclient._get_provider_by_name("},{"line_number":991,"context_line":"                    context, hypervisor_hostname)"},{"line_number":992,"context_line":"            except exception.ResourceProviderNotFound:"},{"line_number":993,"context_line":"                raise exception.ComputeHostNotFound(host\u003dhypervisor_hostname)"},{"line_number":994,"context_line":""},{"line_number":995,"context_line":"    def _provision_instances(self, context, instance_type, min_count,"},{"line_number":996,"context_line":"            max_count, base_options, boot_meta, security_groups,"}],"source_content_type":"text/x-python","patch_set":6,"id":"9fb8cfa7_7914f8a0","line":993,"range":{"start_line":983,"start_character":0,"end_line":993,"end_character":77},"in_reply_to":"9fb8cfa7_d9fde4b1","updated":"2019-06-06 13:08:49.000000000","message":"No. As desribed in the function, we will have three scenes. The function is not related to non-baremetal case, it is only related with the params when we call the api.","commit_id":"c69ca3ef7da3782ac1388bbcc8ec502abdc70307"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"3145692070ef7d35681e550ede2f144d3e9d0ff5","unresolved":false,"context_lines":[{"line_number":972,"context_line":"                 API call to placement."},{"line_number":973,"context_line":"        \"\"\""},{"line_number":974,"context_line":""},{"line_number":975,"context_line":"        if host:"},{"line_number":976,"context_line":"            # Only host is specified."},{"line_number":977,"context_line":"            try:"},{"line_number":978,"context_line":"                host_mapping \u003d objects.HostMapping.get_by_host(context, host)"},{"line_number":979,"context_line":"            except exception.HostMappingNotFound:"}],"source_content_type":"text/x-python","patch_set":7,"id":"9fb8cfa7_1ebec7d4","line":976,"range":{"start_line":975,"start_character":0,"end_line":976,"end_character":37},"updated":"2019-06-10 18:55:14.000000000","message":"These don\u0027t match. Based on the code below, I think the comment is wrong.","commit_id":"e11c6e62de5d928fb51a7340a81334abb122efdc"},{"author":{"_account_id":28706,"name":"Boxiang Zhu","email":"bxzhu_5355@163.com","username":"ZhuBoxiang"},"change_message_id":"0980f1110974243c742a0ef6c88cbcd78dab86e9","unresolved":false,"context_lines":[{"line_number":972,"context_line":"                 API call to placement."},{"line_number":973,"context_line":"        \"\"\""},{"line_number":974,"context_line":""},{"line_number":975,"context_line":"        if host:"},{"line_number":976,"context_line":"            # Only host is specified."},{"line_number":977,"context_line":"            try:"},{"line_number":978,"context_line":"                host_mapping \u003d objects.HostMapping.get_by_host(context, host)"},{"line_number":979,"context_line":"            except exception.HostMappingNotFound:"}],"source_content_type":"text/x-python","patch_set":7,"id":"9fb8cfa7_b21bf9c7","line":976,"range":{"start_line":975,"start_character":0,"end_line":976,"end_character":37},"in_reply_to":"9fb8cfa7_1ebec7d4","updated":"2019-06-17 12:21:20.000000000","message":"Done","commit_id":"e11c6e62de5d928fb51a7340a81334abb122efdc"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"3145692070ef7d35681e550ede2f144d3e9d0ff5","unresolved":false,"context_lines":[{"line_number":995,"context_line":"                    context, hypervisor_hostname)"},{"line_number":996,"context_line":"            except exception.ResourceProviderNotFound:"},{"line_number":997,"context_line":"                raise exception.ComputeHostNotFound(host\u003dhypervisor_hostname)"},{"line_number":998,"context_line":"            except exception.PlacementAPIConnectFailure:"},{"line_number":999,"context_line":"                raise exception.PlacementAPIConnectFailure()"},{"line_number":1000,"context_line":""},{"line_number":1001,"context_line":"    def _provision_instances(self, context, instance_type, min_count,"},{"line_number":1002,"context_line":"            max_count, base_options, boot_meta, security_groups,"}],"source_content_type":"text/x-python","patch_set":7,"id":"9fb8cfa7_7e16e3f3","line":999,"range":{"start_line":998,"start_character":0,"end_line":999,"end_character":60},"updated":"2019-06-10 18:55:14.000000000","message":"redundant\n\nactually worse than redundant, because the second raise will mask the stack trace of the original.","commit_id":"e11c6e62de5d928fb51a7340a81334abb122efdc"},{"author":{"_account_id":6167,"name":"Ken\u0027ichi Ohmichi","email":"ken1ohmichi@gmail.com","username":"oomichi"},"change_message_id":"68db9948c8dc9b1ad92f5a413578df6943dc82e5","unresolved":false,"context_lines":[{"line_number":995,"context_line":"                    context, hypervisor_hostname)"},{"line_number":996,"context_line":"            except exception.ResourceProviderNotFound:"},{"line_number":997,"context_line":"                raise exception.ComputeHostNotFound(host\u003dhypervisor_hostname)"},{"line_number":998,"context_line":"            except exception.PlacementAPIConnectFailure:"},{"line_number":999,"context_line":"                raise exception.PlacementAPIConnectFailure()"},{"line_number":1000,"context_line":""},{"line_number":1001,"context_line":"    def _provision_instances(self, context, instance_type, min_count,"},{"line_number":1002,"context_line":"            max_count, base_options, boot_meta, security_groups,"}],"source_content_type":"text/x-python","patch_set":7,"id":"9fb8cfa7_7e9d5064","line":999,"range":{"start_line":998,"start_character":0,"end_line":999,"end_character":60},"in_reply_to":"9fb8cfa7_7e16e3f3","updated":"2019-06-12 22:16:32.000000000","message":"+1","commit_id":"e11c6e62de5d928fb51a7340a81334abb122efdc"},{"author":{"_account_id":28706,"name":"Boxiang Zhu","email":"bxzhu_5355@163.com","username":"ZhuBoxiang"},"change_message_id":"0980f1110974243c742a0ef6c88cbcd78dab86e9","unresolved":false,"context_lines":[{"line_number":995,"context_line":"                    context, hypervisor_hostname)"},{"line_number":996,"context_line":"            except exception.ResourceProviderNotFound:"},{"line_number":997,"context_line":"                raise exception.ComputeHostNotFound(host\u003dhypervisor_hostname)"},{"line_number":998,"context_line":"            except exception.PlacementAPIConnectFailure:"},{"line_number":999,"context_line":"                raise exception.PlacementAPIConnectFailure()"},{"line_number":1000,"context_line":""},{"line_number":1001,"context_line":"    def _provision_instances(self, context, instance_type, min_count,"},{"line_number":1002,"context_line":"            max_count, base_options, boot_meta, security_groups,"}],"source_content_type":"text/x-python","patch_set":7,"id":"9fb8cfa7_32ece98d","line":999,"range":{"start_line":998,"start_character":0,"end_line":999,"end_character":60},"in_reply_to":"9fb8cfa7_7e16e3f3","updated":"2019-06-17 12:21:20.000000000","message":"Done","commit_id":"e11c6e62de5d928fb51a7340a81334abb122efdc"},{"author":{"_account_id":28706,"name":"Boxiang Zhu","email":"bxzhu_5355@163.com","username":"ZhuBoxiang"},"change_message_id":"0980f1110974243c742a0ef6c88cbcd78dab86e9","unresolved":false,"context_lines":[{"line_number":995,"context_line":"                    context, hypervisor_hostname)"},{"line_number":996,"context_line":"            except exception.ResourceProviderNotFound:"},{"line_number":997,"context_line":"                raise exception.ComputeHostNotFound(host\u003dhypervisor_hostname)"},{"line_number":998,"context_line":"            except exception.PlacementAPIConnectFailure:"},{"line_number":999,"context_line":"                raise exception.PlacementAPIConnectFailure()"},{"line_number":1000,"context_line":""},{"line_number":1001,"context_line":"    def _provision_instances(self, context, instance_type, min_count,"},{"line_number":1002,"context_line":"            max_count, base_options, boot_meta, security_groups,"}],"source_content_type":"text/x-python","patch_set":7,"id":"9fb8cfa7_12e9a57e","line":999,"range":{"start_line":998,"start_character":0,"end_line":999,"end_character":60},"in_reply_to":"9fb8cfa7_7e9d5064","updated":"2019-06-17 12:21:20.000000000","message":"If we catch the PlacementAPIConnectFailure when we do _valid_host_or_node, we still raise the ComputeHostNotFound exception and log the error msg.","commit_id":"e11c6e62de5d928fb51a7340a81334abb122efdc"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"0c7976bd7c3bc6b6ac9e34fe6b13a4093db1d623","unresolved":false,"context_lines":[{"line_number":966,"context_line":"        :param context: The API request context."},{"line_number":967,"context_line":"        :param host: Target host."},{"line_number":968,"context_line":"        :param hypervisor_hostname: Target node."},{"line_number":969,"context_line":"        :raises: ComputeHostNotFound if We find no compute nodes with host"},{"line_number":970,"context_line":"                 and/or hypervisor_hostname."},{"line_number":971,"context_line":"        \"\"\""},{"line_number":972,"context_line":""}],"source_content_type":"text/x-python","patch_set":9,"id":"9fb8cfa7_590ce193","line":969,"range":{"start_line":969,"start_character":40,"end_line":969,"end_character":42},"updated":"2019-06-17 18:40:22.000000000","message":"we","commit_id":"f4a5a321e4aacc3d2e1e43bd9d677bb35d020bc5"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"03e11c2ea19168f91285adccb17ea1f84fd40d04","unresolved":false,"context_lines":[{"line_number":993,"context_line":"                    context, hypervisor_hostname)"},{"line_number":994,"context_line":"            except exception.ResourceProviderNotFound:"},{"line_number":995,"context_line":"                raise exception.ComputeHostNotFound(host\u003dhypervisor_hostname)"},{"line_number":996,"context_line":"            except exception.PlacementAPIConnectFailure as ex:"},{"line_number":997,"context_line":"                LOG.error(\"Compute host %(host)s could not be found: \""},{"line_number":998,"context_line":"                          \"%(reason)s\", {\"host\": hypervisor_hostname,"},{"line_number":999,"context_line":"                                         \"reason\": ex.format_message()})"}],"source_content_type":"text/x-python","patch_set":9,"id":"9fb8cfa7_7ccf53b0","line":996,"updated":"2019-06-17 18:51:38.000000000","message":"We should probably have a unit test for this case as well.","commit_id":"f4a5a321e4aacc3d2e1e43bd9d677bb35d020bc5"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"0c7976bd7c3bc6b6ac9e34fe6b13a4093db1d623","unresolved":false,"context_lines":[{"line_number":994,"context_line":"            except exception.ResourceProviderNotFound:"},{"line_number":995,"context_line":"                raise exception.ComputeHostNotFound(host\u003dhypervisor_hostname)"},{"line_number":996,"context_line":"            except exception.PlacementAPIConnectFailure as ex:"},{"line_number":997,"context_line":"                LOG.error(\"Compute host %(host)s could not be found: \""},{"line_number":998,"context_line":"                          \"%(reason)s\", {\"host\": hypervisor_hostname,"},{"line_number":999,"context_line":"                                         \"reason\": ex.format_message()})"},{"line_number":1000,"context_line":"                raise exception.ComputeHostNotFound(host\u003dhypervisor_hostname)"},{"line_number":1001,"context_line":""},{"line_number":1002,"context_line":"    def _provision_instances(self, context, instance_type, min_count,"},{"line_number":1003,"context_line":"            max_count, base_options, boot_meta, security_groups,"}],"source_content_type":"text/x-python","patch_set":9,"id":"9fb8cfa7_d91f71b5","line":1000,"range":{"start_line":997,"start_character":16,"end_line":1000,"end_character":77},"updated":"2019-06-17 18:40:22.000000000","message":"I think this is confusing and masks the real issue, which is a server fault communicating with another service and should legitimately result in an unhandled 500 response to the user. In other words, I don\u0027t think we need to handle PlacementAPIConnectFailure here at all and let it just pass through and will result in a 500 response.\n\nWe do sort of the same thing here if cinder is down:\n\nhttps://github.com/openstack/nova/blob/ea7293c7bed3e5c759523f8d6c69387a4bcd7b9f/nova/compute/api.py#L1547\n\nand it always drives me crazy to debug it when I\u0027m testing that code.","commit_id":"f4a5a321e4aacc3d2e1e43bd9d677bb35d020bc5"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"d764ef39e322f854555a423bc4b787c97af031b2","unresolved":false,"context_lines":[{"line_number":994,"context_line":"            except exception.ResourceProviderNotFound:"},{"line_number":995,"context_line":"                raise exception.ComputeHostNotFound(host\u003dhypervisor_hostname)"},{"line_number":996,"context_line":"            except exception.PlacementAPIConnectFailure as ex:"},{"line_number":997,"context_line":"                LOG.error(\"Compute host %(host)s could not be found: \""},{"line_number":998,"context_line":"                          \"%(reason)s\", {\"host\": hypervisor_hostname,"},{"line_number":999,"context_line":"                                         \"reason\": ex.format_message()})"},{"line_number":1000,"context_line":"                raise exception.ComputeHostNotFound(host\u003dhypervisor_hostname)"},{"line_number":1001,"context_line":""},{"line_number":1002,"context_line":"    def _provision_instances(self, context, instance_type, min_count,"},{"line_number":1003,"context_line":"            max_count, base_options, boot_meta, security_groups,"}],"source_content_type":"text/x-python","patch_set":9,"id":"9fb8cfa7_7c73d3b2","line":1000,"range":{"start_line":997,"start_character":16,"end_line":1000,"end_character":77},"in_reply_to":"9fb8cfa7_d91f71b5","updated":"2019-06-17 18:49:28.000000000","message":"I agree. PlacementAPIConnectFailure is the very definition of a 5xx. (It\u0027d be a 503 Service Unavailable if it were the n-api service; but since it\u0027s an internal service-to-service problem, 500 Internal Server Error is completely appropriate.)","commit_id":"f4a5a321e4aacc3d2e1e43bd9d677bb35d020bc5"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"b33085282b3ff41b6d433d9c8fde2dc710c3dee1","unresolved":false,"context_lines":[{"line_number":966,"context_line":"        :param context: The API request context."},{"line_number":967,"context_line":"        :param host: Target host."},{"line_number":968,"context_line":"        :param hypervisor_hostname: Target node."},{"line_number":969,"context_line":"        :raises: ComputeHostNotFound if we find no compute nodes with host"},{"line_number":970,"context_line":"                 and/or hypervisor_hostname."},{"line_number":971,"context_line":"        \"\"\""},{"line_number":972,"context_line":""}],"source_content_type":"text/x-python","patch_set":10,"id":"9fb8cfa7_6246b724","line":969,"range":{"start_line":969,"start_character":9,"end_line":969,"end_character":15},"updated":"2019-06-18 20:46:07.000000000","message":"nit: could also add that PlacementAPIConnectFailure can be raised from this method (implicitly) which is expected to result in a 500 response from the API.","commit_id":"cf670873ad9806eda31ac072eb1f19c388129b28"}],"nova/tests/unit/compute/test_compute_api.py":[{"author":{"_account_id":9708,"name":"Balazs Gibizer","display_name":"gibi","email":"gibizer@gmail.com","username":"gibi"},"change_message_id":"630da68f36f29722295163d78136769e81dd9314","unresolved":false,"context_lines":[{"line_number":6474,"context_line":"    @mock.patch(\u0027nova.objects.ComputeNodeList.get_all_by_host\u0027)"},{"line_number":6475,"context_line":"    def test__validate_host_or_node_and_return_compute_nodes(self,"},{"line_number":6476,"context_line":"        mock_get_all, mock_get_host_node, mock_get_node, mock_get_hm):"},{"line_number":6477,"context_line":"        def _varify_result(expected, result):"},{"line_number":6478,"context_line":"            self.assertEqual(len(expected), len(result))"},{"line_number":6479,"context_line":"            for expected_cn, result_cn in zip(expected, result):"},{"line_number":6480,"context_line":"                self.assertEqual(expected_cn.host, result_cn.host)"}],"source_content_type":"text/x-python","patch_set":2,"id":"bfb3d3c7_1cca101a","line":6477,"range":{"start_line":6477,"start_character":12,"end_line":6477,"end_character":26},"updated":"2019-05-30 11:40:21.000000000","message":"_verify_result","commit_id":"573767f9c41ccd99a150a33c469bf5a1abfa5f25"},{"author":{"_account_id":28706,"name":"Boxiang Zhu","email":"bxzhu_5355@163.com","username":"ZhuBoxiang"},"change_message_id":"2feeabe3375c81dd2a2f15435052698c9f4bff33","unresolved":false,"context_lines":[{"line_number":6474,"context_line":"    @mock.patch(\u0027nova.objects.ComputeNodeList.get_all_by_host\u0027)"},{"line_number":6475,"context_line":"    def test__validate_host_or_node_and_return_compute_nodes(self,"},{"line_number":6476,"context_line":"        mock_get_all, mock_get_host_node, mock_get_node, mock_get_hm):"},{"line_number":6477,"context_line":"        def _varify_result(expected, result):"},{"line_number":6478,"context_line":"            self.assertEqual(len(expected), len(result))"},{"line_number":6479,"context_line":"            for expected_cn, result_cn in zip(expected, result):"},{"line_number":6480,"context_line":"                self.assertEqual(expected_cn.host, result_cn.host)"}],"source_content_type":"text/x-python","patch_set":2,"id":"bfb3d3c7_2dfc6e6e","line":6477,"range":{"start_line":6477,"start_character":12,"end_line":6477,"end_character":26},"in_reply_to":"bfb3d3c7_1cca101a","updated":"2019-05-31 08:43:55.000000000","message":"Done","commit_id":"573767f9c41ccd99a150a33c469bf5a1abfa5f25"},{"author":{"_account_id":9708,"name":"Balazs Gibizer","display_name":"gibi","email":"gibizer@gmail.com","username":"gibi"},"change_message_id":"630da68f36f29722295163d78136769e81dd9314","unresolved":false,"context_lines":[{"line_number":6532,"context_line":"        mock_get_host_node.reset_mock()"},{"line_number":6533,"context_line":"        mock_get_hm.reset_mock()"},{"line_number":6534,"context_line":""},{"line_number":6535,"context_line":"        # Case3: call it with node"},{"line_number":6536,"context_line":"        host \u003d None"},{"line_number":6537,"context_line":"        node \u003d \u0027fake_node\u0027"},{"line_number":6538,"context_line":""}],"source_content_type":"text/x-python","patch_set":2,"id":"bfb3d3c7_9cdda0e1","line":6535,"updated":"2019-05-30 11:40:21.000000000","message":"Please make the 3 cases to 3 separate test cases.","commit_id":"573767f9c41ccd99a150a33c469bf5a1abfa5f25"},{"author":{"_account_id":28706,"name":"Boxiang Zhu","email":"bxzhu_5355@163.com","username":"ZhuBoxiang"},"change_message_id":"2feeabe3375c81dd2a2f15435052698c9f4bff33","unresolved":false,"context_lines":[{"line_number":6532,"context_line":"        mock_get_host_node.reset_mock()"},{"line_number":6533,"context_line":"        mock_get_hm.reset_mock()"},{"line_number":6534,"context_line":""},{"line_number":6535,"context_line":"        # Case3: call it with node"},{"line_number":6536,"context_line":"        host \u003d None"},{"line_number":6537,"context_line":"        node \u003d \u0027fake_node\u0027"},{"line_number":6538,"context_line":""}],"source_content_type":"text/x-python","patch_set":2,"id":"bfb3d3c7_4df7628c","line":6535,"in_reply_to":"bfb3d3c7_9cdda0e1","updated":"2019-05-31 08:43:55.000000000","message":"Done","commit_id":"573767f9c41ccd99a150a33c469bf5a1abfa5f25"},{"author":{"_account_id":6167,"name":"Ken\u0027ichi Ohmichi","email":"ken1ohmichi@gmail.com","username":"oomichi"},"change_message_id":"0db2a91548e290f4671122fe0bf6687e0f3ca5d8","unresolved":false,"context_lines":[{"line_number":6539,"context_line":""},{"line_number":6540,"context_line":"        mock_get_provider.assert_called_once_with(fake_context, \u0027fake_node\u0027)"},{"line_number":6541,"context_line":"        mock_get_host_node.assert_not_called()"},{"line_number":6542,"context_line":"        mock_get_hm.assert_not_called()"},{"line_number":6543,"context_line":""},{"line_number":6544,"context_line":""},{"line_number":6545,"context_line":"class ComputeAPIUnitTestCase(_ComputeAPIUnitTestMixIn, test.NoDBTestCase):"}],"source_content_type":"text/x-python","patch_set":4,"id":"9fb8cfa7_be691a26","line":6542,"updated":"2019-06-04 21:47:52.000000000","message":"We need 2 more test cases for 2 exception.ComputeHostNotFound patterns in _validate_host_or_node().","commit_id":"43366743b1d82d13c73fc8cc25c254f1a187e5fe"},{"author":{"_account_id":28706,"name":"Boxiang Zhu","email":"bxzhu_5355@163.com","username":"ZhuBoxiang"},"change_message_id":"2f7c549394814bf52915e1c585b1a5d4f5abc84c","unresolved":false,"context_lines":[{"line_number":6539,"context_line":""},{"line_number":6540,"context_line":"        mock_get_provider.assert_called_once_with(fake_context, \u0027fake_node\u0027)"},{"line_number":6541,"context_line":"        mock_get_host_node.assert_not_called()"},{"line_number":6542,"context_line":"        mock_get_hm.assert_not_called()"},{"line_number":6543,"context_line":""},{"line_number":6544,"context_line":""},{"line_number":6545,"context_line":"class ComputeAPIUnitTestCase(_ComputeAPIUnitTestMixIn, test.NoDBTestCase):"}],"source_content_type":"text/x-python","patch_set":4,"id":"9fb8cfa7_a30a5f23","line":6542,"in_reply_to":"9fb8cfa7_be691a26","updated":"2019-06-05 08:10:23.000000000","message":"Done.\nAdd 3 test cases for exeception.ComputeHostNotFound.","commit_id":"43366743b1d82d13c73fc8cc25c254f1a187e5fe"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"947e900040cb6452b87f7dd485477b3459210dc8","unresolved":false,"context_lines":[{"line_number":6417,"context_line":""},{"line_number":6418,"context_line":"        self.compute_api._validate_host_or_node(fake_context, host, node)"},{"line_number":6419,"context_line":"        mock_get_host_node.assert_called_once_with("},{"line_number":6420,"context_line":"            fake_context, \u0027fake-host\u0027, \u0027fake-host\u0027)"},{"line_number":6421,"context_line":"        mock_get_hm.assert_called_once_with(fake_context, \u0027fake-host\u0027)"},{"line_number":6422,"context_line":"        _get_provider_by_name.assert_not_called()"},{"line_number":6423,"context_line":""}],"source_content_type":"text/x-python","patch_set":6,"id":"9fb8cfa7_95f3910a","line":6420,"range":{"start_line":6420,"start_character":12,"end_line":6420,"end_character":24},"updated":"2019-06-07 20:36:19.000000000","message":"This doesn\u0027t seem right, because this should be the cell-targeted context. I\u0027m not sure how this is passing.","commit_id":"c69ca3ef7da3782ac1388bbcc8ec502abdc70307"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"947e900040cb6452b87f7dd485477b3459210dc8","unresolved":false,"context_lines":[{"line_number":6437,"context_line":"                          self.compute_api._validate_host_or_node,"},{"line_number":6438,"context_line":"                          fake_context, host, node)"},{"line_number":6439,"context_line":"        mock_get_host_node.assert_called_once_with("},{"line_number":6440,"context_line":"            fake_context, \u0027fake-host\u0027, \u0027fake-host\u0027)"},{"line_number":6441,"context_line":"        mock_get_hm.assert_called_once_with(fake_context, \u0027fake-host\u0027)"},{"line_number":6442,"context_line":"        _get_provider_by_name.assert_not_called()"},{"line_number":6443,"context_line":""}],"source_content_type":"text/x-python","patch_set":6,"id":"9fb8cfa7_55dd196e","line":6440,"range":{"start_line":6440,"start_character":12,"end_line":6440,"end_character":24},"updated":"2019-06-07 20:36:19.000000000","message":"same","commit_id":"c69ca3ef7da3782ac1388bbcc8ec502abdc70307"},{"author":{"_account_id":28706,"name":"Boxiang Zhu","email":"bxzhu_5355@163.com","username":"ZhuBoxiang"},"change_message_id":"52723c56bdc4db0b9c7cd5e5c83aa5d1d5092337","unresolved":false,"context_lines":[{"line_number":6441,"context_line":"        self.assertRaises(exception.ComputeHostNotFound,"},{"line_number":6442,"context_line":"                          self.compute_api._validate_host_or_node,"},{"line_number":6443,"context_line":"                          self.context, host, node)"},{"line_number":6444,"context_line":"        with context.target_cell(self.context, cells[0]) as cctxt:"},{"line_number":6445,"context_line":"            mock_get_host_node.assert_called_once_with("},{"line_number":6446,"context_line":"                cctxt, \u0027fake-host\u0027, \u0027fake-host\u0027)"},{"line_number":6447,"context_line":"        mock_get_hm.assert_called_once_with(self.context, \u0027fake-host\u0027)"}],"source_content_type":"text/x-python","patch_set":7,"id":"9fb8cfa7_6302dd0d","line":6444,"range":{"start_line":6444,"start_character":8,"end_line":6444,"end_character":66},"updated":"2019-06-10 06:34:09.000000000","message":"Add cell_context, but I do not know whether it is right?","commit_id":"e11c6e62de5d928fb51a7340a81334abb122efdc"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"0c7976bd7c3bc6b6ac9e34fe6b13a4093db1d623","unresolved":false,"context_lines":[{"line_number":1714,"context_line":"    @mock.patch.object(context, \u0027target_cell\u0027)"},{"line_number":1715,"context_line":"    def test_lookup_instance_cell_mapping(self, mock_target_cell):"},{"line_number":1716,"context_line":"        instance \u003d self._create_instance_obj()"},{"line_number":1717,"context_line":"        mock_target_cell.return_value.__enter__.return_value \u003d self.context"},{"line_number":1718,"context_line":""},{"line_number":1719,"context_line":"        inst_map \u003d objects.InstanceMapping("},{"line_number":1720,"context_line":"            cell_mapping\u003dobjects.CellMapping(database_connection\u003d\u0027\u0027,"}],"source_content_type":"text/x-python","patch_set":9,"id":"9fb8cfa7_d9577126","line":1717,"updated":"2019-06-17 18:40:22.000000000","message":"I expected us to need to do something like this.","commit_id":"f4a5a321e4aacc3d2e1e43bd9d677bb35d020bc5"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"0c7976bd7c3bc6b6ac9e34fe6b13a4093db1d623","unresolved":false,"context_lines":[{"line_number":6349,"context_line":"        host \u003d \u0027fake-host\u0027"},{"line_number":6350,"context_line":"        node \u003d \u0027fake-host\u0027"},{"line_number":6351,"context_line":""},{"line_number":6352,"context_line":"        cells \u003d objects.CellMappingList.get_all(self.context)"},{"line_number":6353,"context_line":"        mock_get_hm.return_value \u003d objects.HostMapping("},{"line_number":6354,"context_line":"            cell_mapping\u003dcells[0], host\u003dhost)"},{"line_number":6355,"context_line":""},{"line_number":6356,"context_line":"        self.compute_api._validate_host_or_node(self.context, host, node)"},{"line_number":6357,"context_line":"        with context.target_cell(self.context, cells[0]) as cctxt:"}],"source_content_type":"text/x-python","patch_set":9,"id":"9fb8cfa7_b9663d29","line":6354,"range":{"start_line":6352,"start_character":8,"end_line":6354,"end_character":45},"updated":"2019-06-17 18:40:22.000000000","message":"I don\u0027t think this is necessary if we can determine why the assertion is passing below (when it really shouldn\u0027t be).","commit_id":"f4a5a321e4aacc3d2e1e43bd9d677bb35d020bc5"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"0c7976bd7c3bc6b6ac9e34fe6b13a4093db1d623","unresolved":false,"context_lines":[{"line_number":6356,"context_line":"        self.compute_api._validate_host_or_node(self.context, host, node)"},{"line_number":6357,"context_line":"        with context.target_cell(self.context, cells[0]) as cctxt:"},{"line_number":6358,"context_line":"            mock_get_host_node.assert_called_once_with("},{"line_number":6359,"context_line":"                cctxt, \u0027fake-host\u0027, \u0027fake-host\u0027)"},{"line_number":6360,"context_line":"        mock_get_hm.assert_called_once_with(self.context, \u0027fake-host\u0027)"},{"line_number":6361,"context_line":"        mock_get_provider_by_name.assert_not_called()"},{"line_number":6362,"context_line":""}],"source_content_type":"text/x-python","patch_set":9,"id":"9fb8cfa7_99eed989","line":6359,"range":{"start_line":6359,"start_character":16,"end_line":6359,"end_character":21},"updated":"2019-06-17 18:40:22.000000000","message":"I still don\u0027t really know how this is working because target_cell yields a new RequestContext each time it\u0027s called so the cctxt that gets used in _validate_host_or_node should be different from the one used here.\n\nAnother way to show this is I made this change to your patch and the tests don\u0027t fail:\n\ndiff --git a/nova/compute/api.py b/nova/compute/api.py\nindex dfcebf1a0c..a6d91c752b 100644\n--- a/nova/compute/api.py\n+++ b/nova/compute/api.py\n@@ -985,7 +985,7 @@ class API(base.Base):\n                     # Here we only do an existence check, so we don\u0027t\n                     # need to store the return value into a variable.\n                     objects.ComputeNode.get_by_host_and_nodename(\n-                        cctxt, host, hypervisor_hostname)\n+                        context, host, hypervisor_hostname)\n         elif hypervisor_hostname:\n             # When only node is specified.\n             try:\n\n\nInterestingly if I just pass nova_context.get_admin_context() that will fail. So I wonder if the check is based on some hash or __eq__ implementation on RequestContext?","commit_id":"f4a5a321e4aacc3d2e1e43bd9d677bb35d020bc5"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"de46ff62296e4100a4d02ada3fef3918d1958c74","unresolved":false,"context_lines":[{"line_number":6356,"context_line":"        self.compute_api._validate_host_or_node(self.context, host, node)"},{"line_number":6357,"context_line":"        with context.target_cell(self.context, cells[0]) as cctxt:"},{"line_number":6358,"context_line":"            mock_get_host_node.assert_called_once_with("},{"line_number":6359,"context_line":"                cctxt, \u0027fake-host\u0027, \u0027fake-host\u0027)"},{"line_number":6360,"context_line":"        mock_get_hm.assert_called_once_with(self.context, \u0027fake-host\u0027)"},{"line_number":6361,"context_line":"        mock_get_provider_by_name.assert_not_called()"},{"line_number":6362,"context_line":""}],"source_content_type":"text/x-python","patch_set":9,"id":"9fb8cfa7_5c7ccf71","line":6359,"range":{"start_line":6359,"start_character":16,"end_line":6359,"end_character":21},"in_reply_to":"9fb8cfa7_99eed989","updated":"2019-06-17 18:48:11.000000000","message":"If I do this it\u0027s more definitive:\n\nhttp://paste.openstack.org/show/753112/\n\nAnd fails if I don\u0027t use the yielded cctxt in the code.","commit_id":"f4a5a321e4aacc3d2e1e43bd9d677bb35d020bc5"}]}
