0

我在 AKS 中使用 traefik 作为入口控制器,我有一个可以在本地正确运行的 grpc 服务,但是 traefik 背后有一些问题。

当GRPC服务器返回错误时,我正确接收,但是当它发送正常响应时,我没有收到:

grpcServer@grpc.test.com:443> client.Ping({}, metadata, pr)
EventEmitter {}
grpcServer@grpc.test.com:443> 
Error:  { Error: 2 UNKNOWN: No status received
    at Object.exports.createStatusError (/usr/local/lib/node_modules/grpcc/node_modules/grpc/src/common.js:91:15)
    at Object.onReceiveStatus (/usr/local/lib/node_modules/grpcc/node_modules/grpc/src/client_interceptors.js:1204:28)
    at InterceptingListener._callNext (/usr/local/lib/node_modules/grpcc/node_modules/grpc/src/client_interceptors.js:568:42)
    at InterceptingListener.onReceiveStatus (/usr/local/lib/node_modules/grpcc/node_modules/grpc/src/client_interceptors.js:618:8)
    at callback (/usr/local/lib/node_modules/grpcc/node_modules/grpc/src/client_interceptors.js:845:24) code: 2, metadata: {}, details: 'No status received' }

对比

grpcServer@localhost:10000> client.Ping({}, metadata, pr)
EventEmitter {}
grpcServer@localhost:10000> 
{
  "response": "PONG"
}

错误:

grpcServer@grpc.test.com:443> client.Ping({}, pr)
EventEmitter {}
grpcServer@grpc.test.com:443> 
Error:  { Error: 16 UNAUTHENTICATED: incorrect serial number
    at Object.exports.createStatusError (/usr/local/lib/node_modules/grpcc/node_modules/grpc/src/common.js:91:15)
    at Object.onReceiveStatus (/usr/local/lib/node_modules/grpcc/node_modules/grpc/src/client_interceptors.js:1204:28)
    at InterceptingListener._callNext (/usr/local/lib/node_modules/grpcc/node_modules/grpc/src/client_interceptors.js:568:42)
    at InterceptingListener.onReceiveStatus (/usr/local/lib/node_modules/grpcc/node_modules/grpc/src/client_interceptors.js:618:8)
    at callback (/usr/local/lib/node_modules/grpcc/node_modules/grpc/src/client_interceptors.js:845:24)
  code: 16,
  metadata:
   { 'content-length': '0', date: 'Wed, 06 Feb 2019 21:32:38 GMT' },
  details: 'incorrect serial number' }

k8s 服务 yml:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: velcloud-grpc
  namespace: production
  annotations:
    kubernetes.io/ingress.class: traefik
    ingress.kubernetes.io/protocol: h2c
    traefik.protocol: h2c
spec:
  rules:
    - host: grpc.test.com
      http:
        paths:
          - path: /
            backend:
              serviceName: velcloud-grpc
              servicePort: grpc

编辑:更多信息

经过一些调试,我检查了收到的响应:

{ client_close: true,
  metadata: { date: [ 'Wed, 06 Feb 2019 23:48:06 GMT' ] },
  read: <Buffer 0a 04 50 4f 4e 47>,
  status:
   { code: 2,
     details: 'No status received',
     metadata: Metadata { _internal_repr: {} } } } { code: 2,
  details: 'No status received'
}

这里唯一的问题是状态,一旦反序列化读取内容正确的响应:{ response: 'PONG' }

我不知道为什么将状态设置为 2 (UNKNOWN) 而不是 0 (OK)。

4

1 回答 1

2

在我的 Traefik 配置中,我使用了重试中间件([retry]),而 Traefik v1.7.8 有一个错误:

当重试中间件已经发送了 headers 时,使用原始 headers 映射能够发送尾部。

https://github.com/containous/traefik/pull/4442

我用这个修复手动构建了 v1.7 分支,一切都恢复正常了!非常感谢 Containous(Damien 和 Julien!)帮助调试此问题!

于 2019-02-08T14:21:34.533 回答