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

chef 12 ignores default_release for apt_package #2606

Closed
ThomasPr opened this issue Dec 10, 2014 · 7 comments

Comments

Projects
None yet
5 participants
@ThomasPr
Copy link

commented Dec 10, 2014

I just figured out an issue after upgrading to chef 12. When specifying a default_release option for apt_package this option will be ignored.

Small example:

apt_package "haveged" do
  default_release "wheezy-backports"
end

I would expect that chef installs 1.9.1-1~bpo70+1, but it actually installs 1.4-4. Using chef 11.16 this works as expected and installs haveged from backports. Please have a look below for a full recipe that illustrates the issue.

I'm able to reproduce this issue on two clean VMs, installed only Chef 11.16.4 on the first one and 12.0.1 on the second. After executing the example recipe below I get haveged 1.9.1-1~bpo70+1 on the first VM and 1.4-4 on the second. The only difference between these two machines is the chef version.

Full example recipe to reproduce the issue:

file "/etc/apt/sources.list" do
  content <<-EOF
    deb http://ftp.de.debian.org/debian/ wheezy main
    deb http://security.debian.org/ wheezy/updates main
    deb http://ftp.de.debian.org/debian/ wheezy-updates main
    deb http://ftp.de.debian.org/debian/ wheezy-backports main contrib non-free
  EOF
  notifies :run, "execute[apt-get update]", :immediately
end

execute "apt-get update" do
  command "apt-get update"
  action :nothing
end

apt_package "haveged" do
  default_release "wheezy-backports"
end
@lamont-granquist

This comment has been minimized.

Copy link
Contributor

commented Dec 10, 2014

Can you post some debug log information from the 11.x run and the 12.x run?

@lamont-granquist

This comment has been minimized.

Copy link
Contributor

commented Dec 10, 2014

Also is the execute[apt-get update] resource redefined anywhere else? do you have the apt cookbook also installed in the run-list? are you getting any CHEF-3694 errors on that resource?

@ThomasPr

This comment has been minimized.

Copy link
Author

commented Dec 10, 2014

Chef 11.x

  * apt_package[haveged] action install[2014-12-10T19:15:18+01:00] INFO: Processing apt_package[haveged] action install (main::test line 18)
[2014-12-10T19:15:18+01:00] DEBUG: apt_package[haveged] checking package status for haveged
haveged:
  Installed: (none)
  Candidate: 1.9.1-1~bpo70+1
  Version table:
     1.9.1-1~bpo70+1 0
        990 http://ftp.de.debian.org/debian/ wheezy-backports/main amd64 Packages
     1.4-4 0
        500 http://ftp.de.debian.org/debian/ wheezy/main amd64 Packages
[2014-12-10T19:15:18+01:00] DEBUG: apt_package[haveged] current version is nil
[2014-12-10T19:15:18+01:00] DEBUG: apt_package[haveged] candidate version is 1.9.1-1~bpo70+1
Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
  init-system-helpers libhavege1
The following NEW packages will be installed:
  haveged init-system-helpers libhavege1
0 upgraded, 3 newly installed, 0 to remove and 28 not upgraded.
Need to get 74.8 kB of archives.
After this operation, 254 kB of additional disk space will be used.
Get:1 http://ftp.de.debian.org/debian/ wheezy-backports/main libhavege1 amd64 1.9.1-1~bpo70+1 [27.0 kB]
Get:2 http://ftp.de.debian.org/debian/ wheezy-backports/main init-system-helpers all 1.18~bpo70+1 [14.2 kB]
Get:3 http://ftp.de.debian.org/debian/ wheezy-backports/main haveged amd64 1.9.1-1~bpo70+1 [33.6 kB]
Fetched 74.8 kB in 0s (735 kB/s)
Selecting previously unselected package libhavege1:amd64.
(Reading database ... 36669 files and directories currently installed.)
Unpacking libhavege1:amd64 (from .../libhavege1_1.9.1-1~bpo70+1_amd64.deb) ...
Selecting previously unselected package init-system-helpers.
Unpacking init-system-helpers (from .../init-system-helpers_1.18~bpo70+1_all.deb) ...
Selecting previously unselected package haveged.
Unpacking haveged (from .../haveged_1.9.1-1~bpo70+1_amd64.deb) ...
Processing triggers for man-db ...
Setting up libhavege1:amd64 (1.9.1-1~bpo70+1) ...
Setting up init-system-helpers (1.18~bpo70+1) ...
Setting up haveged (1.9.1-1~bpo70+1) ...

    - install version 1.9.1-1~bpo70+1 of package haveged
