Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Chefspec version 7.3.4 causes failures due to definitions being deprecated #588

Closed
lordkage opened this issue Jan 6, 2019 · 5 comments
Closed

Comments

@lordkage
Copy link

lordkage commented Jan 6, 2019

Cookbook version

5.2.1

Chef-client version

chefdk 3.6.57
chef 14.8.12
chefspec 7.3.4

Platform Details

Development OS: Mac OS 13
Target OS: CentOS 7

Scenario:

Including apache2::default causes unit testing to fail. Period. Integration and deployment still appear to be unaffected.

Steps to Reproduce:

Include the apache2::default on recipe that has a spec file, run chefspec against it.

Expected Result:

Unit testing to proceed as expected.

Actual Result:

================================================================================
Recipe Compile Error in /var/folders/7x/jmvtwc388xj8xw001s76t54h0000gn/T/chefspec20190105-43843-1v7wnnefile_cache_path/cookbooks/mentat/recipes/apache.rb
================================================================================

NoMethodError
-------------
undefined method `params' for nil:NilClass

Cookbook Trace:
---------------
  /var/folders/7x/jmvtwc388xj8xw001s76t54h0000gn/T/chefspec20190105-43843-1v7wnnefile_cache_path/cookbooks/apache2/recipes/default.rb:179:in `block in from_file'
  /var/folders/7x/jmvtwc388xj8xw001s76t54h0000gn/T/chefspec20190105-43843-1v7wnnefile_cache_path/cookbooks/apache2/recipes/default.rb:178:in `each'
  /var/folders/7x/jmvtwc388xj8xw001s76t54h0000gn/T/chefspec20190105-43843-1v7wnnefile_cache_path/cookbooks/apache2/recipes/default.rb:178:in `from_file'
  /var/folders/7x/jmvtwc388xj8xw001s76t54h0000gn/T/chefspec20190105-43843-1v7wnnefile_cache_path/cookbooks/mentat/recipes/apache.rb:7:in `from_file'

Relevant File Content:
----------------------
/var/folders/7x/jmvtwc388xj8xw001s76t54h0000gn/T/chefspec20190105-43843-1v7wnnefile_cache_path/cookbooks/apache2/recipes/default.rb:

172:      apache_binary: apache_binary,
173:      apache_dir: apache_dir
174:    )
175:    notifies :reload, 'service[apache2]', :delayed
176:  end
177:
178:  %w(security charset).each do |conf|
179>>   apache_conf conf do
180:      enable true
181:    end
182:  end
183:
184:  template 'ports.conf' do
185:    path "#{apache_dir}/ports.conf"
186:    source 'ports.conf.erb'
187:    mode '0644'
188:    notifies :restart, 'service[apache2]', :delayed

System Info:
------------
chef_version=14.8.12
platform=centos
platform_version=7.5.1804
ruby=ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-darwin16]
program_name=/opt/chefdk/embedded/bin/rspec
executable=/opt/chefdk/embedded/bin/rspec

Related Chefspec issue: chefspec/chefspec#926

@damacus
Copy link
Member

damacus commented Jan 6, 2019

This is fixed on master as we've now moved away from definitions, we're just making the last few steps of making sure it works.

If you want to give master a spin instead of 5.2.1 (as of writing this ng the latest on Supermarket), turn you should have some better luck with this.

If this doesn't work, or run with your orgs expectations, then I suggest dropping the unit testing and focusing on integration testing for now.

Closing as won't fix.

@damacus damacus closed this as completed Jan 6, 2019
@lordkage
Copy link
Author

lordkage commented Jan 6, 2019

I filed this issue for two reasons:

  1. To bring better visibility to why this is a problem, as it took me two days to back trace where it popped up. The chef.io documentation still lists definitions as "deprecated," and not dead in current versions of chef. The README's referenced issue in version 5.2.1, do not indicate that it would break testing if you moved past a certain version of chefspec.

  2. Ask; is there an ETA on when the new "definition-less" version of the cookbook will be cut?
    I tried master a few days ago, and it was a less then wonderful experience. I will give it another spin, as I was moving many pieces around at that point. However, a new "accepted" cut version would be preferable over a the floating endpoint of master.

@damacus
Copy link
Member

damacus commented Jan 6, 2019

Yeah, I really hear you on this one. It's been a thorn on my side for 6+ months, rewriting this and getting some of the magic better documented.

This milestone is what's left to be written https://github.com/sous-chefs/apache2/milestone/8

I'm currently working on the ssl & website resource as we speak. So if you're OK with no mod_php support, I'm inclined the cut v6 at that point

@lordkage
Copy link
Author

Unfortunately, I am leveraging mod_php and mod_ssl as part of the cookbook I am currently building. I have set my chefdk to and older version for the moment, until the version is available.

openstack-gerrit pushed a commit to openstack-archive/openstack-chef that referenced this issue Jul 5, 2019
Using the chef-client baked into ChefDK is causing issues with the
fog-openstack gem since it is locked in ChefDK. To work around this and
better mimic how this is used in production, switch the integration
tests to installing chef-client instead of ChefDK.

- Split out pre-run playbooks between delivery and integration (keep
  ChefDK for delivery)
- Install Chef 14 by default
- Install Berkshelf in Chef
- Install cookstyle which is needed in the Rakefile
- Update command paths so that berkshelf is available with Chef and
  ChefDK
- Update ChefDK to 3.2.30 but not higher due to issues with chefspec and
  apache2 [1]
- Upgrade fog-openstack gem to work around extraneous warnings to match
  cookbook-openstackclient
- Remove unneeded pip downgrade

[1] sous-chefs/apache2#588

Change-Id: I0b0c2eb80dc0d831685cc7f69a1186a6148e6258
Signed-off-by: Lance Albertson <lance@osuosl.org>
openstack-gerrit pushed a commit to openstack/openstack that referenced this issue Jul 5, 2019
* Update openstack-chef from branch 'master'
  - Install and use Chef Client instead of ChefDK on integration tests
    
    Using the chef-client baked into ChefDK is causing issues with the
    fog-openstack gem since it is locked in ChefDK. To work around this and
    better mimic how this is used in production, switch the integration
    tests to installing chef-client instead of ChefDK.
    
    - Split out pre-run playbooks between delivery and integration (keep
      ChefDK for delivery)
    - Install Chef 14 by default
    - Install Berkshelf in Chef
    - Install cookstyle which is needed in the Rakefile
    - Update command paths so that berkshelf is available with Chef and
      ChefDK
    - Update ChefDK to 3.2.30 but not higher due to issues with chefspec and
      apache2 [1]
    - Upgrade fog-openstack gem to work around extraneous warnings to match
      cookbook-openstackclient
    - Remove unneeded pip downgrade
    
    [1] sous-chefs/apache2#588
    
    Change-Id: I0b0c2eb80dc0d831685cc7f69a1186a6148e6258
    Signed-off-by: Lance Albertson <lance@osuosl.org>
@lock
Copy link

lock bot commented Jan 13, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants