Skip to content

feat: added use_internal_docker_network feature#304

Merged
tas50 merged 1 commit intotest-kitchen:masterfrom
amalucelli:use_internal_docker_network
Jan 18, 2019
Merged

feat: added use_internal_docker_network feature#304
tas50 merged 1 commit intotest-kitchen:masterfrom
amalucelli:use_internal_docker_network

Conversation

@amalucelli
Copy link
Copy Markdown
Contributor

As I don't have write access in the base branch of the PR #283, I forked from master, made the changes of the origin PR and also the one suggested in the comments.

Co-authored-by: @AaronKalair

@codecov-io
Copy link
Copy Markdown

codecov-io commented Aug 7, 2018

Codecov Report

Merging #304 into master will decrease coverage by 0.99%.
The diff coverage is 14.28%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #304   +/-   ##
=======================================
- Coverage   33.77%   32.78%   -1%     
=======================================
  Files           2        2           
  Lines         228      241   +13     
=======================================
+ Hits           77       79    +2     
- Misses        151      162   +11
Impacted Files Coverage Δ
lib/kitchen/driver/docker.rb 31.46% <14.28%> (-0.96%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 57a8771...0d48229. Read the comment docs.

@jcalonso
Copy link
Copy Markdown

+1 for this, I'm running a Dind (Docker in Docker) setup and I'm getting the following error:

----End Backtrace-----
[integration:L554:28s] D      ---Nested Exception---
[integration:L555:28s] D      Class: Kitchen::ActionFailed
[integration:L556:28s] D      Message: Failed to complete #create action: [Address not available - connect(2) for [::1]:32771]
[integration:L557:28s] D      ----------------------
[integration:L558:28s] D      ------Backtrace-------
[integration:L559:28s] D      /usr/lib/ruby/2.4.0/socket.rb:1198:in `__connect_nonblock'
[integration:L560:28s] D      /usr/lib/ruby/2.4.0/socket.rb:1198:in `connect_nonblock'
[integration:L561:28s] D      /usr/lib/ruby/2.4.0/socket.rb:56:in `connect_internal'
[integration:L562:28s] D      /usr/lib/ruby/2.4.0/socket.rb:137:in `connect'
[integration:L563:28s] D      /usr/lib/ruby/2.4.0/socket.rb:627:in `block in tcp'
[integration:L564:28s] D      /usr/lib/ruby/2.4.0/socket.rb:227:in `each'
[integration:L565:28s] D      /usr/lib/ruby/2.4.0/socket.rb:227:in `foreach'
[integration:L566:28s] D      /usr/lib/ruby/2.4.0/socket.rb:617:in `tcp'
[integration:L567:28s] D      /usr/lib/ruby/gems/2.4.0/gems/net-ssh-4.2.0/lib/net/ssh/transport/session.rb:70:in `initialize'
[integration:L568:28s] D      /usr/lib/ruby/gems/2.4.0/gems/net-ssh-4.2.0/lib/net/ssh.rb:237:in `new'
[integration:L569:28s] D      /usr/lib/ruby/gems/2.4.0/gems/net-ssh-4.2.0/lib/net/ssh.rb:237:in `start'
...

@robertlabrie
Copy link
Copy Markdown

Can we please have this? I do a terrible hack of clobbering localhost in /etc/hosts to work around it


def container_ip(state)
begin
cmd = "inspect --format '{{ .NetworkSettings.IPAddress }}'"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amalucelli @AaronKalair FYI, there is an issue when using this setup with user defined networks.

In those cases, the IPAddress at the NetworkSettings level is empty, and instead needs to be found on the Network. That nested value is also there when using the default bridge network, so I would think that it should be safe to use in any case:
I was able to get this working by changing the template to '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}'

@timogoebel
Copy link
Copy Markdown
Contributor

Nice, I needed this to get kitchen-docker working on gitlab-ci.

Please see the .gitlab-ci.yml on how to use this patch before it's merged.

image: ruby:2.5-alpine
services:
  - docker:dind

stages:
  - functional

verify-centos-7:
  before_script:
    - apk add docker libffi-dev build-base patch
    - docker info
    - bundle install
    - cd $(bundle show kitchen-docker)
    - wget -O use_internal_docker_network.patch https://patch-diff.githubusercontent.com/raw/test-kitchen/kitchen-docker/pull/304.patch
    - patch -p1 < use_internal_docker_network.patch
    - cd -
  stage: functional
  tags:
    - aws
  artifacts:
    expire_in: 7d
    when: on_failure
    paths:
      - .kitchen/logs
  script:
    - kitchen test default-centos-7 -d always

@ayanich
Copy link
Copy Markdown

ayanich commented Oct 22, 2018

I also need this to get things running on circleci, would love to see this get merged.

@jtimberman
Copy link
Copy Markdown

Hello,

I've verified that this works using our CI system, too.

This script is what I used to apply the PR, install the gem with ChefDK, and run Test Kitchen in my cookbook repository.

#!/bin/bash
mkdir -p /kitchen
pushd /kitchen
  git clone https://github.com/test-kitchen/kitchen-docker
  pushd kitchen-docker
  git fetch origin pull/304/head:use_internal_docker_network
  git checkout use_internal_docker_network
  chef exec bundle install
  chef exec bundle exec rake install
  popd
popd

chef exec kitchen test

@tas50 tas50 merged commit 8f6038d into test-kitchen:master Jan 18, 2019
@tas50
Copy link
Copy Markdown
Member

tas50 commented Jan 18, 2019

Merging based on @jtimberman's experience

@amalucelli amalucelli deleted the use_internal_docker_network branch January 18, 2019 18:38
@Nklya
Copy link
Copy Markdown

Nklya commented Jan 23, 2019

It seems that I cannot use kitchen-docker with use_internal_docker_network: true on macOS because docker for mac doesn't connect local and docker networks.

Will investigate and maybe create another PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants