Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Kitchen converge doesn't work with docker fresh installation #282

Closed
bsampaio opened this issue Oct 25, 2022 · 2 comments
Closed

Kitchen converge doesn't work with docker fresh installation #282

bsampaio opened this issue Oct 25, 2022 · 2 comments

Comments

@bsampaio
Copy link

bsampaio commented Oct 25, 2022

👻 Issues with kitchen and Docker integration

When trying to run kitchen converge icinga-ubuntu-2204 I got the following error:

-----> Creating <icinga-ubuntu-2204>...
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: 1 actions failed.
>>>>>>     Failed to complete #create action: [undefined method `each' for nil:NilClass] on icinga-ubuntu-2204
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

After checking that everything was well configured I tried the debug option kitchen converge --debug icinga-ubuntu-2204
In the ~/.kitchen/logs/kitchen.log file I found the following error:

E, [2022-10-25T14:54:47.745961 #68914] ERROR -- Kitchen: -Composite Exception--
E, [2022-10-25T14:54:47.745965 #68914] ERROR -- Kitchen: Class: Kitchen::ActionFailed
E, [2022-10-25T14:54:47.745970 #68914] ERROR -- Kitchen: Message: Failed to complete #create action: [undefined method `each' for nil:NilClass] on icinga-ubuntu-2204
E, [2022-10-25T14:54:47.745974 #68914] ERROR -- Kitchen: ----------------------
E, [2022-10-25T14:54:47.745979 #68914] ERROR -- Kitchen: ------Backtrace-------
E, [2022-10-25T14:54:47.745983 #68914] ERROR -- Kitchen: /opt/chef-workstation/embedded/lib/ruby/gems/3.0.0/gems/kitchen-dokken-2.17.3/lib/kitchen/driver/dokken.rb:440:in `docker_config_creds'

By opening the gems file I found the following code:

      def docker_config_creds
        return @docker_config_creds if @docker_config_creds

        @docker_config_creds = {}
        config_file = ::File.join(::Dir.home, ".docker", "config.json")
        if ::File.exist?(config_file)
          JSON.load_file!(config_file)["auths"].each do |k, v|
            next if v["auth"].nil?

            username, password = Base64.decode64(v["auth"]).split(":")
            @docker_config_creds[k] = { serveraddress: k, username: username, password: password }
          end
        else
          debug("~/.docker/config.json does not exist")
        end

        @docker_config_creds
      end

As you can see the loop tries to iterate an "auths" key in ~/.docker/config.json that doesn't exist.

In order to fix the bug, the user must run docker login -u your_docker_username "https://index.docker.io/v1/" or manually add the following "auths" content:

{
  "credsStore": "desktop",
  "auths": {
      "https://index.docker.io/v1/": {}
  }
}

Version

#Chef
Chef Workstation version: 22.10.1013
Chef CLI version: 5.6.1
Chef Habitat version: 1.6.521
Test Kitchen version: 3.3.2
Cookstyle version: 7.32.1

#Gems
Chef Infra Client version: 17.10.0
kitchen-azurerm (1.10.5)
kitchen-digitalocean (0.14.2)
kitchen-dokken (2.17.3)
kitchen-ec2 (3.13.0)
kitchen-google (2.3.0)
kitchen-hyperv (0.7.1)
kitchen-inspec (2.6.1)
kitchen-openstack (6.2.0)
kitchen-vagrant (1.12.1)
kitchen-vcenter (2.11.13)
kitchen-vra (3.2.0)
test-kitchen (3.3.2)

Environment

  Model Name:	MacBook Pro
  Model Identifier:	Mac14,7
  Chip:	Apple M2
  Total Number of Cores:	8 (4 performance and 4 efficiency)
  Memory:	16 GB
  System Firmware Version:	7459.141.1
  OS Loader Version:	7459.141.1
  Serial Number (system):	*********
  Hardware UUID:	B******
  Provisioning UDID:	********
  Activation Lock Status:	Enabled

Scenario

Run kitchen converge and kitchen login in a docker's fresh installation

Steps to Reproduce

Fresh install docker, kitchen and try to run a cookbook.

Expected Result

Docker container up and running

Actual Result

Error

@psacc
Copy link

psacc commented Feb 14, 2023

opened #290 that seems to be duplicate of this one

@damacus
Copy link
Contributor

damacus commented Apr 3, 2023

Closed via #287

@damacus damacus closed this as completed Apr 3, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants