首页 > 解决方案 > 嵌套虚拟化的 DNS 解析失败

问题描述

我正在使用以下 gRPC 设置:gRPC 1.27.1 installed through vcpkg for Visual Studio 2015。

C# 服务器- 在 Azure VM 中运行。

C++ 客户端- 在 Hyper V 映像中运行,该映像嵌套在运行服务器的 Azure VM 中。

当我尝试使用服务器机器名称连接到服务器时,我收到DNS resolution failure错误消息。如果我使用机器名称连接,我只会收到该错误。如果我使用服务器机器的内部 IP 进行连接,则连接工作正常。

以下是我收到的错误日志:

D0330 16:12:31.223000000  3616 dns_resolver_ares.cc:503] Using ares dns resolver
I0330 16:12:31.226000000  3616 init.cc:165] grpc_init(void)
I0330 16:12:31.226000000  3616 init.cc:165] grpc_init(void)
I0330 16:12:31.226000000  3616 channel_create.cc:96] grpc_insecure_channel_create(target=10.0.0.135:34226, args=010FDBB8, reserved=00000000)
I0330 16:12:31.226000000  3616 init.cc:165] grpc_init(void)
I0330 16:12:31.226000000  3616 init.cc:165] grpc_init(void)
I0330 16:12:31.227000000  3616 init.cc:212] grpc_shutdown(void)
I0330 16:12:31.227000000  3616 init.cc:212] grpc_shutdown(void)
I0330 16:12:31.227000000  3616 channel.cc:426] grpc_channel_register_call(channel=09224EF8, method=/service/Start, host=(null), reserved=00000000)
I0330 16:12:31.227000000  3616 channel.cc:426] grpc_channel_register_call(channel=09224EF8, method=/service/Shutdown, host=(null), reserved=00000000)
I0330 16:12:31.228000000  3616 channel.cc:426] grpc_channel_register_call(channel=09224EF8, method=/service/Restart, host=(null), reserved=00000000)
I0330 16:12:31.228000000  3616 channel.cc:426] grpc_channel_register_call(channel=09224EF8, method=/service/Status, host=(null), reserved=00000000)
I0330 16:12:31.228000000  3616 channel.cc:426] grpc_channel_register_call(channel=09224EF8, method=/service/DataServiceStatus, host=(null), reserved=00000000)
I0330 16:12:31.229000000  3616 channel.cc:426] grpc_channel_register_call(channel=09224EF8, method=/service/DataServicePortOverride, host=(null), reserved=00000000)
I0330 16:12:31.229000000  3616 channel.cc:426] grpc_channel_register_call(channel=09224EF8, method=/service/MachineUptimeSeconds, host=(null), reserved=00000000)
I0330 16:12:31.230000000  3616 channel_connectivity.cc:43] grpc_channel_check_connectivity_state(channel=09224EF8, try_to_connect=1)
I0330 16:12:31.230000000  3616 channel_connectivity.cc:43] grpc_channel_check_connectivity_state(channel=09224EF8, try_to_connect=1)
I0330 16:12:31.231000000  3616 init.cc:165] grpc_init(void)
I0330 16:12:31.231000000  3616 completion_queue.cc:525] grpc_completion_queue_create_internal(completion_type=0, polling_type=0)
I0330 16:12:31.231000000  3616 channel_connectivity.cc:232] grpc_channel_watch_connectivity_state(channel=09224EF8, last_observed_state=1, deadline=gpr_timespec { tv_sec: 1585581156, tv_nsec: 230938000, clock_type: 1 }, cq=02CA8F88, tag=0925CC20)
I0330 16:12:31.231000000  3616 completion_queue.cc:982] grpc_completion_queue_next(cq=02CA8F88, deadline=gpr_timespec { tv_sec: 9223372036854775807, tv_nsec: 0, clock_type: 1 }, reserved=00000000)
I0330 16:12:31.234000000  3616 subchannel.cc:1055] New connected subchannel at 0923AB60 for subchannel 0929F0C8
I0330 16:12:31.234000000  3616 completion_queue.cc:706] cq_end_op_for_next(cq=02CA8F88, tag=0925CC20, error="No Error", done=511C7A00, done_arg=02D3B090, storage=02D3B108)
I0330 16:12:31.234000000  3616 completion_queue.cc:1083] RETURN_EVENT[02CA8F88]: OP_COMPLETE: tag:0925CC20 OK
I0330 16:12:31.235000000  3616 completion_queue.cc:1425] grpc_completion_queue_destroy(cq=02CA8F88)
I0330 16:12:31.235000000  3616 completion_queue.cc:1419] grpc_completion_queue_shutdown(cq=02CA8F88)
I0330 16:12:31.235000000  3616 init.cc:212] grpc_shutdown(void)
I0330 16:12:31.235000000  3616 channel_connectivity.cc:43] grpc_channel_check_connectivity_state(channel=09224EF8, try_to_connect=1)
I0330 16:12:31.236000000  3616 channel_connectivity.cc:43] grpc_channel_check_connectivity_state(channel=09224EF8, try_to_connect=1)
I0330 16:12:31.236000000  3616 init.cc:165] grpc_init(void)
I0330 16:12:31.237000000  3616 completion_queue.cc:525] grpc_completion_queue_create_internal(completion_type=0, polling_type=0)
I0330 16:12:31.237000000  3616 channel.cc:459] grpc_channel_create_registered_call(channel=09224EF8, parent_call=00000000, propagation_mask=ffff, completion_queue=02CA91B0, registered_call_handle=0929D760, deadline=gpr_timespec { tv_sec: 9223372036854775807, tv_nsec: 0, clock_type: 1 }, reserved=00000000)
I0330 16:12:31.238000000  3616 grpc_context.cc:28] grpc_census_call_set_context(call=092708D0, census_context=00000000)
I0330 16:12:31.238000000  3616 call.cc:1967] grpc_call_start_batch(call=092708D0, ops=010FDC80, nops=6, tag=092710E8, reserved=00000000)
I0330 16:12:31.238000000  3616 call.cc:1565] ops[0]: SEND_INITIAL_METADATA(nil)
I0330 16:12:31.238000000  3616 call.cc:1565] ops[1]: SEND_MESSAGE ptr=091D18F0
I0330 16:12:31.238000000  3616 call.cc:1565] ops[2]: SEND_CLOSE_FROM_CLIENT
I0330 16:12:31.239000000  3616 call.cc:1565] ops[3]: RECV_INITIAL_METADATA ptr=010FDF1C
I0330 16:12:31.239000000  3616 call.cc:1565] ops[4]: RECV_MESSAGE ptr=0927115C
I0330 16:12:31.239000000  3616 call.cc:1565] ops[5]: RECV_STATUS_ON_CLIENT metadata=010FDF34 status=09271178 details=0927117C
I0330 16:12:31.240000000  3616 completion_queue.cc:982] grpc_completion_queue_next(cq=02CA91B0, deadline=gpr_timespec { tv_sec: 1585581156, tv_nsec: 240221700, clock_type: 1 }, reserved=00000000)
I0330 16:12:31.244000000  3616 completion_queue.cc:706] cq_end_op_for_next(cq=02CA91B0, tag=092710E8, error="No Error", done=50E52E60, done_arg=09271390, storage=092713B4)
I0330 16:12:31.245000000  3616 completion_queue.cc:1083] RETURN_EVENT[02CA91B0]: OP_COMPLETE: tag:092710E8 OK
I0330 16:12:31.246000000  3616 completion_queue.cc:1419] grpc_completion_queue_shutdown(cq=02CA91B0)
I0330 16:12:31.246000000  3616 completion_queue.cc:982] grpc_completion_queue_next(cq=02CA91B0, deadline=gpr_timespec { tv_sec: 1585581156, tv_nsec: 240221700, clock_type: 1 }, reserved=00000000)
I0330 16:12:31.247000000  3616 completion_queue.cc:1083] RETURN_EVENT[02CA91B0]: QUEUE_SHUTDOWN
I0330 16:12:31.247000000  3616 call.cc:573] grpc_call_unref(c=092708D0)
I0330 16:12:31.247000000  3616 metadata_array.cc:34] grpc_metadata_array_destroy(array=010FDF34)
I0330 16:12:31.247000000  3616 metadata_array.cc:34] grpc_metadata_array_destroy(array=010FDF1C)
I0330 16:12:31.248000000  3616 completion_queue.cc:1425] grpc_completion_queue_destroy(cq=02CA91B0)
I0330 16:12:31.248000000  3616 completion_queue.cc:1419] grpc_completion_queue_shutdown(cq=02CA91B0)
I0330 16:12:31.248000000  3616 init.cc:212] grpc_shutdown(void)
D0330 16:12:31.508000000  3616 dns_resolver_ares.cc:503] Using ares dns resolver
I0330 16:12:31.512000000  3616 init.cc:165] grpc_init(void)
I0330 16:12:31.512000000  3616 init.cc:165] grpc_init(void)
I0330 16:12:31.512000000  3616 channel_create.cc:96] grpc_insecure_channel_create(target=8again001:34226, args=010FDC68, reserved=00000000)
I0330 16:12:31.512000000  3616 init.cc:165] grpc_init(void)
I0330 16:12:31.512000000  3616 init.cc:165] grpc_init(void)
I0330 16:12:31.513000000  3616 init.cc:212] grpc_shutdown(void)
I0330 16:12:31.513000000  3616 init.cc:212] grpc_shutdown(void)
I0330 16:12:31.513000000  3616 channel.cc:426] grpc_channel_register_call(channel=091E5FB8, method=/service/HealthCheck, host=(null), reserved=00000000)
I0330 16:12:31.513000000  3616 channel.cc:426] grpc_channel_register_call(channel=091E5FB8, method=/service/UpdateProductInstallation, host=(null), reserved=00000000)
I0330 16:12:52.550000000  2600 init.cc:165] grpc_init(void)
I0330 16:12:52.550000000  2600 completion_queue.cc:525] grpc_completion_queue_create_internal(completion_type=0, polling_type=0)
I0330 16:12:52.551000000  2600 channel.cc:459] grpc_channel_create_registered_call(channel=091E5FB8, parent_call=00000000, propagation_mask=ffff, completion_queue=0E848088, registered_call_handle=091D8418, deadline=gpr_timespec { tv_sec: 9223372036854775807, tv_nsec: 0, clock_type: 1 }, reserved=00000000)
I0330 16:12:52.551000000  2600 grpc_context.cc:28] grpc_census_call_set_context(call=0EA318D0, census_context=00000000)
I0330 16:12:52.551000000  2600 call.cc:1967] grpc_call_start_batch(call=0EA318D0, ops=0E6FF0A4, nops=3, tag=0EA320E8, reserved=00000000)
I0330 16:12:52.552000000  2600 call.cc:1565] ops[0]: SEND_INITIAL_METADATA(nil)
I0330 16:12:52.552000000  2600 call.cc:1565] ops[1]: SEND_MESSAGE ptr=012B5F08
I0330 16:12:52.552000000  2600 call.cc:1565] ops[2]: SEND_CLOSE_FROM_CLIENT
I0330 16:12:52.554000000  2600 completion_queue.cc:982] grpc_completion_queue_next(cq=0E848088, deadline=gpr_timespec { tv_sec: 1585581177, tv_nsec: 554900700, clock_type: 1 }, reserved=00000000)
I0330 16:12:52.559000000  2600 completion_queue.cc:706] cq_end_op_for_next(cq=0E848088, tag=0EA320E8, error={"created":"@1585581172.559000000","description":"Failed to pick subchannel","file":"vcpkg\buildtrees\grpc\src\v1.27.1-e5ac019672\src\core\ext\filters\client_channel\client_channel.cc","file_line":3941,"referenced_errors":[{"created":"@1585581172.558000000","description":"Resolver transient failure","file":"vcpkg\buildtrees\grpc\src\v1.27.1-e5ac019672\src\core\ext\filters\client_channel\resolving_lb_policy.cc","file_line":262,"referenced_errors":[{"created":"@1585581172.558000000","description":"DNS resolution failed","file":"vcpkg\buildtrees\grpc\src\v1.27.1-e5ac019672\src\core\ext\filters\client_channel\resolver\dns\c_ares\dns_resolver_ares.cc","file_line":370,"grpc_status":14,"referenced_errors":[{"created":"@1585581172.558000000","description":"C-ares status is not ARES_SUCCESS: Domain name not found","file":"vcpkg\buildtrees\grpc\src\v1.27.1-e5ac019672\src\core\ext\filters\client_channel\resolver\dns\c_ares\grpc_ares_wrapper.cc","file_line":244,"referenced_errors":[{"created":"@1585581172.557000000","description":"C-ares status is not ARES_SUCCESS: Domain name not found","file":"vcpkg\buildtrees\grpc\src\v1.27.1-e5ac019672\src\core\ext\filters\client_channel\resolver\dns\c_ares\grpc_ares_wrapper.cc","file_line":244}]}]}]}]}, done=51831F20, done_arg=0EA32530, storage=0EA32554)
I0330 16:12:52.566000000  2600 completion_queue.cc:1083] RETURN_EVENT[0E848088]: OP_COMPLETE: tag:0EA320E8 ERROR
I0330 16:12:52.566000000  2600 call.cc:1967] grpc_call_start_batch(call=0EA318D0, ops=0E6FF1B8, nops=2, tag=0EA32418, reserved=00000000)
I0330 16:12:52.567000000  2600 call.cc:1565] ops[0]: RECV_INITIAL_METADATA ptr=0E6FF468
I0330 16:12:52.567000000  2600 call.cc:1565] ops[1]: RECV_STATUS_ON_CLIENT metadata=0E6FF480 status=0EA32438 details=0EA3243C
I0330 16:12:52.567000000  2600 completion_queue.cc:706] cq_end_op_for_next(cq=0E848088, tag=0EA32418, error="No Error", done=51831F20, done_arg=0EA325E0, storage=0EA32604)
I0330 16:12:52.567000000  2600 completion_queue.cc:1419] grpc_completion_queue_shutdown(cq=0E848088)
I0330 16:12:52.568000000  2600 completion_queue.cc:982] grpc_completion_queue_next(cq=0E848088, deadline=gpr_timespec { tv_sec: 1585581177, tv_nsec: 554900700, clock_type: 1 }, reserved=00000000)
I0330 16:12:52.568000000  2600 completion_queue.cc:1083] RETURN_EVENT[0E848088]: OP_COMPLETE: tag:0EA32418 OK
I0330 16:12:52.569000000  2600 completion_queue.cc:982] grpc_completion_queue_next(cq=0E848088, deadline=gpr_timespec { tv_sec: 1585581177, tv_nsec: 554900700, clock_type: 1 }, reserved=00000000)
I0330 16:12:52.569000000  2600 completion_queue.cc:1083] RETURN_EVENT[0E848088]: QUEUE_SHUTDOWN
I0330 16:12:52.569000000  2600 channel_connectivity.cc:43] grpc_channel_check_connectivity_state(channel=091E5FB8, try_to_connect=1)
I0330 16:12:52.570000000  2600 init.cc:165] grpc_init(void)
I0330 16:12:52.570000000  2600 completion_queue.cc:525] grpc_completion_queue_create_internal(completion_type=0, polling_type=0)
I0330 16:12:52.570000000  2600 channel_connectivity.cc:232] grpc_channel_watch_connectivity_state(channel=091E5FB8, last_observed_state=3, deadline=gpr_timespec { tv_sec: 1585581177, tv_nsec: 569630800, clock_type: 1 }, cq=0E8482B0, tag=0E8CE5D0)
I0330 16:12:52.570000000  2600 completion_queue.cc:982] grpc_completion_queue_next(cq=0E8482B0, deadline=gpr_timespec { tv_sec: 9223372036854775807, tv_nsec: 0, clock_type: 1 }, reserved=00000000)
I0330 16:12:57.577000000  1664 completion_queue.cc:706] cq_end_op_for_next(cq=0E8482B0, tag=0E8CE5D0, error={"created":"@1585581177.577000000","description":"Timed out waiting for connection state change","file":"vcpkg\buildtrees\grpc\src\v1.27.1-e5ac019672\src\core\ext\filters\client_channel\channel_connectivity.cc","file_line":142}, done=51ADF960, done_arg=02D3BC58, storage=02D3BCD0)
I0330 16:12:57.578000000  2600 completion_queue.cc:1083] RETURN_EVENT[0E8482B0]: OP_COMPLETE: tag:0E8CE5D0 ERROR
I0330 16:12:57.578000000  2600 completion_queue.cc:1425] grpc_completion_queue_destroy(cq=0E8482B0)
I0330 16:12:57.579000000  2600 completion_queue.cc:1419] grpc_completion_queue_shutdown(cq=0E8482B0)
I0330 16:12:57.579000000  2600 init.cc:212] grpc_shutdown(void)
I0330 16:12:57.579000000  2600 call.cc:573] grpc_call_unref(c=0EA318D0)
I0330 16:12:57.579000000  2600 metadata_array.cc:34] grpc_metadata_array_destroy(array=0E6FF480)
I0330 16:12:57.580000000  2600 metadata_array.cc:34] grpc_metadata_array_destroy(array=0E6FF468)
I0330 16:12:57.580000000  2600 completion_queue.cc:1425] grpc_completion_queue_destroy(cq=0E848088)
I0330 16:12:57.580000000  2600 completion_queue.cc:1419] grpc_completion_queue_shutdown(cq=0E848088)
I0330 16:12:57.580000000  2600 init.cc:212] grpc_shutdown(void)

感兴趣的线是:

I0330 16:12:52.559000000  2600 completion_queue.cc:706] cq_end_op_for_next(cq=0E848088, tag=0EA320E8, error={"created":"@1585581172.559000000","description":"Failed to pick subchannel","file":"vcpkg\buildtrees\grpc\src\v1.27.1-e5ac019672\src\core\ext\filters\client_channel\client_channel.cc","file_line":3941,"referenced_errors":[{"created":"@1585581172.558000000","description":"Resolver transient failure","file":"vcpkg\buildtrees\grpc\src\v1.27.1-e5ac019672\src\core\ext\filters\client_channel\resolving_lb_policy.cc","file_line":262,"referenced_errors":[{"created":"@1585581172.558000000","description":"DNS resolution failed","file":"vcpkg\buildtrees\grpc\src\v1.27.1-e5ac019672\src\core\ext\filters\client_channel\resolver\dns\c_ares\dns_resolver_ares.cc","file_line":370,"grpc_status":14,"referenced_errors":[{"created":"@1585581172.558000000","description":"C-ares status is not ARES_SUCCESS: Domain name not found","file":"vcpkg\buildtrees\grpc\src\v1.27.1-e5ac019672\src\core\ext\filters\client_channel\resolver\dns\c_ares\grpc_ares_wrapper.cc","file_line":244,"referenced_errors":[{"created":"@1585581172.557000000","description":"C-ares status is not ARES_SUCCESS: Domain name not found","file":"vcpkg\buildtrees\grpc\src\v1.27.1-e5ac019672\src\core\ext\filters\client_channel\resolver\dns\c_ares\grpc_ares_wrapper.cc","file_line":244}]}]}]}]}, done=51831F20, done_arg=0EA32530, storage=0EA32554)

设置GRPC_DNS_RESOLVER=native确实解决了这个问题,但是我很想知道为什么默认解析器 ( c-ares) 不起作用。是否使用 GRPC_DNS_RESOLVER=native OK 进行生产?

我认为c-aresgRPC 不需要,我可以选择不安装它。这是可能的,还是我必须使用GRPC_DNS_RESOLVER=native.

编辑:

我已经能够在一个更简单的场景中复制这个问题。

如果我只是让服务器运行并使用来自同一台机器的 C++ 客户端连接到它,而不是使用 localhost 或 localhost IP 我使用实际的机器名称,那么我会得到同样的错误。

标签: c++grpcc-ares

解决方案


推荐阅读