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

windows_package resource uses property success_codes #416

Closed
straeth1 opened this issue Mar 24, 2017 · 5 comments
Closed

windows_package resource uses property success_codes #416

straeth1 opened this issue Mar 24, 2017 · 5 comments

Comments

@straeth1
Copy link

On Windows machines with the datadog cookbook, I run into the following error in the client.log:

[2017-03-24T15:15:46+00:00] INFO: Platform: x64-mingw32
[2017-03-24T15:15:46+00:00] INFO: Chef-client pid: 2608
[2017-03-24T15:16:14+00:00] INFO: Run List is [recipe[delivery-base], recipe[act_datadog::default]]
[2017-03-24T15:16:14+00:00] INFO: Run List expands to [delivery-base, act_datadog::default]
[2017-03-24T15:16:14+00:00] INFO: Starting Chef Run for ew1bw-datadoga1
[2017-03-24T15:16:14+00:00] INFO: Running start handlers
[2017-03-24T15:16:14+00:00] INFO: Start handlers complete.
[2017-03-24T15:16:15+00:00] INFO: Loading cookbooks [act_datadog@0.1.2, apt@6.0.1, chef_handler@1.4.0, compat_resource@12.16.3, datadog@2.8.1, windows@3.0.2, yum@5.0.0, chef-ingredient@0.21.0, delivery-base@0.2.2, packagecloud@0.3.0, push-jobs@3.2.2, runit@1.8.0, yum-epel@2.1.1, line@0.6.3, ohai@5.0.0]
[2017-03-24T15:16:16+00:00] ERROR: Running exception handlers
[2017-03-24T15:16:16+00:00] ERROR: Exception handlers complete
[2017-03-24T15:16:16+00:00] INFO: Sending resource update report (run-id: 5f3d8923-1bf4-4cba-b363-43c4cdbf61f7)
[2017-03-24T15:16:16+00:00] FATAL: Stacktrace dumped to C:/chef/cache/chef-stacktrace.out
[2017-03-24T15:16:16+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2017-03-24T15:16:16+00:00] FATAL: NoMethodError: undefined method `success_codes' for Chef::Resource::WindowsPackage

The Stacktrace points to the _install-windows.rb recipe that uses a property which is not supported by the core Chef windows_package resource.

Generated at 2017-03-24 15:16:16 +0000
NoMethodError: undefined method `success_codes' for Chef::Resource::WindowsPackage
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/resource.rb:1377:in `method_missing'
C:/chef/cache/cookbooks/datadog/recipes/_install-windows.rb:51:in `block in from_file'
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/resource_builder.rb:76:in `instance_eval'
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/resource_builder.rb:76:in `build'
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/dsl/declare_resource.rb:291:in `build_resource'
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/dsl/declare_resource.rb:248:in `declare_resource'
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/dsl/resources.rb:39:in `windows_package'
C:/chef/cache/cookbooks/datadog/recipes/_install-windows.rb:46:in `from_file'
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/mixin/from_file.rb:30:in `instance_eval'
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/mixin/from_file.rb:30:in `from_file'
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/cookbook_version.rb:233:in `load_recipe'
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/run_context.rb:338:in `load_recipe'
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/run_context.rb:294:in `block in include_recipe'
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/run_context.rb:293:in `each'
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/run_context.rb:293:in `include_recipe'
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/dsl/include_recipe.rb:26:in `include_recipe'
C:/chef/cache/cookbooks/datadog/recipes/dd-agent.rb:32:in `from_file'
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/mixin/from_file.rb:30:in `instance_eval'
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/mixin/from_file.rb:30:in `from_file'
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/cookbook_version.rb:233:in `load_recipe'
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/run_context.rb:338:in `load_recipe'
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/run_context.rb:294:in `block in include_recipe'
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/run_context.rb:293:in `each'
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/run_context.rb:293:in `include_recipe'
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/dsl/include_recipe.rb:26:in `include_recipe'
C:/chef/cache/cookbooks/act_datadog/recipes/default.rb:12:in `from_file'
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/mixin/from_file.rb:30:in `instance_eval'
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/mixin/from_file.rb:30:in `from_file'
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/cookbook_version.rb:233:in `load_recipe'
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/run_context.rb:338:in `load_recipe'
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/run_context/cookbook_compiler.rb:141:in `block in compile_recipes'
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/run_context/cookbook_compiler.rb:138:in `each'
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/run_context/cookbook_compiler.rb:138:in `compile_recipes'
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/run_context/cookbook_compiler.rb:75:in `compile'
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/run_context.rb:187:in `load'
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/policy_builder/expand_node_object.rb:97:in `setup_run_context'
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/client.rb:511:in `setup_run_context'
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/client.rb:281:in `run'
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/application.rb:277:in `run_with_graceful_exit_option'
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/application.rb:253:in `block in run_chef_client'
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/local_mode.rb:44:in `with_server_connectivity'
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/application.rb:236:in `run_chef_client'
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/application/client.rb:464:in `sleep_then_run_chef_client'
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/application/client.rb:451:in `block in interval_run_chef_client'
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/application/client.rb:450:in `loop'
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/application/client.rb:450:in `interval_run_chef_client'
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/application/client.rb:434:in `run_application'
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/application.rb:59:in `run'
C:/opscode/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/bin/chef-client:26:in `<top (required)>'
C:/opscode/chef/bin/chef-client:68:in `load'
C:/opscode/chef/bin/chef-client:68:in `<main>'

I think this is a left over when the windows community cookbook had a windows_package resource on its own, but the community windows cookbook has removed that resource as of v 3.0.0.

IMHO to fix this you would just need to replace line 88 in _install-windows.rb with

returns [0, 3010]
@olivielpeau
Copy link
Member

Thanks @straeth1 for the feedback!

We've also identified this issue, which is one of the reasons why the latest version of the present cookbook (2.9.0) is explicitly not compatible with windows 3.x (see https://github.com/DataDog/chef-datadog/blob/v2.9.0/metadata.rb#L26).
(The other reasons being that we've simply haven't had the chance to test how the cookbook behaves on different versions of Chef when the core resource is used instead of the resource that's provided by windows < 3.0).

Do you need windows cookbook at version 3.x or would 2.x/1.x work on your environment?

Fixing this issue by replacing success_codes with returns would work only with windows >= 1.39.0 (since the attribute alias was introduced in that cookbook in chef-boneyard/windows@1a7ad4d). Adding a respond_to? conditional would probably work though. Does that make sense?

@straeth1
Copy link
Author

Hi Olivier
Pinning the windows cookbook to a specific version is fine with me at the moment and I am glad that you have already started to address the issue.

@olivielpeau
Copy link
Member

This is resolved with #438 and released with version 2.10.1 of the present cookbook, thanks again @straeth1 for your feedback!

@SaurabhDev
Copy link

I am still getting the same issue with windows >=3.0
NoMethodError: visualstudio_edition[visualstudio_2015_community] (visualstudio::install line 29) had an error: NoMethodError: undefined method success_codes' for Chef::Resource::WindowsPackage C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.5.3-universal-mingw32/lib/chef/resource.rb:1297:in method_missing'

Could you please provide the solution as I am unable to find install_windows.rb in windows package

@chen01
Copy link

chen01 commented Jan 8, 2018

@SaurabhDev as it was said above the solution is to use returns instead of success_codes
example:

windows_package 'blah' do
      returns [0, 3010] 
      ...
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants