test-kitchen/kitchen-docker

Message: Error getting internal IP of Docker container

paulcalabro opened this issue · 4 comments

I think the call to super is happening prematurely in linux.rb, resulting in the code trying to determine an IP address of a non-existent container:

D      ------Backtrace-------
D      /var/jenkins_home/workspace/Happy-Tests/vendor/bundle/ruby/2.5.0/bundler/gems/kitchen-docker-c2f715e79a34/lib/kitchen/docker/helpers/container_helper.rb:141:in `rescue in container_ip_address'
D      /var/jenkins_home/workspace/Happy-Tests/vendor/bundle/ruby/2.5.0/bundler/gems/kitchen-docker-c2f715e79a34/lib/kitchen/docker/helpers/container_helper.rb:136:in `container_ip_address'
D      /var/jenkins_home/workspace/Happy-Tests/vendor/bundle/ruby/2.5.0/bundler/gems/kitchen-docker-c2f715e79a34/lib/kitchen/docker/container.rb:45:in `create'
D      /var/jenkins_home/workspace/Happy-Tests/vendor/bundle/ruby/2.5.0/bundler/gems/kitchen-docker-c2f715e79a34/lib/kitchen/docker/container/linux.rb:32:in `create'
D      /var/jenkins_home/workspace/Happy-Tests/vendor/bundle/ruby/2.5.0/bundler/gems/kitchen-docker-c2f715e79a34/lib/kitchen/driver/docker.rb:123:in `create'
D      /var/jenkins_home/workspace/Happy-Tests/vendor/bundle/ruby/2.5.0/gems/test-kitchen-2.2.5/lib/kitchen/instance.rb:485:in `public_send'
D      /var/jenkins_home/workspace/Happy-Tests/vendor/bundle/ruby/2.5.0/gems/test-kitchen-2.2.5/lib/kitchen/instance.rb:485:in `block in perform_action'
D      /var/jenkins_home/workspace/Happy-Tests/vendor/bundle/ruby/2.5.0/gems/test-kitchen-2.2.5/lib/kitchen/instance.rb:552:in `synchronize_or_call'
D      /var/jenkins_home/workspace/Happy-Tests/vendor/bundle/ruby/2.5.0/gems/test-kitchen-2.2.5/lib/kitchen/instance.rb:514:in `block in action'
D      /usr/lib/ruby/2.5.0/benchmark.rb:293:in `measure'
D      /var/jenkins_home/workspace/Happy-Tests/vendor/bundle/ruby/2.5.0/gems/test-kitchen-2.2.5/lib/kitchen/instance.rb:513:in `action'
D      /var/jenkins_home/workspace/Happy-Tests/vendor/bundle/ruby/2.5.0/gems/test-kitchen-2.2.5/lib/kitchen/instance.rb:485:in `perform_action'
D      /var/jenkins_home/workspace/Happy-Tests/vendor/bundle/ruby/2.5.0/gems/test-kitchen-2.2.5/lib/kitchen/instance.rb:394:in `create_action'
D      /var/jenkins_home/workspace/Happy-Tests/vendor/bundle/ruby/2.5.0/gems/test-kitchen-2.2.5/lib/kitchen/instance.rb:382:in `block (2 levels) in transition_to'
D      /var/jenkins_home/workspace/Happy-Tests/vendor/bundle/ruby/2.5.0/gems/test-kitchen-2.2.5/lib/kitchen/lifecycle_hooks.rb:45:in `run_with_hooks'
D      /var/jenkins_home/workspace/Happy-Tests/vendor/bundle/ruby/2.5.0/gems/test-kitchen-2.2.5/lib/kitchen/instance.rb:381:in `block in transition_to'
D      /var/jenkins_home/workspace/Happy-Tests/vendor/bundle/ruby/2.5.0/gems/test-kitchen-2.2.5/lib/kitchen/instance.rb:380:in `each'
D      /var/jenkins_home/workspace/Happy-Tests/vendor/bundle/ruby/2.5.0/gems/test-kitchen-2.2.5/lib/kitchen/instance.rb:380:in `transition_to'
D      /var/jenkins_home/workspace/Happy-Tests/vendor/bundle/ruby/2.5.0/gems/test-kitchen-2.2.5/lib/kitchen/instance.rb:129:in `create'
D      /var/jenkins_home/workspace/Happy-Tests/vendor/bundle/ruby/2.5.0/gems/test-kitchen-2.2.5/lib/kitchen/command.rb:197:in `public_send'
D      /var/jenkins_home/workspace/Happy-Tests/vendor/bundle/ruby/2.5.0/gems/test-kitchen-2.2.5/lib/kitchen/command.rb:197:in `run_action_in_thread'
D      /var/jenkins_home/workspace/Happy-Tests/vendor/bundle/ruby/2.5.0/gems/test-kitchen-2.2.5/lib/kitchen/command.rb:169:in `block (2 levels) in run_action'
D      /var/jenkins_home/workspace/Happy-Tests/vendor/bundle/ruby/2.5.0/gems/logging-2.2.2/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'
D      ----End Backtrace-----

If instead I invoke super after run_container has been invoked, I can see the following state change (of interest to me is the hostname since I'm using use_internal_docker_network):

p state
state[:port] = container_ssh_port(state)
super
p state
{:username=>"kitchen", :hostname=>"localhost", :last_error=>"Kitchen::ActionFailed", :ssh_key=>"/var/jenkins_home/workspace/Happy-Tests/.kitchen/docker_id_rsa", :image_id=>"ff956abf52be", :container_id=>"4c20e4d8df538f48cf7d2c27a063a187d50cb3fd745f61c46d5a18ce33c7c835"}
{:username=>"kitchen", :hostname=>"192.168.160.3", :last_error=>"Kitchen::ActionFailed", :ssh_key=>"/var/jenkins_home/workspace/Happy-Tests/.kitchen/docker_id_rsa", :image_id=>"ff956abf52be", :container_id=>"4c20e4d8df538f48cf7d2c27a063a187d50cb3fd745f61c46d5a18ce33c7c835", :port=>22}

I'll open a PR in a little bit with a fix.

@paulcalabro PR #369 was just merged to the master branch which I believe should resolve this issue. It sounds like this issue is the same as #366. If you're able to, could you test with the latest fix from this PR?

I'll leave this issue open for now, but will close it after a couple of weeks if there are no updates. Thanks.

@jeffreycoe okay, i'll test this out this week. thank you!

Hi @paulcalabro - Did you have a chance to test the fix in PR #369?

I'm closing this issue as I believe this is resolved. Please open a new issue if there are still issues with the latest release. Thanks.