kitchen-docker
kitchen-docker copied to clipboard
Unable to use docker as transport
:ghost: Brief Description
Inability of using docker
as transport
.
Version
-
kitchen-docker
: 2.10.0 -
test-kitchen
: 2.8.0
Environment
# bundle install
[...]
Using test-kitchen 2.8.0 (was 2.4.0) from https://github.com/test-kitchen/test-kitchen.git (at master@c0b0d89)
Using kitchen-docker 2.10.0 from https://github.com/test-kitchen/kitchen-docker.git (at master@5d6ba50)
[...]
Bundle updated!
# bundle exec kitchen verify
-----> Starting Test Kitchen (v2.8.0)
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ClientError
>>>>>> Message: Could not load the 'docker' transport. Error: undefined local variable or method `logger' for main:Object
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration
# bundle exec kitchen diagnose --all
---
timestamp: 2020-12-22 12:05:50 UTC
kitchen_version: 2.8.0
plugins:
error:
exception: "#<Kitchen::ClientError: Could not load the 'docker' transport. Error:
undefined local variable or method `logger' for main:Object>"
message: 'Could not load the ''docker'' transport. Error: undefined local variable
or method `logger'' for main:Object'
backtrace:
- "/usr/lib/ruby/gems/2.7.0/bundler/gems/test-kitchen-c0b0d8988771/lib/kitchen/plugin.rb:45:in
`rescue in load'"
- "/usr/lib/ruby/gems/2.7.0/bundler/gems/test-kitchen-c0b0d8988771/lib/kitchen/plugin.rb:33:in
`load'"
- "/usr/lib/ruby/gems/2.7.0/bundler/gems/test-kitchen-c0b0d8988771/lib/kitchen/transport.rb:37:in
`for_plugin'"
- "/usr/lib/ruby/gems/2.7.0/bundler/gems/test-kitchen-c0b0d8988771/lib/kitchen/config.rb:326:in
`new_transport'"
- "/usr/lib/ruby/gems/2.7.0/bundler/gems/test-kitchen-c0b0d8988771/lib/kitchen/config.rb:254:in
`new_instance'"
- "/usr/lib/ruby/gems/2.7.0/bundler/gems/test-kitchen-c0b0d8988771/lib/kitchen/config.rb:143:in
`block in build_instances'"
- "/usr/lib/ruby/gems/2.7.0/bundler/gems/test-kitchen-c0b0d8988771/lib/kitchen/config.rb:142:in
`map'"
- "/usr/lib/ruby/gems/2.7.0/bundler/gems/test-kitchen-c0b0d8988771/lib/kitchen/config.rb:142:in
`with_index'"
- "/usr/lib/ruby/gems/2.7.0/bundler/gems/test-kitchen-c0b0d8988771/lib/kitchen/config.rb:142:in
`build_instances'"
- "/usr/lib/ruby/gems/2.7.0/bundler/gems/test-kitchen-c0b0d8988771/lib/kitchen/config.rb:116:in
`instances'"
- "/usr/lib/ruby/gems/2.7.0/bundler/gems/test-kitchen-c0b0d8988771/lib/kitchen/command.rb:109:in
`filtered_instances'"
- "/usr/lib/ruby/gems/2.7.0/bundler/gems/test-kitchen-c0b0d8988771/lib/kitchen/command.rb:139:in
`parse_subcommand'"
- "/usr/lib/ruby/gems/2.7.0/bundler/gems/test-kitchen-c0b0d8988771/lib/kitchen/command/diagnose.rb:52:in
`load_instances'"
- "/usr/lib/ruby/gems/2.7.0/bundler/gems/test-kitchen-c0b0d8988771/lib/kitchen/command/diagnose.rb:31:in
`block in call'"
- "/usr/lib/ruby/gems/2.7.0/bundler/gems/test-kitchen-c0b0d8988771/lib/kitchen/command/diagnose.rb:72:in
`record_failure'"
- "/usr/lib/ruby/gems/2.7.0/bundler/gems/test-kitchen-c0b0d8988771/lib/kitchen/command/diagnose.rb:31:in
`call'"
- "/usr/lib/ruby/gems/2.7.0/bundler/gems/test-kitchen-c0b0d8988771/lib/kitchen/cli.rb:52:in
`perform'"
- "/usr/lib/ruby/gems/2.7.0/bundler/gems/test-kitchen-c0b0d8988771/lib/kitchen/cli.rb:142:in
`diagnose'"
- "/usr/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor/command.rb:27:in `run'"
- "/usr/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'"
- "/usr/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch'"
- "/usr/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor/base.rb:485:in `start'"
- "/usr/lib/ruby/gems/2.7.0/bundler/gems/test-kitchen-c0b0d8988771/bin/kitchen:11:in
`block in <top (required)>'"
- "/usr/lib/ruby/gems/2.7.0/bundler/gems/test-kitchen-c0b0d8988771/lib/kitchen/errors.rb:170:in
`with_friendly_errors'"
- "/usr/lib/ruby/gems/2.7.0/bundler/gems/test-kitchen-c0b0d8988771/bin/kitchen:11:in
`<top (required)>'"
- "/usr/lib/ruby/gems/2.7.0/bin/kitchen:23:in `load'"
- "/usr/lib/ruby/gems/2.7.0/bin/kitchen:23:in `<top (required)>'"
- "/usr/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `load'"
- "/usr/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `kernel_load'"
- "/usr/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:28:in `run'"
- "/usr/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli.rb:476:in `exec'"
- "/usr/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in
`run'"
- "/usr/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in
`invoke_command'"
- "/usr/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor.rb:399:in
`dispatch'"
- "/usr/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli.rb:30:in `dispatch'"
- "/usr/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/base.rb:476:in
`start'"
- "/usr/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli.rb:24:in `start'"
- "/usr/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/exe/bundle:46:in `block in <top
(required)>'"
- "/usr/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/friendly_errors.rb:123:in
`with_friendly_errors'"
- "/usr/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/exe/bundle:34:in `<top (required)>'"
- "/usr/bin/bundle:23:in `load'"
- "/usr/bin/bundle:23:in `<main>'"
loader:
process_erb: true
process_local: true
process_global: true
global_config:
project_config:
filename: "/states/.kitchen.yml"
raw_data:
driver:
name: docker
use_sudo: false
wait_for_transport: false
transport:
name: docker
log_level: :debug
provisioner:
name: salt_solo
is_file_root: true
state_top_from_file: top.sls
verifier:
name: nox
testingdir: "/srv/salt/test"
platforms:
- name: debian
image: debian:buster-slim
suites:
- name: REDACTED
provisioner:
salt_bootstrap_options: "-c /tmp -x python3 stable"
init_environment: |
DEBIAN_FRONTEND=noninteractive sudo apt install -y python3-pip python3-docker >/dev/null 2>&1
sudo python3 -m pip install nox
install_after_init_environment: true
grains:
products:
- REDACTED
local_config:
combined_config:
filename:
raw_data:
driver:
name: docker
use_sudo: false
wait_for_transport: false
transport:
name: docker
log_level: :debug
provisioner:
name: salt_solo
is_file_root: true
state_top_from_file: top.sls
verifier:
name: nox
testingdir: "/srv/salt/test"
platforms:
- name: debian
image: debian:buster-slim
suites:
- name: REDACTED
provisioner:
salt_bootstrap_options: "-c /tmp -x python3 stable"
init_environment: |
DEBIAN_FRONTEND=noninteractive sudo apt install -y python3-pip python3-docker >/dev/null 2>&1
sudo python3 -m pip install nox
install_after_init_environment: true
grains:
products:
- REDACTED
instances:
error:
exception: "#<Kitchen::ClientError: Could not load the 'docker' transport. Error:
undefined local variable or method `logger' for main:Object>"
message: 'Could not load the ''docker'' transport. Error: undefined local variable
or method `logger'' for main:Object'
backtrace:
- "/usr/lib/ruby/gems/2.7.0/bundler/gems/test-kitchen-c0b0d8988771/lib/kitchen/plugin.rb:45:in
`rescue in load'"
- "/usr/lib/ruby/gems/2.7.0/bundler/gems/test-kitchen-c0b0d8988771/lib/kitchen/plugin.rb:33:in
`load'"
- "/usr/lib/ruby/gems/2.7.0/bundler/gems/test-kitchen-c0b0d8988771/lib/kitchen/transport.rb:37:in
`for_plugin'"
- "/usr/lib/ruby/gems/2.7.0/bundler/gems/test-kitchen-c0b0d8988771/lib/kitchen/config.rb:326:in
`new_transport'"
- "/usr/lib/ruby/gems/2.7.0/bundler/gems/test-kitchen-c0b0d8988771/lib/kitchen/config.rb:254:in
`new_instance'"
- "/usr/lib/ruby/gems/2.7.0/bundler/gems/test-kitchen-c0b0d8988771/lib/kitchen/config.rb:143:in
`block in build_instances'"
- "/usr/lib/ruby/gems/2.7.0/bundler/gems/test-kitchen-c0b0d8988771/lib/kitchen/config.rb:142:in
`map'"
- "/usr/lib/ruby/gems/2.7.0/bundler/gems/test-kitchen-c0b0d8988771/lib/kitchen/config.rb:142:in
`with_index'"
- "/usr/lib/ruby/gems/2.7.0/bundler/gems/test-kitchen-c0b0d8988771/lib/kitchen/config.rb:142:in
`build_instances'"
- "/usr/lib/ruby/gems/2.7.0/bundler/gems/test-kitchen-c0b0d8988771/lib/kitchen/config.rb:116:in
`instances'"
- "/usr/lib/ruby/gems/2.7.0/bundler/gems/test-kitchen-c0b0d8988771/lib/kitchen/command.rb:109:in
`filtered_instances'"
- "/usr/lib/ruby/gems/2.7.0/bundler/gems/test-kitchen-c0b0d8988771/lib/kitchen/command.rb:139:in
`parse_subcommand'"
- "/usr/lib/ruby/gems/2.7.0/bundler/gems/test-kitchen-c0b0d8988771/lib/kitchen/command/diagnose.rb:52:in
`load_instances'"
- "/usr/lib/ruby/gems/2.7.0/bundler/gems/test-kitchen-c0b0d8988771/lib/kitchen/command/diagnose.rb:31:in
`block in call'"
- "/usr/lib/ruby/gems/2.7.0/bundler/gems/test-kitchen-c0b0d8988771/lib/kitchen/command/diagnose.rb:72:in
`record_failure'"
- "/usr/lib/ruby/gems/2.7.0/bundler/gems/test-kitchen-c0b0d8988771/lib/kitchen/command/diagnose.rb:31:in
`call'"
- "/usr/lib/ruby/gems/2.7.0/bundler/gems/test-kitchen-c0b0d8988771/lib/kitchen/cli.rb:52:in
`perform'"
- "/usr/lib/ruby/gems/2.7.0/bundler/gems/test-kitchen-c0b0d8988771/lib/kitchen/cli.rb:142:in
`diagnose'"
- "/usr/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor/command.rb:27:in `run'"
- "/usr/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'"
- "/usr/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch'"
- "/usr/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor/base.rb:485:in `start'"
- "/usr/lib/ruby/gems/2.7.0/bundler/gems/test-kitchen-c0b0d8988771/bin/kitchen:11:in
`block in <top (required)>'"
- "/usr/lib/ruby/gems/2.7.0/bundler/gems/test-kitchen-c0b0d8988771/lib/kitchen/errors.rb:170:in
`with_friendly_errors'"
- "/usr/lib/ruby/gems/2.7.0/bundler/gems/test-kitchen-c0b0d8988771/bin/kitchen:11:in
`<top (required)>'"
- "/usr/lib/ruby/gems/2.7.0/bin/kitchen:23:in `load'"
- "/usr/lib/ruby/gems/2.7.0/bin/kitchen:23:in `<top (required)>'"
- "/usr/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `load'"
- "/usr/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `kernel_load'"
- "/usr/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:28:in `run'"
- "/usr/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli.rb:476:in `exec'"
- "/usr/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in
`run'"
- "/usr/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in
`invoke_command'"
- "/usr/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor.rb:399:in
`dispatch'"
- "/usr/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli.rb:30:in `dispatch'"
- "/usr/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/base.rb:476:in
`start'"
- "/usr/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/cli.rb:24:in `start'"
- "/usr/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/exe/bundle:46:in `block in <top
(required)>'"
- "/usr/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/friendly_errors.rb:123:in
`with_friendly_errors'"
- "/usr/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/exe/bundle:34:in `<top (required)>'"
- "/usr/bin/bundle:23:in `load'"
- "/usr/bin/bundle:23:in `<main>'"
+1
Also tried rolling back kitchen and kitchen-docker from every version to v1 release and same error.
Also input the env_variables at driver and transport layer for logger and same error running docker 19.03.13-ce on arch
I encountered this issue on test-kitchen 2.5.4 (I need the old version for Chef 12 / Ruby 2.3.6 compatibility) and kitchen-docker 2.10.0, but was able to fix it by backing down to kitchen-docker 2.8.0.
It doesn't seem to work either:
$ bundle install
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and
installing your bundle as root will break this application for all non-root
users on this machine.
Fetching gem metadata from https://rubygems.org/..........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies...
Using bundler 2.2.2
[...]
Fetching test-kitchen 2.11.1
Installing test-kitchen 2.11.1
Fetching kitchen-salt 0.6.3
Fetching kitchen-sync 2.2.1
Fetching kitchen-docker 2.8.0
Installing kitchen-salt 0.6.3
Installing kitchen-sync 2.2.1
Installing kitchen-docker 2.8.0
Bundle complete! 4 Gemfile dependencies, 47 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
$ kitchen test
-----> Starting Test Kitchen (v2.11.1)
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ClientError
>>>>>> Message: Could not load the 'docker' transport from the load path. Did you mean: dummy, exec, runtests, ssh, winrm ? Please ensure that your transport is installed as a gem or included in your Gemfile if using Bundler.
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ClientError
>>>>>> Message: Could not load the 'docker' transport from the load path. Did you mean: dummy, exec, runtests, ssh, winrm ? Please ensure that your transport is installed as a gem or included in your Gemfile if using Bundler.
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration
ERROR: Job failed: exit code 20
This seems to fail around the require_relative '../docker/helpers/inspec_helper'
line in kitchen-docker-2.12.0/lib/kitchen/transport/docker.rb
. Adding kitchen-inspec
to my Gemfile fixed it.
@jbussdieker-quiknode Odd... I would have to run this scenario through the debugger (and I will if I ever tackle this issue) but the file you pointed to wraps the require into a begin
block and catches the LoadError. I wouldn't expect it to cause this failure.
Thanks for the lead though. I was unable to reproduce this when I looked at it several months back.
Oddly enough that line wasn't specifically what caused the error. I was adding instrumentation to the code and would get output from puts
before that line but not after. From there I installed inspec and it worked.
I'm guessing the logger
the exception is using doesn't exist which raises an exception inside the handler.
I tested the theory and it worked:
diff --git a/kitchen-docker-2.12.0/lib/docker/version.rb b/kitchen-docker-2.12.0/lib/docker/version.rb
index 70fd25e..ed32290 100644
--- a/kitchen-docker-2.12.0/lib/docker/version.rb
+++ b/kitchen-docker-2.12.0/lib/docker/version.rb
@@ -21,5 +21,5 @@ begin
API_VERSION = '1.24'
end
rescue LoadError => e
- logger.debug("[Docker] docker-api gem not found for InSpec verifier. #{e}")
+ puts("[Docker] docker-api gem not found for InSpec verifier. #{e}")
end
diff --git a/kitchen-docker-2.12.0/lib/kitchen/docker/helpers/inspec_helper.rb b/kitchen-docker-2.12.0/lib/kitchen/docker/helpers/inspec_helper.rb
index 5f0d325..f662543 100644
--- a/kitchen-docker-2.12.0/lib/kitchen/docker/helpers/inspec_helper.rb
+++ b/kitchen-docker-2.12.0/lib/kitchen/docker/helpers/inspec_helper.rb
@@ -36,5 +36,5 @@ begin
end
end
rescue LoadError => e
- logger.debug("[Docker] kitchen-inspec gem not found for InSpec verifier. #{e}")
+ puts("[Docker] kitchen-inspec gem not found for InSpec verifier. #{e}")^M
end
diff --git a/kitchen-docker-2.12.0/lib/kitchen/transport/docker.rb b/kitchen-docker-2.12.0/lib/kitchen/transport/docker.rb
index de31807..e262814 100644
--- a/kitchen-docker-2.12.0/lib/kitchen/transport/docker.rb
+++ b/kitchen-docker-2.12.0/lib/kitchen/transport/docker.rb
@@ -80,7 +80,11 @@ module Kitchen
class Connection < Kitchen::Transport::Docker::Connection
# Include the InSpec patches to be able to execute tests on Windows containers
- include Kitchen::Docker::Helpers::InspecHelper
+ begin
+ include Kitchen::Docker::Helpers::InspecHelper
+ rescue Exception => e
+ puts("Error")
+ end
def execute(command)
return if command.nil?
diff --git a/kitchen-docker-2.12.0/lib/train/docker.rb b/kitchen-docker-2.12.0/lib/train/docker.rb
index 024caae..1fb80b9 100644
--- a/kitchen-docker-2.12.0/lib/train/docker.rb
+++ b/kitchen-docker-2.12.0/lib/train/docker.rb
@@ -121,5 +121,5 @@ begin
end
end
rescue LoadError => e
- logger.debug("[Docker] train gem not found for InSpec verifier. #{e}")
+ puts("[Docker] train gem not found for InSpec verifier. #{e}")
end
So is the workaround still to add the kitchen-inspec
gem?
@olhado I would suggest trying that, yes
That seemed to work!