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

chore(yum_repository): use baseurl property #361

Merged
merged 1 commit into from Sep 19, 2016

Conversation

Projects
None yet
3 participants
@historus
Copy link
Contributor

commented Sep 16, 2016

This was necessary as I recently started getting problems with the url property:

       NoMethodError
       -------------
       undefined method `url' for Chef::Resource::YumRepository

       Cookbook Trace:
       ---------------
       /tmp/kitchen/cache/cookbooks/datadog/recipes/repository.rb:43:in `block in from_file'
       /tmp/kitchen/cache/cookbooks/datadog/recipes/repository.rb:40:in `from_file'
       /tmp/kitchen/cache/cookbooks/datadog/recipes/_install-linux.rb:21:in `from_file'
       /tmp/kitchen/cache/cookbooks/datadog/recipes/dd-agent.rb:24:in `from_file'

Since url is only an alias for baseurl this shouldn't matter.

https://github.com/chef-cookbooks/yum/blob/master/resources/repository.rb#L69

@historus

This comment has been minimized.

Copy link
Contributor Author

commented Sep 16, 2016

chef-stacktrace.out:

/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.60/lib/chef/resource.rb:1347:in method_missing' /tmp/kitchen/cache/cookbooks/datadog/recipes/repository.rb:43:inblock in from_file'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.60/lib/chef/resource_builder.rb:76:in instance_eval' /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.60/lib/chef/resource_builder.rb:76:inbuild'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.60/lib/chef/dsl/declare_resource.rb:285:in build_resource' /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.60/lib/chef/dsl/declare_resource.rb:242:indeclare_resource'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.60/lib/chef/dsl/resources.rb:40:in yum_repository' /tmp/kitchen/cache/cookbooks/datadog/recipes/repository.rb:40:infrom_file'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.60/lib/chef/mixin/from_file.rb:30:in instance_eval' /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.60/lib/chef/mixin/from_file.rb:30:infrom_file'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.60/lib/chef/cookbook_version.rb:233:in load_recipe' /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.60/lib/chef/run_context.rb:327:inload_recipe'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.60/lib/chef/run_context.rb:283:in block in include_recipe' /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.60/lib/chef/run_context.rb:282:ineach'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.60/lib/chef/run_context.rb:282:in include_recipe' /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.60/lib/chef/dsl/include_recipe.rb:26:ininclude_recipe'
/tmp/kitchen/cache/cookbooks/datadog/recipes/_install-linux.rb:21:in from_file' /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.60/lib/chef/mixin/from_file.rb:30:ininstance_eval'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.60/lib/chef/mixin/from_file.rb:30:in from_file' /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.60/lib/chef/cookbook_version.rb:233:inload_recipe'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.60/lib/chef/run_context.rb:327:in load_recipe' /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.60/lib/chef/run_context.rb:283:inblock in include_recipe'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.60/lib/chef/run_context.rb:282:in each' /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.60/lib/chef/run_context.rb:282:ininclude_recipe'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.14.60/lib/chef/dsl/include_recipe.rb:26:in include_recipe' /tmp/kitchen/cache/cookbooks/datadog/recipes/dd-agent.rb:24:infrom_file'

@bai

This comment has been minimized.

Copy link
Contributor

commented Sep 16, 2016

Should there be a condition on chef version? I think older yum_repository accepts only url and new one only baseurl.

@historus

This comment has been minimized.

Copy link
Contributor Author

commented Sep 16, 2016

baseurl (with compatibility for url) has been introduced with chef-cookbooks/yum@03e455c (Commits on Dec 13, 2013). The constraint is more on the yum cookbook, I'll add it.

@olivielpeau

This comment has been minimized.

Copy link
Member

commented Sep 16, 2016

Thanks @historus for this!

For reference, this issue affects a very limited number of Chef versions (between chef/chef@62c04b4 and chef/chef@67e86db, i.e. betweenv12.14.30 and v12.14.64), but it's still worth fixing.

Let's update the version constraint on yum in metadata.rb to >= 3.0 too, thanks! (we already make use of attributes on yum_repository that got added in 3.0, so it already makes sense even without the url/baseurl change)

@historus historus force-pushed the historus:master branch from d3b6451 to 4c852fa Sep 16, 2016

@olivielpeau olivielpeau added this to the 2.6.0 milestone Sep 16, 2016

@olivielpeau olivielpeau added the bug label Sep 16, 2016

@historus historus changed the title chore(url): use baseurl property chore(yum_repository): use baseurl property Sep 16, 2016

metadata.rb Outdated
@@ -24,7 +24,7 @@
depends 'apt' # We recommend '>= 2.1.0'. See CHANGELOG.md for details
depends 'chef_handler', '~> 1.1' # We recommend '~> 1.3' with Chef < 12. See CHANGELOG.md for details
depends 'windows' # We recommend '< 1.39.0' if running Chef >= 12.6. See README.md for details
depends 'yum'
depends 'yum', '~> 3.0'

This comment has been minimized.

Copy link
@olivielpeau

olivielpeau Sep 16, 2016

Member

Let's use an optimistic version constraint here (>= 3.0), I've tested that yum 4.0 works well with our cookbook.

Since yum 4.0 is Chef 12+ only, we should add a comment on that though, i.e.:

depends          'yum', '>= 3.0' # Use '~> 3.0' with Chef < 12

@historus historus force-pushed the historus:master branch from 4c852fa to 5790566 Sep 16, 2016

@olivielpeau

This comment has been minimized.

Copy link
Member

commented Sep 19, 2016

Thanks @historus! Merging, this will be shipped with the next minor release (should be out in the next couple of days)

@olivielpeau olivielpeau merged commit 987bb05 into DataDog:master Sep 19, 2016

2 checks passed

ci/circleci Your tests passed on CircleCI!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.