Tencent / spring-cloud-tencent

Spring Cloud Tencent is a Spring Cloud based Service Governance Framework provided by Tencent.
Other
3.19k stars 492 forks source link

K8S微服务grpc协议链接问题 #1223

Closed BruceAn1978 closed 9 months ago

BruceAn1978 commented 9 months ago

Describe the bug 微服务应用发版至K8S集群后,服务发现/注册和配置中心功能均报网络连接错误,无法正常注册服务和拉取配置参数。本地启动后,可以正常注册服务和拉取配置参数。

Environment

Additional context

2024-01-19 17:57:54 ERROR [Config] long polling failed. [com.tencent.polaris.configuration.client.internal.ConfigFileLongPullService] 
com.tencent.polaris.api.exception.RetriableException: ERR-1007(NETWORK_ERROR): [Config] failed to watch config file, cause: UNAVAILABLE: io exception
    at com.tencent.polaris.plugins.configuration.connector.polaris.PolarisConfigFileConnector.watchConfigFiles(PolarisConfigFileConnector.java:124)
    at com.tencent.polaris.configuration.client.internal.ConfigFileLongPullService.doLongPolling(ConfigFileLongPullService.java:132)
    at com.tencent.polaris.configuration.client.internal.ConfigFileLongPullService.lambda$startLongPollingTask$0(ConfigFileLongPullService.java:116)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.base/java.lang.Thread.run(Unknown Source)
Caused by: io.grpc.StatusRuntimeException: UNAVAILABLE: io exception
    at io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:271)
    at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:252)
    at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:165)
    at com.tencent.polaris.specification.api.v1.config.manage.PolarisConfigGRPCGrpc$PolarisConfigGRPCBlockingStub.watchConfigFiles(PolarisConfigGRPCGrpc.java:501)
    at com.tencent.polaris.plugins.configuration.connector.polaris.PolarisConfigFileConnector.watchConfigFiles(PolarisConfigFileConnector.java:116)
    ... 7 common frames omitted
Caused by: io.netty.channel.AbstractChannel$AnnotatedConnectException: finishConnect(..) failed: Connection refused: /127.0.0.1:8093
Caused by: java.net.ConnectException: finishConnect(..) failed: Connection refused
    at io.netty.channel.unix.Errors.newConnectException0(Errors.java:166)
    at io.netty.channel.unix.Errors.handleConnectErrno(Errors.java:131)
    at io.netty.channel.unix.Socket.finishConnect(Socket.java:359)
    at io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.doFinishConnect(AbstractEpollChannel.java:710)
    at io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.finishConnect(AbstractEpollChannel.java:687)
    at io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.epollOutReady(AbstractEpollChannel.java:567)
    at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:499)
    at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:407)
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.base/java.lang.Thread.run(Unknown Source)

2024-01-19 17:58:41 ERROR Report client failed. [com.tencent.polaris.client.api.SDKContext] 
com.tencent.polaris.api.exception.RetriableException: ERR-1007(NETWORK_ERROR): fail to report client host 127.0.0.1, version 1.14.3 service ServiceKey{namespace='null', service='null'}, cause: UNAVAILABLE: io exception
    at com.tencent.polaris.plugins.connector.grpc.GrpcConnector.reportClient(GrpcConnector.java:584)
    at com.tencent.polaris.client.api.SDKContext.lambda$reportClient$0(SDKContext.java:358)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.base/java.util.concurrent.FutureTask.runAndReset(Unknown Source)
    at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.base/java.lang.Thread.run(Unknown Source)
Caused by: io.grpc.StatusRuntimeException: UNAVAILABLE: io exception
    at io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:271)
    at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:252)
    at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:165)
    at com.tencent.polaris.specification.api.v1.service.manage.PolarisGRPCGrpc$PolarisGRPCBlockingStub.reportClient(PolarisGRPCGrpc.java:402)
    at com.tencent.polaris.plugins.connector.grpc.GrpcConnector.reportClient(GrpcConnector.java:562)
    ... 7 common frames omitted
Caused by: io.netty.channel.AbstractChannel$AnnotatedConnectException: finishConnect(..) failed: Connection refused: /127.0.0.1:8091
Caused by: java.net.ConnectException: finishConnect(..) failed: Connection refused
    at io.netty.channel.unix.Errors.newConnectException0(Errors.java:166)
    at io.netty.channel.unix.Errors.handleConnectErrno(Errors.java:131)
    at io.netty.channel.unix.Socket.finishConnect(Socket.java:359)
    at io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.doFinishConnect(AbstractEpollChannel.java:710)
    at io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.finishConnect(AbstractEpollChannel.java:687)
    at io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.epollOutReady(AbstractEpollChannel.java:567)
    at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:499)
    at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:407)
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.base/java.lang.Thread.run(Unknown Source)`

错误日志中的IP和端口和bootstrap.yml中配置的不一致,错误日志中IP为127.0.0.1,bootstrap.yml配置参数

spring:
  cloud.polaris:
    address: grpc://10.0.168.155:8091
    namespace: M2-VAS-Test
    config.groups:
      - name: Default
        files: ["${spring.application.name}.yml"]
BruceAn1978 commented 9 months ago

一个奇怪的问题,只是运行环境换为了K8S Docker镜像模式就连接有问题,而且报错的IP地址是127.0.0.1,不是应用中配置的地址。

BruceAn1978 commented 9 months ago

没有人关注这个问题吗?

SkyeBeFreeman commented 9 months ago

@BruceAn1978 参考一下看看 https://blog.51cto.com/u_16213392/7088143 https://www.volcengine.com/theme/5712689-S-7-1