Chef立即在powershell_script上抛出Mixlib :: ShellOut :: CommandTimeout

时间:2018-10-10 20:11:37

标签: powershell chef

我遇到了反复出现但又随机的错误。有时,这很有效,但我经常在非常简单的powershell_script资源上超时。 Chef似乎并没有等待默认的超时时间(3600秒),而是立即引发了此异常。我在这里想念什么吗?我该如何调试 Mixlib::ShellOut::CommandTimeout

 ================================================================================
 Error executing action `run` on resource 'powershell_script[uninstall]'
 ================================================================================

 Mixlib::ShellOut::CommandTimeout
 --------------------------------
 command timed out:
 ---- Begin output of "C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -InputFormat None -File "C:/Users/vagrant/AppData/Local/Temp/chef-script20180924-2936-1r1bagl.ps1" ----                                                                     
 STDOUT: 
 STDERR: 
 ---- End output of "C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -InputFormat None -File "C:/Users/vagrant/AppData/Local/Temp/chef-script20180924-2936-1r1bagl.ps1" ----                                                                       

 ProcessId: 1664
 app_name: C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe
 command_line: "C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -InputFormat None -File "C:/Users/vagrant/AppData/Local/Temp/chef-script20180924-2936-1r1bagl.ps1"                                                                                 
 timeout: 3600

 Resource Declaration:
 ---------------------
 # In C:/Users/vagrant/AppData/Local/Temp/kitchen/cache/cookbooks/documents/recipes/service.rb

   7: powershell_script "uninstall" do
   8:   only_if { ::File.exist?('C:\Documents\scripts\Uninstall.ps1') }
   9:   code <<-SCRIPT
  10:   "Trying to uninstall...."
  11:   . C:\\Documents\\scripts\\Uninstall.ps1 > C:\\Documents\\Uninstall.log
  12:   SCRIPT
  13: end
  14: 

1 个答案:

答案 0 :(得分:1)

您具体使用哪个Chef版本?

尽管,如果您想调试,我想尝试将命令直接传递到Mixlib::ShellOut.new(cmd, :timeout => 3600)是一个很好的起点。

但是,在我搜索了一下之后,我刚刚发现Powershell资源曾经有一些问题,例如https://github.com/chef/mixlib-shellout/issues/86https://github.com/chef/chef/issues/2348,因此不确定它们是否已在较新版本中修复。

因此,要考虑的另一种解决方案是将dsc脚本与Chef一起使用 (即https://docs.chef.io/resource_dsc_script.htmlhttps://docs.microsoft.com/en-us/powershell/dsc/scriptresource),我认为这可能更可靠。