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

Lots of log WARNings when using apt cookbook ("Deprecation class overwrites LWRP resource apt_preference from cookbook apt") #163

Closed
tknerr opened this issue Sep 22, 2015 · 8 comments

Comments

@tknerr
Copy link

tknerr commented Sep 22, 2015

I recently noticed that I'm getting lots of these warnings when using the apt cookbook:

[2015-09-22T21:35:22+00:00] WARN: You declared a new resource #<Class:0x0000000641b418> for resource apt_preference, but it comes alphabetically after LWRP resource apt_preference from cookbook apt and has the same filters ({}), so it will not be used. Use override: true if you want to use it for apt_preference.
[2015-09-22T21:35:22+00:00] WARN: AptPreference already exists!  Deprecation class overwrites LWRP resource apt_preference from cookbook apt
[2015-09-22T21:35:22+00:00] WARN: You declared a new resource #<Class:0x00000006412368> for resource apt_repository, but it comes alphabetically after LWRP resource apt_repository from cookbook apt and has the same filters ({}), so it will not be used. Use override: true if you want to use it for apt_repository.
[2015-09-22T21:35:22+00:00] WARN: AptRepository already exists!  Deprecation class overwrites LWRP resource apt_repository from cookbook apt

This is using Chef 12.4.1 with chef zero provisioner, happening during a chefspec run

@tknerr
Copy link
Author

tknerr commented Sep 22, 2015

Googling doesn't help too much, the only stuff I'm finding are logs from travis-ci:
http://www.google.com/search?q="AptRepository+already+exists!+Deprecation+class+overwrites+LWRP+resource+apt_repository+from+cookbook+apt"

@andrewjamesbrown
Copy link

This appears to be coming from Chef::Platform::HandlerMap in 12.4.1, though it isn't obvious why ChefSpec is triggering these warnings. FWIW, I see similar errors using the sudo cookbook.
@jkeiser, can you shed any light on why we've begun to see these messages?

Thanks!

@WarFox
Copy link

WarFox commented Oct 1, 2015

I'm getting similar warning for a custom LWRP

[2015-10-01T10:16:47+01:00] WARN: You declared a new resource #<Class:0x007fa901bac690> for resource #{resource_name}, but it comes alphabetically after LWRP resource #{resource_name} from cookbook #{cookbook_name} and has the same filters ({}), so it will not be used. Use override: true if you want to use it for #{resource_name}.
[2015-10-01T10:16:47+01:00] WARN: #{resource_name} already exists!  Deprecation class overwrites LWRP resource #{resource_name} from cookbook #{cookbook_name}

I've also noticed that this warning only comes when I use ChefSpec::Runner

runner = ChefSpec::ServerRunner.new do |node, server|

ChefSpec::SoloRunner doesn't go around whining about this.

Hope this helps to narrow down the issue a bit.

@tknerr
Copy link
Author

tknerr commented Oct 1, 2015

Is this still present with the recently released Chefspec 4.4.0 version?
Am 01.10.2015 11:46 vorm. schrieb "Deepu Mohan Puthrote" <
notifications@github.com>:

I'm getting similar warning for a custom LWRP

[2015-10-01T10:16:47+01:00] WARN: You declared a new resource #Class:0x007fa901bac690 for resource #{resource_name}, but it comes alphabetically after LWRP resource #{resource_name} from cookbook #{cookbook_name} and has the same filters ({}), so it will not be used. Use override: true if you want to use it for #{resource_name}.
[2015-10-01T10:16:47+01:00] WARN: #{resource_name} already exists! Deprecation class overwrites LWRP resource #{resource_name} from cookbook #{cookbook_name}

I've also noticed that this warning only comes when I use ChefSpec::Runner

runner = ChefSpec::ServerRunner.new do |node, server|

ChefSpec::SoloRunner doesn't go around whining about this.

Hope this helps to narrow down the issue a bit.


Reply to this email directly or view it on GitHub
#163 (comment).

@andrewjamesbrown
Copy link

@tknerr, yes I can confirm I'm still seeing this with ChefSpec 4.4.0

@jzohrab
Copy link

jzohrab commented Feb 25, 2016

(Posted in issue 642 above, reposting here) Hey all, a hack workaround for this is to redirect stdout during the chefspec converge, and restore it afterwards. Code:

  let (:chef_run) do
    # Redirecting stdout to suppress 'Deprecation class overwrites LWRP' noise.
    # (ref https://github.com/sethvargo/chefspec/issues/642)
    old_std_out = $stdout.clone
    $stdout.reopen('tmp_std_out.txt', 'w')
    result = chef_runner.converge(described_recipe)
    $stdout.reopen(old_std_out)
    File.read('tmp_std_out.txt').each_line do |lin|
      puts lin unless lin =~ /Deprecation class overwrites LWRP resource/
    end
    File.delete('tmp_std_out.txt')
    result
  end

@tas50
Copy link
Contributor

tas50 commented Jan 10, 2017

We'll be solving this soon by using compat_resource to provide the update and repository functionality. This aligns the code base with core chef and eliminates double code loading

@tas50
Copy link
Contributor

tas50 commented Feb 9, 2017

We've removed the sources from this cookbook so you shouldn't see this warnings in the 6.0 release now.

@tas50 tas50 closed this as completed Feb 9, 2017
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

5 participants