Dokken tries to connect to docker when loaded by chef exec rake
When my repository contains a kitchen.yml with driver dokken and docker-engine is not running, I can't run the static code analysis using cookstyle because kitchen is loaded by rake which loads kitchen-dokken which tries to connect to docker (which is not running) and thus the whole command fails.
We experienced that none of our CI jobs worked anymore from the moment we added a kitchen.yml our developers could use to start testing locally. After a search we found that chef exec rake -vT failed as well with the following error:
kitchen-dokken could not connect to the docker host at unix:///var/run/docker.sock. Is docker running?
Most of our developers do not run docker-engine all the time (saving RAM/CPU resources and such), neither is our CI pipeline configured for dokken yet. Purely because we have a kitchen.yml with a dokken driver, a platform and a suite name we can't run our static code analysis unless docker-engine is running. In my opinion the dependency on a running docker-engine shouldn't be there unless we're invoking kitchen itself.
Version
Chef Workstation version: 21.2.303 Chef Infra Client version: 16.10.17 Chef InSpec version: 4.26.13 Chef CLI version: 3.1.1 Chef Habitat version: 1.6.181 Test Kitchen version: 2.10.0 Cookstyle version: 7.8.3
Environment
OS-X Big Sur 11.2.2
Scenario
I'm trying to run cookstyle while docker-engine is not running.
Steps to Reproduce
-
Create a
kitchen.ymlwith the following content:--- driver: name: dokken platforms: - name: debian-10 suites: - name: default -
Make sure docker-engine is unreachable
-
Run
chef exec rake -vT
Expected Result
I'd expect a list of possible tasks:
rake style # Run foodcritic and cookstyle on this cookbook
rake style:cookstyle # Run RuboCop
rake style:cookstyle:auto_correct # Auto-correct RuboCop offenses
rake test # Run unit and functional tests
rake test:kitchen:all # Run all test instances
rake test:kitchen:converge:all # Run all converge instances
rake test:kitchen:create:all # Run all create instances
rake test:kitchen:default-debian-10 # Run default-debian-10 test instance
rake test:kitchen:destroy # Destroys all active kitchen resources
rake test:kitchen:destroy:all # Run all destroy instances
rake test:kitchen:setup:all # Run all setup instances
rake test:kitchen:verify:all # Run all verify instances
rake test:unit # Run ChefSpec unit tests
Actual Result
You see an error:
kitchen-dokken could not connect to the docker host at unix:///var/run/docker.sock. Is docker running?
@fuegas could you include the Rakefile in question? Following the steps outlined with a custom (empty) rakefile, chef exec is not causing any kitchen content to load (dokken or otherwise).
Hi @marcparadise,
The content (which causes the error) is:
namespace :test do
begin
require 'kitchen/rake_tasks'
desc 'Run kitchen integration tests'
Kitchen::RakeTasks.new
rescue StandardError => e
puts ">>> Kitchen error: #{e}, omitting #{task.name}" unless ENV['CI']
end
end
This is written because we wanted multiple checks to be usable from CLI and in pipelines without duplicating the commands.