amazon-ec2 - 测试厨房几乎每次传输文件都会失败

标签 amazon-ec2 chef-infra test-kitchen

几乎每次我使用 ec2 驱动程序运行 kitchen fusion 时,它都能够创建服务器并建立 ssh 连接,但在检测到 Chef 综合安装后,它会尝试传输文件,但会失败并出现无用的错误。我尝试过使用不同版本的 net-ssh 并重新安装 Chefdk。我已经让它在大约 30 次中成功收敛一次,但不明白有什么区别。

还有其他人遇到过这个问题吗?

-----> Starting Kitchen (v1.10.2)
-----> Creating <default-rhel7>...
       If you are not using an account that qualifies under the AWS
free-tier, you may be charged to run these suites. The charge
should be minimal, but neither Test Kitchen nor its maintainers
are responsible for your incurred costs.

       Instance <i-167bf188> requested.
       Polling AWS for existence, attempt 0...
       Attempting to tag the instance, 0 retries
       EC2 instance <i-167bf188> created.
       Waited 0/600s for instance <i-167bf188> to become ready.
       Waited 5/600s for instance <i-167bf188> to become ready.
       Waited 10/600s for instance <i-167bf188> to become ready.
       Waited 15/600s for instance <i-167bf188> to become ready.
       Waited 20/600s for instance <i-167bf188> to become ready.
       Waited 25/600s for instance <i-167bf188> to become ready.
       Waited 30/600s for instance <i-167bf188> to become ready.
       Waited 35/600s for instance <i-167bf188> to become ready.
       Waited 40/600s for instance <i-167bf188> to become ready.
       Waited 45/600s for instance <i-167bf188> to become ready.
       Waited 50/600s for instance <i-167bf188> to become ready.
       Waited 55/600s for instance <i-167bf188> to become ready.
       EC2 instance <i-167bf188> ready.
       Waiting for SSH service on 10.254.105.26:22, retrying in 3 seconds
       Waiting for SSH service on 10.254.105.26:22, retrying in 3 seconds
       Waiting for SSH service on 10.254.105.26:22, retrying in 3 seconds
       [SSH] Established
       Finished creating <default-rhel7> (1m56.70s).
-----> Converging <default-rhel7>...
       Preparing files for transfer
       Preparing dna.json
       Preparing current project directory as a cookbook
       Removing non-cookbook files before transfer
       Preparing validation.pem
       Preparing client.rb
-----> Chef Omnibus installation detected (install only if missing)
       Transferring files to <default-rhel7>
