test-kitchen / kitchen-dokken

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

Getting `Failed to get D-Bus connection` error when converging Amazon Linux 2 #286

Open jmvbxx opened 1 year ago

jmvbxx commented 1 year ago

:speaking_head: Foreword

Thank for taking the time to fill this bug report fully. Without it we may not be able to fix the bug, and the issue may be closed without resolution.

:ghost: Brief Description

Unable to converge an Amazon Linux 2 container and getting the following error

STDERR: Failed to get D-Bus connection: No such file or directory

Version

    kitchen-dokken (2.8.2)
      docker-api (~> 1.33)
      lockfile (~> 2.1)
      test-kitchen (>= 1.15, < 3)

Environment

Scenario

Trying, unsuccessfully, to converge an Amazon Linux 2 Docker container

Steps to Reproduce

Here is my config:

driver:
  name: dokken
  chef_version: 17.10.0
  chef_image: doximity/cinc
  chef_binary: /opt/chef/bin/cinc-client
  env:
    - AWS_REGION=<%= ENV['AWS_REGION'] %>
    - AWS_ACCESS_KEY_ID=<%= ENV['AWS_ACCESS_KEY_ID'] %>
    - AWS_SECRET_ACCESS_KEY=<%= ENV['AWS_SECRET_ACCESS_KEY'] %>
    - AWS_SESSION_TOKEN=<%= ENV['AWS_SESSION_TOKEN'] %>

transport:
  name: dokken

provisioner:
  name: dokken
  product_version: 14.999
  deprecations_as_errors: false
  nodes_path: test/fixtures/nodes
  roles_path: test/fixtures/roles
  environments_path: test/fixtures/environments
  client_rb:
    environment: kitchen

verifier:
  name: inspec

platforms:
  - name: amazonlinux
    driver:
      image: dokken/amazonlinux-2
      privileged: true
      pid_one_command: /usr/lib/systemd/systemd
      cgroupns_host: true
      volumes:
        - /sys/fs/cgroup:/sys/fs/cgroup:rw

The above platforms configuration is based on https://kitchen.ci/docs/drivers/dokken/#cgroupns_host but I'm still getting the following full error:

    Mixlib::ShellOut::ShellCommandFailed
    ------------------------------------
    Expected process to exit with [0], but received '1'
    ---- Begin output of ["/usr/bin/systemctl", "--system", "show", "-p", "UnitFileState", "-p", "ActiveState", "sensu-agent"] ----
    STDOUT: 
    STDERR: Failed to get D-Bus connection: No such file or directory
    ---- End output of ["/usr/bin/systemctl", "--system", "show", "-p", "UnitFileState", "-p", "ActiveState", "sensu-agent"] ----
    Ran ["/usr/bin/systemctl", "--system", "show", "-p", "UnitFileState", "-p", "ActiveState", "sensu-agent"] returned 1

Expected Result

I expect the container to spin up and converge correctly

Actual Result

I shared the error message above

octavian2204 commented 11 months ago

same issue. it seems kitchen is ignoring cgroupns_host parameter:

here is the kitchen.yml:

---
driver:
  name: dokken
  privileged: true
  cgroupns_host: true
  volumes:
    - /sys/fs/cgroup:/sys/fs/cgroup:rw

provisioner:
  name: dokken
  chef_license: accept-no-persist
  log_level: <%= ENV['CHEF_LOG_LEVEL'] || 'auto' %>

transport:
  name: dokken

platforms:
  - name: debian-11
    driver:
      # image: dokken/debian-12:sha-e9e4388
      image: dokken/debian-11
      pid_one_command: /bin/systemd
      intermediate_instructions:
        - ENV DEBIAN_FRONTEND noninteractive
        - RUN /usr/bin/apt-get update -y
        - RUN /usr/bin/apt-get install -y nano ca-certificates sudo apt-transport-https lsb-release procps net-tools
....
root@amd64:~/rabbitmq-rabbitmq-poc# kitchen list
Instance          Driver  Provisioner  Verifier  Transport  Last Action    Last Error
node01-debian-11  Dokken  Dokken       Inspec    Dokken     Created        Kitchen::ActionFailed
root@amd64:~/rabbitmq-rabbitmq-poc# docker ps
 CONTAINER ID   IMAGE                                COMMAND          CREATED          STATUS          PORTS                                              NAMES
dbecfd139288   124df55356-node01-debian-11:latest   "/bin/systemd"   41 seconds ago   Up 40 seconds   0.0.0.0:9001->15671/tcp, 0.0.0.0:9000->15672/tcp   124df55356-node01-debian-11
root@amd64:~/rabbitmq-rabbitmq-poc# docker inspect 124df55356-node01-debian-11 | grep CgroupnsMode
            "CgroupnsMode": "private",