test-kitchen / kitchen-dokken

Test Kitchen driver/provisioner for lightning faster Chef Infra cookbook testing with Docker
Other
197 stars 91 forks source link

[DinD/CI] Did not find config file: /opt/kitchen/client.rb #149

Open docwhat opened 6 years ago

docwhat commented 6 years ago

This is bug #105 continued but only for the case of running in DinD or CI.

# DinD ChefDK dockerfile
FROM chef/chefdk:current

RUN apt-get update \
      && apt-get install -y apt-transport-https ca-certificates curl software-properties-common

RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - \
      && add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \
      && apt-get update \
      && apt-get install -y docker-ce
# Start it this way...
$ docker run \
      -it --rm \
      --init \
      --volume=/var/run/docker.sock:/var/run/docker.sock:rw \
      --volume=/sys/fs/cgroup:/sys/fs/cgroup:rw \
      --tmpfs=/tmp --tmpfs=/cookbook \
      --volume=<full-path-to-a-cookbook>:/cookbook-ro:ro
      <name-for-image-above> bash
root@docker: rsync -a /cookbook-ro/ /cookbook/
root@docker: chef exec kitchen converge
-----> Starting Kitchen (v1.20.0)
-----> Converging <default-ubuntu-1604>...
       Creating kitchen sandbox in /root/.dokken/kitchen_sandbox/293e786b89-default-ubuntu-1604
       Preparing dna.json
       Resolving cookbook dependencies with Berkshelf 6.3.1...
       Removing non-cookbook files before transfer
       Preparing validation.pem
       Preparing client.rb
[2018-03-26T20:05:59+00:00] WARN: *****************************************
[2018-03-26T20:05:59+00:00] WARN: Did not find config file: /opt/kitchen/client.rb, using command line options.
[2018-03-26T20:05:59+00:00] WARN: *****************************************
[2018-03-26T20:05:59+00:00] WARN: No cookbooks directory found at or above current directory.  Assuming /.
[2018-03-26T20:05:59+00:00] WARN: No cookbooks directory found at or above current directory.  Assuming /.
[2018-03-26T20:05:59+00:00] FATAL: Cannot load configuration from /opt/kitchen/dna.json
[2018-03-26T20:05:59+00:00] FATAL: Cannot load configuration from /opt/kitchen/dna.json
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: 1 actions failed.
>>>>>>     Converge failed on instance <default-ubuntu-1604>.  Please see .kitchen/logs/default-ubuntu-1604.log for more details
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration
acondrat commented 6 years ago

Hi,

Is there any workaround for this issue? I can reproduce it 100% of time.

Thanks

docwhat commented 6 years ago

Nope. I can reproduce it 100% of the time, too...

espoelstra commented 6 years ago

When you are running DiD I believe you MUST creat the same folder layout on the host as you are attempting to mount things into the inner container from. Eg /var/jenkins_home/workspace is used in a Jenkins Docker and -v $(pwd):/src/files is used in a Docker run by Jenkins to build a job, then on the host of the Jenkins Docker I also need /var/jenkins_home/workspace to exist, even if I was using -v ~/projects/jenkins_docker/jenkins_home:/var/jenkins_home/ when spinning up the Jenkins container.

zakame commented 5 years ago

I was exploring integrating dokken with drone and encountered this as well.

The solution seems to be indicated in where dokken makes its sandboxes:

-----> Starting Kitchen (v1.23.2)
-----> Creating <default-ubuntu-1604>...
       Creating kitchen sandbox at /root/.dokken/kitchen_sandbox/b0dce010a4-default-ubuntu-1604
       Creating verifier sandbox at /root/.dokken/verifier_sandbox/b0dce010a4-default-ubuntu-1604
       Building work image..

As the sandboxes reside in /root/.dokken, this directory can be mounted from the host back into the DinD, e.g. in .drone.yml

pipeline:
  test:
    image: chef/chefdk:latest
    environment:
      - KITCHEN_LOCAL_YAML=.kitchen.dokken.yml
    commands:
      - chef --version
      - kitchen test centos-7
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /root/.dokken:/root/.dokken
askz commented 5 years ago

Hi @zakame I tried it but I get the same error... Any update on this ?

jtimberman commented 5 years ago

I can confirm that mounting the volume /root/.dokken as described will work in our DinD CI system.

I think this is a specific configuration thing that needs to be done on each project and isn't in scope of Dokken.

bbros-dev commented 4 years ago

Been wrestling with this today.

Conclusion: I wonder if one of the following two options is the path of least resistance:

  1. Build Dokken images starting from the docker:dind, and some history here.
  2. Fix the local transport kitchen-local.
ramereth commented 3 years ago

@bbros-dev related to kitchen-local... I believe that functionality is already included with the exec transport already built into kitchen. You can see an example of using that provider in the ark cookbook GitHub Action tests.

bbros-dev commented 3 years ago

Thanks @ramereth we've moved away from DinD and more generally Docker.