apt icon indicating copy to clipboard operation
apt copied to clipboard

Converge of apt::default fails as it tries to install version of a package that does not exist

Open jburns24 opened this issue 2 years ago • 0 comments

:ghost: Brief Description

apt's default recipe failed to converge on a freshly installed instance of ubuntu server 22.04. Chef log shows that apt-get update was not ran. But failed when trying to call apt_package[apt-transport-https, gnupg, dirmngr] action install

:pancakes: Cookbook version

apt (7.4.2)

:man_cook: Chef-Infra Version

Chef Client, version 14.15.6

:tophat: Platform details

Ubuntu Server 22.04

Steps To Reproduce

  1. Create a new vm from ubuntu server 22.04 iso
  2. Run chef with [apt::default] as the first recipe

:police_car: Expected behavior

I would expect the default recipe to converge

:heavy_plus_sign: Additional context

looking at the full build log I can see that chef was trying to install apt-transport-https version2.4.6. On the node I ran apt-cache apt-transport-https and saw that this was the Candidate version report by the apt-cache

user@server:/tmp/chef-1665596308/cookbooks/apt$ apt-cache policy apt-transport-https
apt-transport-https:
  Installed: (none)
  Candidate: 2.4.6
  Version table:
     2.4.6 500
        500 http://archive.ubuntu.com/ubuntu jammy-updates/universe amd64 Packages
     2.4.5 500
        500 http://archive.ubuntu.com/ubuntu jammy/universe amd64 Packages

I looked at this output because it looks like this is where the package resource is looking to determine what version of the package to install https://github.com/chef/chef/blob/main/lib/chef/provider/package/apt.rb#L176

My guess on what is happening is that the default recipe does not update the apt-cache if it has been updated in the last 24 hours. I am not yet sure how chef is determining if the apt-cache has been updated but I am just guessing that since this was a fresh server. That the apt cookbook was incorrectly thinking that apt cache had just been updated and thus did not update the cache. And then consequently attempts to download a version of a package that ubuntu is no longer serving.

I manually ran apt-get update and after that I verified the apt-cache for apt-transport-https' candidate version was one that archive.ubuntu was serving.

user@server:/tmp/chef-1665596308/cookbooks/apt$ sudo apt-get update
Hit:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Get:2 http://archive.ubuntu.com/ubuntu jammy-updates InRelease [114 kB]
Get:3 http://archive.ubuntu.com/ubuntu jammy-backports InRelease [99.8 kB]
Get:4 http://archive.ubuntu.com/ubuntu jammy-security InRelease [110 kB]
Get:5 http://archive.ubuntu.com/ubuntu jammy/main amd64 c-n-f Metadata [30.3 kB]
Get:6 http://archive.ubuntu.com/ubuntu jammy/restricted amd64 c-n-f Metadata [488 B]
Get:7 http://archive.ubuntu.com/ubuntu jammy/universe amd64 c-n-f Metadata [286 kB]
Get:8 http://archive.ubuntu.com/ubuntu jammy/multiverse amd64 c-n-f Metadata [8,372 B]
Get:9 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages [633 kB]
Get:10 http://archive.ubuntu.com/ubuntu jammy-updates/main Translation-en [147 kB]
Get:11 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 c-n-f Metadata [8,964 B]
Get:12 http://archive.ubuntu.com/ubuntu jammy-updates/restricted amd64 Packages [373 kB]
Get:13 http://archive.ubuntu.com/ubuntu jammy-updates/restricted Translation-en [57.4 kB]
Get:14 http://archive.ubuntu.com/ubuntu jammy-updates/restricted amd64 c-n-f Metadata [524 B]
Get:15 http://archive.ubuntu.com/ubuntu jammy-updates/universe amd64 Packages [430 kB]
Get:16 http://archive.ubuntu.com/ubuntu jammy-updates/universe Translation-en [109 kB]
Get:17 http://archive.ubuntu.com/ubuntu jammy-updates/universe amd64 c-n-f Metadata [4,404 B]
Get:18 http://archive.ubuntu.com/ubuntu jammy-updates/multiverse amd64 Packages [7,220 B]
Get:19 http://archive.ubuntu.com/ubuntu jammy-updates/multiverse Translation-en [2,360 B]
Get:20 http://archive.ubuntu.com/ubuntu jammy-updates/multiverse amd64 c-n-f Metadata [420 B]
Get:21 http://archive.ubuntu.com/ubuntu jammy-backports/main amd64 Packages [3,008 B]
Get:22 http://archive.ubuntu.com/ubuntu jammy-backports/main Translation-en [1,432 B]
Get:23 http://archive.ubuntu.com/ubuntu jammy-backports/main amd64 c-n-f Metadata [272 B]
Get:24 http://archive.ubuntu.com/ubuntu jammy-backports/restricted amd64 c-n-f Metadata [116 B]
Get:25 http://archive.ubuntu.com/ubuntu jammy-backports/universe amd64 Packages [6,752 B]
Get:26 http://archive.ubuntu.com/ubuntu jammy-backports/universe Translation-en [9,240 B]
Get:27 http://archive.ubuntu.com/ubuntu jammy-backports/universe amd64 c-n-f Metadata [352 B]
Get:28 http://archive.ubuntu.com/ubuntu jammy-backports/multiverse amd64 c-n-f Metadata [116 B]
Get:29 http://archive.ubuntu.com/ubuntu jammy-security/main amd64 Packages [370 kB]
Get:30 http://archive.ubuntu.com/ubuntu jammy-security/main Translation-en [84.1 kB]
Get:31 http://archive.ubuntu.com/ubuntu jammy-security/main amd64 c-n-f Metadata [3,924 B]
Get:32 http://archive.ubuntu.com/ubuntu jammy-security/restricted amd64 Packages [334 kB]
Get:33 http://archive.ubuntu.com/ubuntu jammy-security/restricted Translation-en [51.5 kB]
Get:34 http://archive.ubuntu.com/ubuntu jammy-security/restricted amd64 c-n-f Metadata [524 B]
Get:35 http://archive.ubuntu.com/ubuntu jammy-security/universe amd64 Packages [290 kB]
Get:36 http://archive.ubuntu.com/ubuntu jammy-security/universe Translation-en [64.0 kB]
Get:37 http://archive.ubuntu.com/ubuntu jammy-security/universe amd64 c-n-f Metadata [2,408 B]
Get:38 http://archive.ubuntu.com/ubuntu jammy-security/multiverse amd64 c-n-f Metadata [228 B]
Fetched 3,645 kB in 1s (2,468 kB/s)
Reading package lists... Done
user@server:/tmp/chef-1665596308/cookbooks/apt$ apt-cache policy apt-transport-https
apt-transport-https:
  Installed: (none)
  Candidate: 2.4.8
  Version table:
     2.4.8 500
        500 http://archive.ubuntu.com/ubuntu jammy-updates/universe amd64 Packages
     2.4.5 500
        500 http://archive.ubuntu.com/ubuntu jammy/universe amd64 Packages

