test-kitchen / kitchen-vagrant

A Test Kitchen Driver for Vagrant
Other
348 stars 189 forks source link

Kitchen converge fails on Windows 10 syncing initial cookbooks #407

Open brandonhawbaker opened 5 years ago

brandonhawbaker commented 5 years ago

System Information:

Host: Windows 10 Enterprise Guest: Windows 10 Enterprise (Custom Virtual Box) Kitchen: 2.2.5 ChefDK: 4.2.0 Chef Infra Client version: 15.1.36 Ruby: 2.6.3p62 (2019-04-16 revision 67580) [x64-mingw32] Vagrant: 2.2.4 Kitchen-Vagrant: 1.5.2

I create a Windows 10 box, which works fine with vagrant up, etc. Chef can connect to the box and run commands, but the kitchen converge command only succeeds if I pre-create the c:\tmp\kitchen\cookbooks directory, otherwise I get the following:

>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: 1 actions failed.
>>>>>>     Failed to complete #converge action: [[WinRM::FS::Core::FileTransporter] Upload failed (exitcode: 0), but stderr present
Cannot create "C:\tmp\kitchen" because a file or directory with the same name already exists.
At line:12 char:40
+   $path | ? {-not (test-path $_)} | % {$null = mkdir $_}
+                                        ~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (C:\tmp\kitchen\cookbooks:String) [New-Item], IOException
    + FullyQualifiedErrorId : CreateDirectoryIOError,Microsoft.PowerShell.Commands.NewItemCommand
Could not find a part of the path 'C:\tmp\kitchen\cookbooks\'.
At line:47 char:17
+   dir $unpack | cp -dest "$dst/" -force -recurse
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (metadata.rb:FileInfo) [Copy-Item], DirectoryNotFoundException
    + FullyQualifiedErrorId : CopyDirectoryInfoItemIOError,Microsoft.PowerShell.Commands.CopyItemCommand
Could not find a part of the path 'C:\tmp\kitchen\cookbooks\'.
At line:47 char:17
+   dir $unpack | cp -dest "$dst/" -force -recurse
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (README.md:FileInfo) [Copy-Item], DirectoryNotFoundException
    + FullyQualifiedErrorId : CopyDirectoryInfoItemIOError,Microsoft.PowerShell.Commands.CopyItemCommand
Could not find a part of the path 'C:\tmp\kitchen\cookbooks\'.
At line:47 char:17
+   dir $unpack | cp -dest "$dst/" -force -recurse
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (default.rb:FileInfo) [Copy-Item], DirectoryNotFoundException
    + FullyQualifiedErrorId : CopyDirectoryInfoItemIOError,Microsoft.PowerShell.Commands.CopyItemCommand
Cannot create "C:\tmp\kitchen" because a file or directory with the same name already exists.
At line:12 char:40
+   $path | ? {-not (test-path $_)} | % {$null = mkdir $_}
+                                        ~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (C:\tmp\kitchen\cache:String) [New-Item], IOException
    + FullyQualifiedErrorId : CreateDirectoryIOError,Microsoft.PowerShell.Commands.NewItemCommand
] on default-BPA-TEST
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration
muddman commented 4 years ago

I have the same issue on Windows 10 with test-kitchen (2.3.4, 2.3.3).

kitchen converge creates a file $env:TEMP\kitchen and then attempts to use WinRM to upload files to a directory with the same name: $env:TEMP\kitchen.

Message: Failed to complete #converge action: [[WinRM::FS::Core::FileTransporter] Upload failed (exitcode: 0), but stderr present
Cannot create "C:\Users\vagrant\AppData\Local\Temp\kitchen" because a file or directory with the same name already exists.

Converge creates C:\Users\vagrant\AppData\Local\Temp\kitchen:

#!/bin/bash

function apt_repo_add {
  id="$1"
  arch="$2"
  rurl="$3"
  comp="$4"
  dist="$5"
  rkey="$6"
  test -e /tmp/apt_repo_vendor_"${id}".key || {
    echo "-----> Configuring formula apt vendor_repo ${rurl}"
    eval "$(cat /etc/lsb-release)"
    if curl -k "${rkey}" -o /tmp/apt_repo_vendor_"${id}".key; then
      echo "deb ${arch} ${rurl} ${dist} ${comp}" | tee /etc/apt/sources.list.d/vendor-repo.list
      apt-key add /tmp/apt_repo_vendor_"${id}".key
    fi
  };
}

# detect if file is being sourced
[[ "$0" != "${BASH_SOURCE[0]}" ]] || {
    # if executed, run implicit function
    #apt_repo_add "${@}"
    echo 'Usage: apt_repo_add "custom id" "arch" "repo url" "components" "distribution" "repo gpg key"';
}

Here is the error log:

ERROR -- Kitchen: ----------------------
ERROR -- Kitchen: ------Backtrace-------
ERROR -- Kitchen: C:/opscode/chefdk/embedded/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/command.rb:184:in `report_errors'
ERROR -- Kitchen: C:/opscode/chefdk/embedded/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/command.rb:175:in `run_action'
ERROR -- Kitchen: C:/opscode/chefdk/embedded/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/command/action.rb:36:in `block in call'
ERROR -- Kitchen: C:/opscode/chefdk/embedded/lib/ruby/2.6.0/benchmark.rb:293:in `measure'
ERROR -- Kitchen: C:/opscode/chefdk/embedded/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/command/action.rb:34:in `call'
ERROR -- Kitchen: C:/opscode/chefdk/embedded/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/cli.rb:52:in `perform'
ERROR -- Kitchen: C:/opscode/chefdk/embedded/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/cli.rb:198:in `block (2 levels) in <class:CLI>'
ERROR -- Kitchen: C:/opscode/chefdk/embedded/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
ERROR -- Kitchen: C:/opscode/chefdk/embedded/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
ERROR -- Kitchen: C:/opscode/chefdk/embedded/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
ERROR -- Kitchen: C:/opscode/chefdk/embedded/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/base.rb:466:in `start'
ERROR -- Kitchen: C:/opscode/chefdk/embedded/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/bin/kitchen:13:in `block in <top (required)>'
ERROR -- Kitchen: C:/opscode/chefdk/embedded/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/errors.rb:171:in `with_friendly_errors'
ERROR -- Kitchen: C:/opscode/chefdk/embedded/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/bin/kitchen:13:in `<top (required)>'
ERROR -- Kitchen: C:/opscode/chefdk/bin/kitchen:366:in `load'
ERROR -- Kitchen: C:/opscode/chefdk/bin/kitchen:366:in `<main>'
ERROR -- Kitchen: ----End Backtrace-----
ERROR -- Kitchen: -Composite Exception--
ERROR -- Kitchen: Class: Kitchen::ActionFailed
ERROR -- Kitchen: Message: Failed to complete #converge action: [[WinRM::FS::Core::FileTransporter] Upload failed (exitcode: 0), but stderr present
Cannot create "C:\Users\vagrant\AppData\Local\Temp\kitchen" because a file or directory with the same name already exists.
At line:12 char:40
+   $path | ? {-not (test-path $_)} | % {$null = mkdir $_}
+                                        ~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (C:\Users\vagran...emp\kitchen\srv:String) [New-Item], IOException
    + FullyQualifiedErrorId : CreateDirectoryIOError,Microsoft.PowerShell.Commands.NewItemCommand
Could not find a part of the path 'C:\Users\vagrant\AppData\Local\Temp\kitchen\srv\'.
At line:47 char:17

kitchen diagnose --all results.