sous-chefs / mysql

Development repository for the mysql cookbook
https://supermarket.chef.io/cookbooks/mysql
Apache License 2.0
338 stars 690 forks source link

NoMethodError for mysql_service when converging #638

Closed ryutaro-brainlabs closed 4 years ago

ryutaro-brainlabs commented 4 years ago

:ghost: Brief Description

I try to use the mysql_service method and get a NoMethodError. This started happening from version 16.2 of chef infra client and was fine up to version 16.1.

It's possibly related to this breaking change in chef infra client https://docs.chef.io/release_notes/#whats-new-in-162

:pancakes: Cookbook version

8.5.1

:woman_cook: Chef-Infra Version

16.2.44

:tophat: Platform details

ubuntu-1604

Steps To Reproduce

Steps to reproduce the behavior:

In .kitchen.yml

driver:                                                                                               
 name: docker                                                      
 memory: 4294967296                                                                                   
 privileged: true                                                                                     
 use_sudo: false                                                                                      

provisioner:                                                                                          
 name: chef_zero                                                 
 always_update_cookbooks: true                                                                        
 client_rb:                                                                                           
  chef_license: accept                                                                                

verifier:                                                                                             
 name: inspec                                                                                         

platforms:                                                                                            
 - name: ubuntu-16.04                                                                                 
   driver_config:                                                                                     
     run_command: /lib/systemd/systemd                                                                
     pid_one_command: /lib/systemd/systemd

followed by a test suite.

Add this to a recipe and kitchen converge

mysql_service 'default_mysql' do                                                                                                                                                             
  port '3306'                                                                                         
  version '5.7'                                                                                       
  initial_root_password 'asdfadfa'                                                            
  action [:create, :start]                                                                            
end 

:police_car: Expected behavior

Converge successfully.

:heavy_plus_sign: Additional context

Log from trying to converge.

================================================================================
       Recipe Compile Error in /tmp/kitchen/cache/cookbooks/bl_mysql/recipes/default.rb
       ================================================================================

       NoMethodError
       -------------
       undefined method `mysql_service' for cookbook: bl_mysql, recipe: default :Chef::Recipe

       Cookbook Trace: (most recent call first)
       ----------------------------------------
         /tmp/kitchen/cache/cookbooks/bl_mysql/recipes/default.rb:27:in `from_file'

       Relevant File Content:
       ----------------------
       /tmp/kitchen/cache/cookbooks/bl_mysql/recipes/default.rb:

        20:      action :create
        21:      group 'mysql'
        22:      mode '0755'
        23:      owner 'mysql'
        24:    end
        25:  end
        26:  
        27>> mysql_service 'default_mysql' do
...
        31:    port '3306'
        32:    version '5.7'
        33:    initial_root_password 'asdfadf'
        34:    action [:create, :start]
        35:  end
        36:  

       System Info:
       ------------
       chef_version=16.2.44
       platform=ubuntu
       platform_version=16.04
       ruby=ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]
       program_name=/opt/chef/bin/chef-client
       executable=/opt/chef/bin/chef-client
teliov commented 4 years ago

I can also confirm this as well.

I also get the same undefined method 'mysql_service' error running the latest version of chef on Ubuntu 18.04. I had to downgrade chef to get this to work.

axl89 commented 4 years ago

I had to downgrade chef to get this to work.

@teliov to which version exactly? ~I've tried 16.4.41 and 15.13.8-1 and got no luck... and 14's reached EOL in April 2020.~

EDIT: I confirm that with Chef-client 16.4.41 and 15.13.8-1 using cookbook version 8.7.3 the problem is no longer present.

ramereth commented 4 years ago

@ryutaro-brainlabs @teliov can you please confirm that what @axl89 mentioned above?

amy-brainlabs commented 4 years ago

@ryutaro-brainlabs @teliov can you please confirm that what @axl89 mentioned above?

I am covering Ryutaro while he's on sabbatical, unfortunately we are still seeing this error using chef 16.4.4

amy-brainlabs commented 4 years ago

tell a lie, I was too impatient allowing the dependencies to update... all working now 👍