You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用pssh测试500个Docker容器连通性时遇[Errno 32] Broken pipe问题求助

大规模Docker容器集群pssh连通性测试出现Broken Pipe错误

问题背景

  • 作业要求创建大量Docker容器,通过pssh验证集群内所有节点互联互通
  • 测试10个容器时完全正常,但扩展到500个容器时,随机出现[Errno 32] Broken pipe错误,且所有错误都发生在pssh连通性测试环节
  • 运行环境:Ubuntu 22.04的VirtualBox虚拟机(因Windows无法直接IP连接Docker容器,所以用虚拟机运行脚本)
  • 错误触发时机无规律:本次测试首次连接就报错,之前一次完成300组连接后才出现错误
  • 测试逻辑:每个容器通过pssh连接其余499个容器执行hostname命令,总计500*499次连接,单次测试耗时约7小时,调试难度极大

完整错误信息

[20] 16:30:43 [FAILURE] 0 Exited with error code 255 Stderr: The authenticity of host 0.0.0.0 (0.0.0.0)

xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option

Traceback (most recent call last):

  File "/usr/bin/pssh", line 119, in <module>

    do_pssh(hosts, cmdline, opts)

  File "/usr/bin/pssh", line 94, in do_pssh

    statuses = manager.run()

               ^^^^^^^^^^^^^

  File "/usr/lib/python3.12/site-packages/psshlib/manager.py", line 74, in run

    self.update_tasks(writer)

  File "/usr/lib/python3.12/site-packages/psshlib/manager.py", line 117, in update_tasks

    if self.reap_tasks() == 0:

       ^^^^^^^^^^^^^^^^^

  File "/usr/lib/python3.12/site-packages/psshlib/manager.py", line 139, in reap_tasks

    self.finished(task)

  File "/usr/lib/python3.12/site-packages/psshlib/manager.py", line 177, in finished

    task.report(n)

  File "/usr/lib/python3.12/site-packages/psshlib/task.py", line 291, in report

    sys.stdout.flush()

BrokenPipeError: [Errno 32] Broken pipe

Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>

BrokenPipeError: [Errno 32] Broken pipe

注:环境中不存在0.0.0.0主机,也没有导致xargs报错的未匹配单引号,错误根源应为Broken pipe

相关代码片段

# execute pssh

echo -e "\n\033[92mStep 8: \033[92m\033[100mExecuting pssh to demonstrate all interconnections...\033[0m \033[33m"

for IP in $IPset; do

  echo -en "\033[91m $IP \033[0m => \033[33m"

  ssh -i keydir/my_key root@$IP pssh -i -x \"-i /root/.ssh/my_key\" -H \"$(echo $IPset | sed -e s/$IP//g)\" hostname -i | xargs

done #| cowsay -f cheese

注:$IPset包含所有容器IP;单容器测试ssh+pssh连接无问题;容器运行Alpine Linux;脚本由教授提供

已尝试的解决方法

  • 移除| xargs仅改变输出格式,未解决核心问题
  • 使用tmux运行脚本,依然会触发错误

求助

目前陷入困境,恳请提供可行的解决方案。

内容的提问来源于stack exchange,提问作者Beni12345612

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.19 13:22:06