C:/Users/AlexKiaie/AppData/Local/chefdk/gem/ruby/2.1.0/gems/net-ssh-3.2.0/lib/net/ssh/ruby_compat.rb:25:in `select': closed stream (IOError)
    from C:/Users/AlexKiaie/AppData/Local/chefdk/gem/ruby/2.1.0/gems/net-ssh-3.2.0/lib/net/ssh/ruby_compat.rb:25:in `io_select'
    from C:/Users/AlexKiaie/AppData/Local/chefdk/gem/ruby/2.1.0/gems/net-ssh-3.2.0/lib/net/ssh/transport/packet_stream.rb:75:in `available_for_read?'
    from C:/Users/AlexKiaie/AppData/Local/chefdk/gem/ruby/2.1.0/gems/net-ssh-3.2.0/lib/net/ssh/transport/packet_stream.rb:87:in `next_packet'
    from C:/Users/AlexKiaie/AppData/Local/chefdk/gem/ruby/2.1.0/gems/net-ssh-3.2.0/lib/net/ssh/transport/session.rb:193:in `block in poll_message'
    from C:/Users/AlexKiaie/AppData/Local/chefdk/gem/ruby/2.1.0/gems/net-ssh-3.2.0/lib/net/ssh/transport/session.rb:188:in `loop'
    from C:/Users/AlexKiaie/AppData/Local/chefdk/gem/ruby/2.1.0/gems/net-ssh-3.2.0/lib/net/ssh/transport/session.rb:188:in `poll_message'
    from C:/Users/AlexKiaie/AppData/Local/chefdk/gem/ruby/2.1.0/gems/net-ssh-3.2.0/lib/net/ssh/connection/session.rb:474:in `dispatch_incoming_packets'
    from C:/Users/AlexKiaie/AppData/Local/chefdk/gem/ruby/2.1.0/gems/net-ssh-3.2.0/lib/net/ssh/connection/session.rb:225:in `preprocess'
    from C:/Users/AlexKiaie/AppData/Local/chefdk/gem/ruby/2.1.0/gems/net-ssh-3.2.0/lib/net/ssh/connection/session.rb:206:in `process'
    from C:/Users/AlexKiaie/AppData/Local/chefdk/gem/ruby/2.1.0/gems/net-ssh-3.2.0/lib/net/ssh/connection/session.rb:170:in `block in loop'
    from C:/Users/AlexKiaie/AppData/Local/chefdk/gem/ruby/2.1.0/gems/net-ssh-3.2.0/lib/net/ssh/connection/session.rb:170:in `loop'
    from C:/Users/AlexKiaie/AppData/Local/chefdk/gem/ruby/2.1.0/gems/net-ssh-3.2.0/lib/net/ssh/connection/session.rb:170:in `loop'
    from C:/Users/AlexKiaie/AppData/Local/chefdk/gem/ruby/2.1.0/gems/net-ssh-3.2.0/lib/net/ssh/connection/session.rb:119:in `close'
    from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.10.2/lib/kitchen/transport/ssh.rb:115:in `close'
    from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.10.2/lib/kitchen/transport/ssh.rb:97:in `cleanup!'
    from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.10.2/lib/kitchen/instance.rb:274:in `cleanup!'
    from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.10.2/lib/kitchen/command.rb:209:in `run_action_in_thread'
    from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.10.2/lib/kitchen/command.rb:173:in `block (2 levels) in run_action'
    from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/logging-2.1.0/lib/logging/diagnostic_context.rb:450:in `call'
    from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/logging-2.1.0/lib/logging/diagnostic_context.rb:450:in `block in create_with_logging_context'

最佳答案

我也有类似的问题。经过大量挖掘,我在 /var/log/secure 中发现了一条有趣的消息 -

"localhost sshd[1081]: error: no more sessions".

默认情况下,SSHD 允许 10 个 session ;这些未登录 session 。如果由于某种原因存在未正确关闭或打开的 session ,您将收到此错误。

然后我进入我的 .kitchen.yml 并添加:

max_ssh_sessions: 1

到运输部分。所以现在看起来像:

transport:
  ssh_key: ./kitchen.pem
  # need to get this key from vault, then place it on the kitchen ecs container
  connection_timeout: 10
  connection_retries: 5
  max_ssh_sessions: 1
  username: centos

当我运行测试厨房时,速度明显变慢。然而,它 100% 的时间都有效。我认为正在发生的事情是 kitchen 正在打开多个 SSH session 以加快所需工具的安装速度。例如,yum 代表 ansible/git/whatever,/tmp/install.sh 代表 Chef。

希望这对某人有帮助。我花了一点时间才发现。

关于amazon-ec2 - 测试厨房几乎每次传输文件都会失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38514004/

相关文章:

hadoop - MIT StarCluster 和 S3

linux - 如何在 AWS 上的 Amazon Linux AMI 中自动启动 node.js 应用程序?

amazon-web-services - 基于请求 header 的路由(使用 AWS Application Load Balancer)

ruby - 每个方法中的 Chef 通知

vagrant - 厨房创建 new_box 命令不起作用

vagrant - 端口转发不适用于 Test-Kitchen 和 Vagrant

amazon-web-services - 在 CloudFormation 脚本中使用私有(private) AMI

chef-infra - Chef 自定义资源是否应该使用属性作为默认属性值?

powershell - 以小型 powershell 脚本开头的 Chef Cookbook,需要将返回的整数值传递给 Chef

hadoop - 如何在Test Kitchen Chef中使用群集节点我需要与 Chef 一起在测试厨房中安装hadoop群集进行测试