[2014-12-10T19:15:25+01:00] INFO: Chef Run complete in 11.596860059 seconds

Chef 12.x

  * apt_package[haveged] action install[2014-12-10T19:45:40+01:00] INFO: Processing apt_package[haveged] action install (main::test line 18)
[2014-12-10T19:45:40+01:00] DEBUG: providers for generic apt_package resource enabled on node include: [Chef::Provider::Package::Apt]
[2014-12-10T19:45:40+01:00] DEBUG: providers that refused resource apt_package[haveged] were: []
[2014-12-10T19:45:40+01:00] DEBUG: providers that support resource apt_package[haveged] include: [Chef::Provider::Package::Apt]
[2014-12-10T19:45:40+01:00] DEBUG: providers that survived replacement include: [Chef::Provider::Package::Apt]
[2014-12-10T19:45:40+01:00] DEBUG: apt_package[haveged] checking package status for haveged
haveged:
  Installed: (none)
  Candidate: 1.4-4
  Version table:
     1.9.1-1~bpo70+1 0
        100 http://ftp.de.debian.org/debian/ wheezy-backports/main amd64 Packages
     1.4-4 0
        500 http://ftp.de.debian.org/debian/ wheezy/main amd64 Packages
[2014-12-10T19:45:40+01:00] DEBUG: apt_package[haveged] current version is nil
[2014-12-10T19:45:40+01:00] DEBUG: apt_package[haveged] candidate version is 1.4-4
Reading package lists...
Building dependency tree...
Reading state information...
The following NEW packages will be installed:
  haveged
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 29.5 kB of archives.
After this operation, 105 kB of additional disk space will be used.
Get:1 http://ftp.de.debian.org/debian/ wheezy/main haveged amd64 1.4-4 [29.5 kB]
Fetched 29.5 kB in 0s (162 kB/s)
Selecting previously unselected package haveged.
(Reading database ... 40391 files and directories currently installed.)
Unpacking haveged (from .../haveged_1.4-4_amd64.deb) ...
Processing triggers for man-db ...
Setting up haveged (1.4-4) ...

    - install version 1.4-4 of package haveged
[2014-12-10T19:45:46+01:00] INFO: Chef Run complete in 11.042679929 seconds

Before this debug output, chef executes apt-get update, there is no difference between chef 11.x and 12.x. The run-list contains only the recipe of my previous post, there is no apt cookbook installed.

As you can see in the output above there is a difference in the pin priority of the backports package. It looks like that Chef 12 doesn't forward the default-release option to apt. The following snippet is part of the apt-get manpage:

-t, --target-release, --default-release
    This option controls the default input to the policy engine; it creates a default
    pin at priority 990 using the specified release string. This overrides the general
    settings in /etc/apt/preferences. Specifically pinned packages are not affected by
    the value of this option. In short, this option lets you have simple control over
    which distribution packages will be retrieved from. Some common examples might be
    -t '2.1*', -t unstable or -t sid. Configuration Item: APT::Default-Release; see
    also the apt_preferences(5) manual page.

Let me know if I can provide any further information.

@lamont-granquist lamont-granquist added this to the 12.0.2 milestone Dec 10, 2014

@lamont-granquist

This comment has been minimized.

Copy link
Contributor

commented Dec 10, 2014

So under "checking package status" in the version table, it looks like the backports priority went from 990 to 100, not sure where that comes from.

@lamont-granquist

This comment has been minimized.

Copy link
Contributor

commented Dec 10, 2014

Okay I suspect this is at fault:

        def default_release_options
          # Use apt::Default-Release option only if provider was explicitly defined
          "-o APT::Default-Release=#{@new_resource.default_release}" if @new_resource.provider && @new_resource.default_release
        end

I think this is really a @new_resource.respond_to?(:default_release) check written in an entirely convoluted way that we broke.

@pelletiermaxime

This comment has been minimized.

Copy link

commented Dec 15, 2014

I also ran in this problem.
Also, I don't know if thsi is related, but it now executes the apt commands with the system locale (french in my case), so it doesn't detect package installation (apt-cache policy returns it's results in french). Should I open a separate issues for this ?

@lamont-granquist

This comment has been minimized.

Copy link
Contributor

commented Dec 15, 2014

Yeah the locale problem is separate, please open a new issue.

@thommay thommay added Type: Bug and removed Bug labels Jan 25, 2017

@chef chef locked and limited conversation to collaborators Nov 16, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.