Full chef log

[10.103.16.49] out: Starting Chef Client, version 14.15.6
[10.103.16.49] out: resolving cookbooks for run list: ["chef-linux-base::default", "company-teamcity::sacramento", "company-teamcity::server"]
[10.103.16.49] out: Synchronizing Cookbooks:
[10.103.16.49] out:   - company-teamcity (0.1.0)
[10.103.16.49] out:   - apt (7.4.2)
[10.103.16.49] out:   - chef-linux-base (0.1.0)
[10.103.16.49] out:   - windows-library (0.1.0)
[10.103.16.49] out:   - vs-2017 (1.1.1)
[10.103.16.49] out:   - java (7.0.0)
[10.103.16.49] out:   - firefox (6.0.0)
[10.103.16.49] out:   - chrome (4.0.2)
[10.103.16.49] out:   - git (10.1.0)
[10.103.16.49] out:   - powershell (6.1.3)
[10.103.16.49] out:   - dotnetframework (2.0.0)
[10.103.16.49] out:   - windows-automation (0.4.0)
[10.103.16.49] out:   - windows (4.2.5)
[10.103.16.49] out:   - iis (7.1.1)
[10.103.16.49] out:   - homebrew (5.3.1)
[10.103.16.49] out:   - dmg (4.1.1)
[10.103.16.49] out:   - ms_dotnet (6.0.0)
[10.103.16.49] out: Installing Cookbook Gems:
[10.103.16.49] out: Compiling Cookbooks...
[10.103.16.49] out: [2022-10-12T11:23:56-07:00] WARN: Resource windows_auto_run from the client is overriding the resource from a cookbook. Please upgrade your cookbook or remove the cookbook from your run_list.
[10.103.16.49] out: [2022-10-12T11:23:56-07:00] WARN: Resource windows_certificate from the client is overriding the resource from a cookbook. Please upgrade your cookbook or remove the cookbook from your run_list.
[10.103.16.49] out: [2022-10-12T11:23:56-07:00] WARN: Resource windows_feature from the client is overriding the resource from a cookbook. Please upgrade your cookbook or remove the cookbook from your run_list.
[10.103.16.49] out: [2022-10-12T11:23:56-07:00] WARN: Resource windows_feature_dism from the client is overriding the resource from a cookbook. Please upgrade your cookbook or remove the cookbook from your run_list.
[10.103.16.49] out: [2022-10-12T11:23:56-07:00] WARN: Resource windows_feature_powershell from the client is overriding the resource from a cookbook. Please upgrade your cookbook or remove the cookbook from your run_list.
[10.103.16.49] out: [2022-10-12T11:23:56-07:00] WARN: Resource windows_font from the client is overriding the resource from a cookbook. Please upgrade your cookbook or remove the cookbook from your run_list.
[10.103.16.49] out: [2022-10-12T11:23:56-07:00] WARN: Resource windows_pagefile from the client is overriding the resource from a cookbook. Please upgrade your cookbook or remove the cookbook from your run_list.
[10.103.16.49] out: [2022-10-12T11:23:56-07:00] WARN: Resource windows_path from the client is overriding the resource from a cookbook. Please upgrade your cookbook or remove the cookbook from your run_list.
[10.103.16.49] out: [2022-10-12T11:23:56-07:00] WARN: Resource windows_printer from the client is overriding the resource from a cookbook. Please upgrade your cookbook or remove the cookbook from your run_list.
[10.103.16.49] out: [2022-10-12T11:23:56-07:00] WARN: Resource windows_printer_port from the client is overriding the resource from a cookbook. Please upgrade your cookbook or remove the cookbook from your run_list.
[10.103.16.49] out: [2022-10-12T11:23:56-07:00] WARN: Resource windows_share from the client is overriding the resource from a cookbook. Please upgrade your cookbook or remove the cookbook from your run_list.
[10.103.16.49] out: [2022-10-12T11:23:56-07:00] WARN: Resource windows_shortcut from the client is overriding the resource from a cookbook. Please upgrade your cookbook or remove the cookbook from your run_list.
[10.103.16.49] out: [2022-10-12T11:23:56-07:00] WARN: Resource windows_task from the client is overriding the resource from a cookbook. Please upgrade your cookbook or remove the cookbook from your run_list.
[10.103.16.49] out: [2022-10-12T11:23:56-07:00] WARN: Resource dmg_package from the client is overriding the resource from a cookbook. Please upgrade your cookbook or remove the cookbook from your run_list.
[10.103.16.49] out: Converging 137 resources
[10.103.16.49] out: Recipe: chef-linux-base::default
[10.103.16.49] out:   * execute[sed -i "s/^127\.0\.0\.1.*/127.0.0.1 localhost $(cat /etc/hostname)/g" /etc/hosts] action run (skipped due to only_if)
[10.103.16.49] out: Recipe: apt::default
[10.103.16.49] out:   * file[/var/lib/apt/periodic/update-success-stamp] action nothing (skipped due to action :nothing)
[10.103.16.49] out:   * apt_update[periodic] action periodic (up to date)
[10.103.16.49] out:   * execute[apt-get update] action nothing (skipped due to action :nothing)
[10.103.16.49] out:   * execute[apt-get autoremove] action nothing (skipped due to action :nothing)
[10.103.16.49] out:   * execute[apt-get autoclean] action nothing (skipped due to action :nothing)
[10.103.16.49] out:   * directory[/var/cache/local] action create (up to date)
[10.103.16.49] out:   * directory[/var/cache/local/preseeding] action create (up to date)
[10.103.16.49] out:   * template[/etc/apt/apt.conf.d/10dpkg-options] action create (up to date)
[10.103.16.49] out:   * template[/etc/apt/apt.conf.d/10recommends] action create (up to date)
[10.103.16.49] out:   * apt_package[apt-transport-https, gnupg, dirmngr] action install
[10.103.16.49] out:
[10.103.16.49] out:     ================================================================================
[10.103.16.49] out:     Error executing action `install` on resource 'apt_package[apt-transport-https, gnupg, dirmngr]'
[10.103.16.49] out:     ================================================================================
[10.103.16.49] out:
[10.103.16.49] out:     Mixlib::ShellOut::ShellCommandFailed
[10.103.16.49] out:     ------------------------------------
[10.103.16.49] out:     Expected process to exit with [0], but received '100'
[10.103.16.49] out:     ---- Begin output of ["apt-get", "-q", "-y", "--allow-downgrades", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confold", "install", "apt-transport-https=2.4.6"] ----
[10.103.16.49] out:     STDOUT: Reading package lists...
[10.103.16.49] out:     Building dependency tree...
[10.103.16.49] out:     Reading state information...
[10.103.16.49] out:     The following NEW packages will be installed:
[10.103.16.49] out:       apt-transport-https
[10.103.16.49] out:     0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
[10.103.16.49] out:     Need to get 1,510 B of archives.
[10.103.16.49] out:     After this operation, 169 kB of additional disk space will be used.
[10.103.16.49] out:     Err:1 http://archive.ubuntu.com/ubuntu jammy-updates/universe amd64 apt-transport-https all 2.4.6
[10.103.16.49] out:       404  Not Found [IP: 91.189.91.39 80]
[10.103.16.49] out:     STDERR: E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/universe/a/apt/apt-transport-https_2.4.6_all.deb  404  Not Found [IP: 91.189.91.39 80]
[10.103.16.49] out:     E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
[10.103.16.49] out:     ---- End output of ["apt-get", "-q", "-y", "--allow-downgrades", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confold", "install", "apt-transport-https=2.4.6"] ----
[10.103.16.49] out:     Ran ["apt-get", "-q", "-y", "--allow-downgrades", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confold", "install", "apt-transport-https=2.4.6"] returned 100
[10.103.16.49] out:
[10.103.16.49] out:     Resource Declaration:
[10.103.16.49] out:     ---------------------
[10.103.16.49] out:     # In /root/.chef/local-mode-cache/cache/cookbooks/apt/recipes/default.rb
[10.103.16.49] out:
[10.103.16.49] out:      95: package %w(apt-transport-https gnupg dirmngr) do
[10.103.16.49] out:      96:   only_if { apt_installed? }
[10.103.16.49] out:      97: end
[10.103.16.49] out:
[10.103.16.49] out:     Compiled Resource:
[10.103.16.49] out:     ------------------
[10.103.16.49] out:     # Declared in /root/.chef/local-mode-cache/cache/cookbooks/apt/recipes/default.rb:95:in `from_file'
[10.103.16.49] out:
[10.103.16.49] out:     apt_package("apt-transport-https, gnupg, dirmngr") do
[10.103.16.49] out:       package_name ["apt-transport-https", "gnupg", "dirmngr"]
[10.103.16.49] out:       action [:install]
[10.103.16.49] out:       default_guard_interpreter :default
[10.103.16.49] out:       declared_type :package
[10.103.16.49] out:       cookbook_name "apt"
[10.103.16.49] out:       recipe_name "default"
[10.103.16.49] out:       only_if { #code block }
[10.103.16.49] out:     end
[10.103.16.49] out:
[10.103.16.49] out:     System Info:
[10.103.16.49] out:     ------------
[10.103.16.49] out:     chef_version=14.15.6
[10.103.16.49] out:     platform=ubuntu
[10.103.16.49] out:     platform_version=22.04
[10.103.16.49] out:     ruby=ruby 2.5.8p224 (2020-03-31 revision 67882) [x86_64-linux]
[10.103.16.49] out:     program_name=/opt/chef/bin/chef-client
[10.103.16.49] out:     executable=/opt/chef/bin/chef-client
[10.103.16.49] out:
[10.103.16.49] out:
[10.103.16.49] out: Running handlers:
[10.103.16.49] out: [2022-10-12T11:23:57-07:00] ERROR: Running exception handlers
[10.103.16.49] out: Running handlers complete
[10.103.16.49] out: [2022-10-12T11:23:57-07:00] ERROR: Exception handlers complete
[10.103.16.49] out: Chef Client failed. 0 resources updated in 12 seconds
[10.103.16.49] out: [2022-10-12T11:23:57-07:00] FATAL: Stacktrace dumped to /root/.chef/local-mode-cache/cache/chef-stacktrace.out
[10.103.16.49] out: [2022-10-12T11:23:57-07:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[10.103.16.49] out: [2022-10-12T11:23:57-07:00] FATAL: Mixlib::ShellOut::ShellCommandFailed: apt_package[apt-transport-https, gnupg, dirmngr] (apt::default line 95) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '100'
[10.103.16.49] out: ---- Begin output of ["apt-get", "-q", "-y", "--allow-downgrades", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confold", "install", "apt-transport-https=2.4.6"] ----
[10.103.16.49] out: STDOUT: Reading package lists...
[10.103.16.49] out: Building dependency tree...
[10.103.16.49] out: Reading state information...
[10.103.16.49] out: The following NEW packages will be installed:
[10.103.16.49] out:   apt-transport-https
[10.103.16.49] out: 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
[10.103.16.49] out: Need to get 1,510 B of archives.
[10.103.16.49] out: After this operation, 169 kB of additional disk space will be used.
[10.103.16.49] out: Err:1 http://archive.ubuntu.com/ubuntu jammy-updates/universe amd64 apt-transport-https all 2.4.6
[10.103.16.49] out:   404  Not Found [IP: 91.189.91.39 80]
[10.103.16.49] out: STDERR: E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/universe/a/apt/apt-transport-https_2.4.6_all.deb  404  Not Found [IP: 91.189.91.39 80]
[10.103.16.49] out: E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
[10.103.16.49] out: ---- End output of ["apt-get", "-q", "-y", "--allow-downgrades", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confold", "install", "apt-transport-https=2.4.6"] ----
[10.103.16.49] out: Ran ["apt-get", "-q", "-y", "--allow-downgrades", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confold", "install", "apt-transport-https=2.4.6"] returned 100
[10.103.16.49] out:

jburns24 avatar Oct 12 '22 18:10 jburns24