Closed neuronaut closed 6 years ago
@neuronaut thanks for the report, we are still officially supporting chef 11 but will probably be dropping support in the somewhat near future so I would like to fix this for you so you can at least pin it to a working version before you can upgrade to chef 12 or 13. Can I get the full stack trace? It is very hard to troubleshoot with just a general nil class as it is the most generic ruby error ever. I need the context of where it failed to see what is nil and why.
@majormoses Here's the full stack trace I'm getting:
/opt/aws/opsworks/releases/20170401093533_3444-20170401093533/vendor/bundle/ruby/2.0.0/gems/chef-11.10.4/lib/chef/resource/lwrp_base.rb:125:in `initialize'
/opt/aws/opsworks/releases/20170401093533_3444-20170401093533/vendor/bundle/ruby/2.0.0/gems/chef-11.10.4/lib/chef/dsl/recipe.rb:106:in `new'
/opt/aws/opsworks/releases/20170401093533_3444-20170401093533/vendor/bundle/ruby/2.0.0/gems/chef-11.10.4/lib/chef/dsl/recipe.rb:106:in `build_resource'
/opt/aws/opsworks/releases/20170401093533_3444-20170401093533/vendor/bundle/ruby/2.0.0/gems/chef-11.10.4/lib/chef/dsl/recipe.rb:86:in `declare_resource'
/opt/aws/opsworks/releases/20170401093533_3444-20170401093533/vendor/bundle/ruby/2.0.0/gems/chef-11.10.4/lib/chef/dsl/recipe.rb:42:in `method_missing'
/var/lib/aws/opsworks/cache.stage2/cookbooks/utilities/recipes/install_sumologic.rb:17:in `create_source'
/var/lib/aws/opsworks/cache.stage2/cookbooks/utilities/recipes/install_sumologic.rb:34:in `from_file'
/opt/aws/opsworks/releases/20170401093533_3444-20170401093533/vendor/bundle/ruby/2.0.0/gems/chef-11.10.4/lib/chef/mixin/from_file.rb:30:in `instance_eval'
/opt/aws/opsworks/releases/20170401093533_3444-20170401093533/vendor/bundle/ruby/2.0.0/gems/chef-11.10.4/lib/chef/mixin/from_file.rb:30:in `from_file'
/opt/aws/opsworks/releases/20170401093533_3444-20170401093533/vendor/bundle/ruby/2.0.0/gems/chef-11.10.4/lib/chef/cookbook_version.rb:237:in `load_recipe'
/opt/aws/opsworks/releases/20170401093533_3444-20170401093533/vendor/bundle/ruby/2.0.0/gems/chef-11.10.4/lib/chef/run_context.rb:151:in `load_recipe'
/opt/aws/opsworks/releases/20170401093533_3444-20170401093533/vendor/bundle/ruby/2.0.0/gems/chef-11.10.4/lib/chef/run_context/cookbook_compiler.rb:139:in `block in compile_recipes'
/opt/aws/opsworks/releases/20170401093533_3444-20170401093533/vendor/bundle/ruby/2.0.0/gems/chef-11.10.4/lib/chef/run_context/cookbook_compiler.rb:137:in `each'
/opt/aws/opsworks/releases/20170401093533_3444-20170401093533/vendor/bundle/ruby/2.0.0/gems/chef-11.10.4/lib/chef/run_context/cookbook_compiler.rb:137:in `compile_recipes'
/opt/aws/opsworks/releases/20170401093533_3444-20170401093533/vendor/bundle/ruby/2.0.0/gems/chef-11.10.4/lib/chef/run_context/cookbook_compiler.rb:74:in `compile'
/opt/aws/opsworks/releases/20170401093533_3444-20170401093533/vendor/bundle/ruby/2.0.0/gems/chef-11.10.4/lib/chef/run_context.rb:86:in `load'
/opt/aws/opsworks/releases/20170401093533_3444-20170401093533/vendor/bundle/ruby/2.0.0/gems/chef-11.10.4/lib/chef/policy_builder/expand_node_object.rb:75:in `setup_run_context'
/opt/aws/opsworks/releases/20170401093533_3444-20170401093533/vendor/bundle/ruby/2.0.0/gems/chef-11.10.4/lib/chef/client.rb:252:in `setup_run_context'
/opt/aws/opsworks/releases/20170401093533_3444-20170401093533/vendor/bundle/ruby/2.0.0/gems/chef-11.10.4/lib/chef/client.rb:413:in `do_run'
/opt/aws/opsworks/releases/20170401093533_3444-20170401093533/vendor/bundle/ruby/2.0.0/gems/chef-11.10.4/lib/chef/client.rb:200:in `block in run'
/opt/aws/opsworks/releases/20170401093533_3444-20170401093533/vendor/bundle/ruby/2.0.0/gems/chef-11.10.4/lib/chef/client.rb:194:in `fork'
/opt/aws/opsworks/releases/20170401093533_3444-20170401093533/vendor/bundle/ruby/2.0.0/gems/chef-11.10.4/lib/chef/client.rb:194:in `run'
/opt/aws/opsworks/releases/20170401093533_3444-20170401093533/vendor/bundle/ruby/2.0.0/gems/chef-11.10.4/lib/chef/application.rb:215:in `run_chef_client'
/opt/aws/opsworks/releases/20170401093533_3444-20170401093533/vendor/bundle/ruby/2.0.0/gems/chef-11.10.4/lib/chef/application/client.rb:314:in `block in run_application'
/opt/aws/opsworks/releases/20170401093533_3444-20170401093533/vendor/bundle/ruby/2.0.0/gems/chef-11.10.4/lib/chef/application/client.rb:306:in `loop'
/opt/aws/opsworks/releases/20170401093533_3444-20170401093533/vendor/bundle/ruby/2.0.0/gems/chef-11.10.4/lib/chef/application/client.rb:306:in `run_application'
/opt/aws/opsworks/releases/20170401093533_3444-20170401093533/vendor/bundle/ruby/2.0.0/gems/chef-11.10.4/lib/chef/application.rb:66:in `run'
/opt/aws/opsworks/releases/20170401093533_3444-20170401093533/vendor/bundle/ruby/2.0.0/gems/chef-11.10.4/bin/chef-client:26:in `<top (required)>'
/opt/aws/opsworks/current/bin/chef-client:16:in `load'
/opt/aws/opsworks/current/bin/chef-client:16:in `<main>'
It appears that as chef tries to create the resource it calls self.class.resource_name.to_sym
but resource_name
is returning nil.
@neuronaut I will take a look this weekend hopefully.
@neuronaut I am pretty sure its unrelated but as ubuntu 12.04 while is LTS is EOL so I would strongly suggest upgrading/replacing with 14.04 or 16.04.
@majormoses We were just beginning to upgrade to Ubuntu 14.04 when I first reported this issue. Now that we've finished I have retested the recipe on 14.04 but I still get the same issue, so any help you can give would be greatly appreciated!
@neuronaut sorry this kinda fell off my radar and no project I work on uses chef 11 anymore so it has not really been a priority. I'd strongly urge you to upgrade your opsworks to chef 12. I will try to spend some time this week but pretty much all the community cookbooks (latest version) have dropped chef 11 support a long time ago.
I do not see source_name as a resource for that provider: https://github.com/SumoLogic/sumologic-collector-chef-cookbook/blob/v1.2.21/libraries/resource_local_file_source.rb and I checked
can you test if something like this works for you?
role = node.roles[0]
sumo_source_local_file 'localfile-authlog' do
description 'Auth Logs'
source_json_directory node['sumologic']['sumo_json_path']
category "#{node.chef_environment}/auth/#{role}"
path_expression '/var/log/auth.log'
host_name node['fqdn']
only_if { node['platform_family'].include? 'debian' }
end
Feel free to remove and replace the roles stuff I just grabbed that from my wrapper cookbook.
I see it is a name attribute: https://github.com/SumoLogic/sumologic-collector-chef-cookbook/blob/v1.2.21/libraries/resource_source.rb#L23 can you just try removing that? If you want to name the chef resource to test_name
you could do this:
sumo_source_local_file 'test_name' do
source_json_directory "/etc/sumologic"
path_expression "/srv/www/ritani_web_site/shared/log/staging.log"
end
which is equivalent to what you had but probably will work?
I've tried both of the above suggestions as shown but I still get the same error: undefined method `to_sym' for nil:NilClass
.
I had some time today to dig into it a bit and it seems that the error is happening because the class Chef::Resource::SumoSourceLocalFile
returns a nil
when the resource_name
method is called. If you look at the stacktrace I posted above, this is happening in lwrp_base.rb
on line 125 with the code:
@resource_name = self.class.resource_name.to_sym
I'm not sure why SumoSourceLocalFile isn't returning a value for its resource_name
, though.
I will take a closer look later but following what you have discovered this is where I am gonna start investigating:
When I have some time I will look at it but like I said supporting chef 11 is not exactly high priority for me.
As the current major stable version is chef 14 I do not feel it is prudent to put in any effort into diagnosing issues 3 major versions back. I would strongly recommend you invest in upgrading to a recent version of chef. We will probably be looking at officially dropping less than chef 13 in the somewhat short term. Most of the cookbooks I maintain dropped chef 11 support years ago and most of them only support late versions of chef 12. I hope you the best in finding something that works for you and your organization.
AWS is still using Chef 11 and 12 (they have yet to upgrade to newer versions). If you drop support in the short term for anything less than Chef 13 you'll be preventing AWS customers from using your product. This is the problem my (now former) company faced with upgrading chef - we had compatibility problems with the chef 12 stack requirements on AWS that we couldn't fix in the short term and were thus stuck on chef 11 which you don't support. This sort of attitude about not supporting versions of chef used on a very common cloud platform makes me very likely to avoid using SumoLogic at new companies in the future.
@neuronaut I am sorry you feel that way, please note that I am not a sumologic employee so my views may not coincide with theirs. I maintain this cookbook because I want to help and no one else is doing it, asking me to support software that EOL'd over a year ago is not fair (to the maintainers or the users that have to forgo newer features to maintain backwards compatibility) nor is it feasible. Chef 12 has been out since 2014 and I willing to support some of the later versions of chef 12 for a while despite that it is EOL as pf April 30th. See https://blog.chef.io/2018/02/16/preparing-for-chef-14-and-chef-12-end-of-life/ for more information. Chef support for 13 will live on for a while but I can't put in any effort to chef 11 as chef dropped support for that a long time ago see here https://blog.chef.io/2017/03/29/upgrading-chef-client-13.
If you have issues with how chef supports their software you should take it up with them.
When using the resource
sumo_source_local_file
to install a local file source I get the error:undefined method `to_sym' for nil:NilClass
My recipe's source:
Environment Information
sumologic-collector cookbook version: v1.2.21 Chef version 11.10 OS: Ubuntu 12.04 running on AWS
Expected Behavior
A new source should have been installed.
Actual Behavior
Got the above error.
Steps to Reproduce
Important Factoids
I've tried any number of different parameter combinations, but I always get the same result so it doesn't seem to be related to incorrect parameters. I've also tried creating the collector in the same recipe (before creating the source), and alternately making sure that the collector is already installed prior to running the recipe (I even accidentally tried installing a source without having a collector installed) and in all cases got the same error.