Skip to content

Commit

Permalink
shorten the directory name for vagrant_root
Browse files Browse the repository at this point in the history
This omits "kitchen-#{something}" from the vagrant root directories that
will appear under .kitchen/kitchen-vagrant. 

Windows users will run into a path length limit of 260 characters.[1]
We have been repeating in the directory structure "kitchen-" and the
basename of kitchen-root--the directory that contains the .kitchen.yml
which most of the time works out to be the name of the cookbook being
tested. This made for meaningful if verbose names for virtual machines
so as to correlate a machine running in a Vagrant-supported hypervisor
to a test-kitchen config.

The inclusion of this string was _not_ for any unique identifier to
avoid naming collusions within the hypervisor. This change should be
safe for an upgrade for kitchens that have running instances prior to
upgrade. The state file for a machine that was successfully created will
have recorded the vagrant_root path used at creation time. This will
allow kitchen commands to continue to operate on the running instances.

[1] #210

Signed-off-by: Robb Kidd <[email protected]>
  • Loading branch information
robbkidd committed Aug 22, 2017
1 parent 4f579b5 commit a9e354a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/kitchen/driver/vagrant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ def vagrant_root
if !@vagrant_root && !instance.nil?
@vagrant_root = File.join(
config[:kitchen_root], %w{.kitchen kitchen-vagrant},
"kitchen-#{File.basename(config[:kitchen_root])}-#{instance.name}"
"#{instance.name}"
)
end
@vagrant_root
Expand Down
11 changes: 4 additions & 7 deletions spec/kitchen/driver/vagrant_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def run_command(_cmd, options = {})
config[:pre_create_command] = "{{vagrant_root}}/candy"

expect(driver[:pre_create_command]).to eq(
"/kroot/.kitchen/kitchen-vagrant/kitchen-kroot-suitey-fooos-99/candy"
"/kroot/.kitchen/kitchen-vagrant/suitey-fooos-99/candy"
)
end

Expand Down Expand Up @@ -613,8 +613,7 @@ def run_command(_cmd, options = {})

let(:vagrant_root) do
File.join(%W{
#{@dir} .kitchen kitchen-vagrant
kitchen-#{File.basename(@dir)}-suitey-fooos-99
#{@dir} .kitchen kitchen-vagrant suitey-fooos-99
})
end

Expand Down Expand Up @@ -845,8 +844,7 @@ def run_command(_cmd, options = {})

let(:vagrant_root) do
File.join(%W{
#{@dir} .kitchen kitchen-vagrant
kitchen-#{File.basename(@dir)}-suitey-fooos-99
#{@dir} .kitchen kitchen-vagrant suitey-fooos-99
})
end

Expand Down Expand Up @@ -935,8 +933,7 @@ def run_command(_cmd, options = {})

let(:vagrant_root) do
File.join(%W{
#{@dir} .kitchen kitchen-vagrant
kitchen-#{File.basename(@dir)}-suitey-fooos-99
#{@dir} .kitchen kitchen-vagrant suitey-fooos-99
})
end

Expand Down

0 comments on commit a9e354a

Please sign in to comment.