简体   繁体   English

Docker + pubsub + 子进程挂起,没有错误

[英]Docker + pubsub + subprocess hangs with no errors

I'm running pubsub in a docker container and am experiencing hangs after a few minutes.我在 docker 容器中运行 pubsub,几分钟后遇到挂起。 I've been running pubsub with similar commands outside of docker, and see no hangs (over 1 year running).我一直在使用 docker 之外的类似命令运行 pubsub,并且没有看到挂起(运行超过 1 年)。

I was able to reproduce my issue with a simplified implementation outlined below.我能够通过下面概述的简化实现来重现我的问题。

The following four files (docker file, requirements.txt, worker.py, test.py) are placed into the same directory.以下四个文件(docker file、requirements.txt、worker.py、test.py)放在同一个目录下。 They are located in this gist.它们位于此要点中。 Basically the worker.py is calling a subprocess function, which calls test.py to run a time.sleep(3).基本上,worker.py 正在调用一个子进程 function,它调用 test.py 来运行 time.sleep(3)。

Gist for code and debug outputs 代码和调试输出的要点

To build the docker file, I placed the Dockerfile, requirements.txt, worker.py, and test.py into a directory and ran:为了构建 docker 文件,我将 Dockerfile、requirements.txt、worker.py 和 test.py 放入一个目录并运行:

docker build --tag=test .

To run the docker file, I did the following:要运行 docker 文件,我执行了以下操作:

docker run -it \
   -e GOOGLE_APPLICATION_CREDENTIALS=/keys/service-account.json \
   -e GRPC_ENABLE_FORK_SUPPORT=false \
   -e GRPC_VERBOSITY=debug \
   -e GRPC_TRACE=all \
   -v /tmp/keys/:/keys/:ro \
   -v /tmp/logs:/logs \
test:latest bash

The file service-account.json holds my pubsub keys.文件 service-account.json 包含我的 pubsub 密钥。

I'm running docker on my Mac, but I've also experienced the same hanging using kubernetes, and on an Ubuntu 18.04 machine running docker. I'm running docker on my Mac, but I've also experienced the same hanging using kubernetes, and on an Ubuntu 18.04 machine running docker. The issue is that after a few minutes, the pubsub subscriber becomes unresponsive.问题是几分钟后,pubsub 订阅者变得无响应。 The above code runs perfectly in a virtual environment without docker.上述代码在没有 docker 的虚拟环境中完美运行。

The file (in gist) publish_output.txt is the log file of my pubsub publisher output, and containers the message ID's.文件(要点)publish_output.txt 是我的 pubsub 发布者 output 的日志文件,并包含消息 ID。

The file subscriber_output.txt (in gist) is the subscriber log output.文件subscriber_output.txt(要点)是订阅者日志output。 I set GRPC_TRACE to all and GRPC_VERBOSITY to debug.我将 GRPC_TRACE 设置为 all 并将 GRPC_VERBOSITY 设置为调试。 The last successful message received was message ID 1253690400552289 (line 9338 of subscriber_output.txt).收到的最后一条成功消息是消息 ID 1253690400552289(subscriber_output.txt 的第 9338 行)。 Messages 1253713007710668, 1253714609061509, 1253713464329969 and onward were all not received by pubsub. pubsub 未收到 1253713007710668、1253714609061509、1253713464329969 及以后的消息。

Is there any additional setting I need to do?我需要做任何额外的设置吗? Unfortunately, I'm running custom C++ code from python so I need to use subprocesses.不幸的是,我正在运行来自 python 的自定义 C++ 代码,所以我需要使用子进程。

The current python packages in my docker configuration:我的 docker 配置中的当前 python 包:

CacheControl             0.12.6
cachetools               4.1.0
certifi                  2020.4.5.1
chardet                  3.0.4
firebase                 3.0.1
firebase-admin           4.3.0
firestore                0.0.8
google-api-core          1.18.0
google-api-python-client 1.9.1
google-auth              1.16.1
google-auth-httplib2     0.0.3
google-cloud-core        1.3.0
google-cloud-firestore   1.7.0
google-cloud-logging     1.15.0
google-cloud-pubsub      1.5.0
google-cloud-storage     1.28.1
google-resumable-media   0.5.1
googleapis-common-protos 1.52.0
grpc-google-iam-v1       0.12.3
grpcio                   1.29.0
httplib2                 0.18.1
idna                     2.9
iso8601                  0.1.12
msgpack                  1.0.0
pip                      20.1.1
protobuf                 3.12.2
pyasn1                   0.4.8
pyasn1-modules           0.2.8
pytz                     2020.1
requests                 2.23.0
rsa                      4.0
setuptools               46.4.0
six                      1.15.0
uritemplate              3.0.1
urllib3                  1.25.9
wheel                    0.34.2

Any help is appreciated.任何帮助表示赞赏。

Thanks!谢谢!

Looks like the issue is with the google-core-api.看起来问题出在 google-core-api 上。

I was able to resolve it by following the recommendations here:我能够按照这里的建议解决它:

https://github.com/googleapis/python-pubsub/issues/112 https://github.com/googleapis/python-pubsub/issues/112

Basically the requirements.txt should use these versions:基本上 requirements.txt 应该使用这些版本:

google-api-python-client <= 1.8.4
google-api-core <= 1.16.0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM