Search code examples
chef-infraworkflowverifydepends

Chef Workflow fails on Verify stage when cookbook has dependencies


I am using the Workflow portion of Chef Automate to deliver cookbooks to my Chef Server. I have successfully uploaded 2 cookbooks on the Chef Server through the pipeline.

On the Chef Server:
apache is at version 0.2.3
another_test is at version 0.1.1

I wanted to make a change to apache to depend on another_test, so I updated the metadata for apache and bumped the version to 0.2.4.

The metadata file for apache has depends 'another_test' and another_test has no dependencies.

The Berksfile for apache is

source :chef_server
source 'https://supermarket.chef.io'
metadata

When I make the delivery review call, the pipeline kicks off but I get a failure in the unit test phase of the Verify stage.

execute[unit_rspec_apache] action run

================================================================================
Error executing action `run` on resource 'execute[unit_rspec_apache]' ================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of rspec --format documentation --color ----
STDOUT: [2017-11-21T14:06:57+00:00] ERROR: Connection refused connecting to https://localhost/universe, retry 1/5
[2017-11-21T14:07:02+00:00] ERROR: Connection refused connecting to https://localhost/universe, retry 2/5
[2017-11-21T14:07:07+00:00] ERROR: Connection refused connecting to https://localhost/universe, retry 3/5
[2017-11-21T14:07:12+00:00] ERROR: Connection refused connecting to https://localhost/universe, retry 4/5
[2017-11-21T14:07:17+00:00] ERROR: Connection refused connecting to https://localhost/universe, retry 5/5

An error occurred in a `before(:suite)` hook. Failure/Error: raise NoSolutionError.new(demands, e)

Berkshelf::NoSolutionError: Unable to satisfy constraints on package another_test, which does not exist, due to solution constraint (apache = 0.2.4). Solution constraints that may result in a constraint on another_test: [(apache = 0.2.4) -> (another_test >= 0.0.0)]
Missing artifacts: another_test
Demand that cannot be met: (apache = 0.2.4)
Unable to find a solution for demands: apache (0.2.4)

Because of this failure, the new version of apache 0.2.4 is never uploaded to the Chef Server.

EDIT: I have tested using a dependency form the supermarket and it passes the verify stage. So I had depends 'java' in apache and that gets uploaded fine. The problem starts when I am depending on a cookbook that comes from my chef server.

EDIT 2: I can log into the runner and do knife cookbook list. This proves to me that the runner can access the chef server and see what cookbooks exist there. I have also tried changing the Berksfile for apache to have source 'https://<full-url-to-chef-server/organizations/myorg' in place of source :chef_server


Solution

  • I had to edit the /var/opt/delivery/workspace/.chef/knife.rb file on the runner node. I added this line at the bottom of the file: chef_server_url 'https://chef-server/organizations/myorg'.

    This knife config file is used by the dbuild user on the runner node. It reads this file to determine the URL for the chef server.