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

mariadb_server_install runs into "No candidate version available" for mariadb_client #344

Open
doganoo opened this issue Jun 8, 2022 · 1 comment

Comments

@doganoo
Copy link

doganoo commented Jun 8, 2022

using this mariadb cookbook, I am installing mariadb successfully on test kitchen.

In a "manual" install/run of chef-client using the following shell script:

curl -LO https://omnitruck.chef.io/install.sh && bash ./install.sh -v 16.0.257 && rm install.sh
mkdir -p /etc/chef/
cp client.rb /etc/chef/client.rb
cp client.pem /etc/chef/client.pem
chef-client

I get the following error after running chef-client on the shell:

[2022-06-08T18:29:41+00:00] FATAL: Chef::Exceptions::Package: mariadb_server_install[package] (install_application::mariadb line 7) had an error: Chef::Exceptions::Package: mariadb_client_install[Install MariaDB Client] (/var/chef/cache/cookbooks/mariadb/resources/server_install.rb line 38) had an error: Chef::Exceptions::Package: apt_package[mariadb-client-10.5] (/var/chef/cache/cookbooks/mariadb/resources/client_install.rb line 32) had an error: Chef::Exceptions::Package: No candidate version available for mariadb-client-10.5

* apt_package[mariadb-client-10.5] action install
        * No candidate version available for mariadb-client-10.5
        ================================================================================
        Error executing action `install` on resource 'apt_package[mariadb-client-10.5]'
        ================================================================================
        
        Chef::Exceptions::Package
        -------------------------
        No candidate version available for mariadb-client-10.5
        
        Cookbook Trace:
        ---------------
        /var/chef/cache/cookbooks/mariadb/resources/client_install.rb:32:in `block in class_from_file'
        /var/chef/cache/cookbooks/mariadb/resources/server_install.rb:38:in `block in class_from_file'
        
        Resource Declaration:
        ---------------------
        # In /var/chef/cache/cookbooks/mariadb/resources/client_install.rb
        
         32:     package "mariadb-client-#{new_resource.version}"
         33:   when 'rhel', 'fedora', 'amazon'
        
        Compiled Resource:
        ------------------
        # Declared in /var/chef/cache/cookbooks/mariadb/resources/client_install.rb:32:in `block in class_from_file'
        
        apt_package("mariadb-client-10.5") do
          package_name "mariadb-client-10.5"
          action [:install]
          default_guard_interpreter :default
          declared_type :package
          cookbook_name "install_application"
        end
        
        System Info:
        ------------
        chef_version=16.0.257
        platform=ubuntu
        platform_version=22.04
        ruby=ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]
        program_name=/usr/bin/chef-client
        executable=/opt/chef/bin/chef-client
        
      
      ================================================================================
      Error executing action `install` on resource 'mariadb_client_install[Install MariaDB Client]'
      ================================================================================
      
      Chef::Exceptions::Package
      -------------------------
      apt_package[mariadb-client-10.5] (/var/chef/cache/cookbooks/mariadb/resources/client_install.rb line 32) had an error: Chef::Exceptions::Package: No candidate version available for mariadb-client-10.5
      
      Cookbook Trace:
      ---------------
      /var/chef/cache/cookbooks/mariadb/resources/client_install.rb:32:in `block in class_from_file'
      /var/chef/cache/cookbooks/mariadb/resources/server_install.rb:38:in `block in class_from_file'
      
      Resource Declaration:
      ---------------------
      # In /var/chef/cache/cookbooks/mariadb/resources/server_install.rb
      
       38:   mariadb_client_install 'Install MariaDB Client' do
       39:     version new_resource.version
       40:     setup_repo new_resource.setup_repo
       41:   end
       42: 
      
      Compiled Resource:
      ------------------
      # Declared in /var/chef/cache/cookbooks/mariadb/resources/server_install.rb:38:in `block in class_from_file'
      
      mariadb_client_install("Install MariaDB Client") do
        action [:install]
        default_guard_interpreter :default
        declared_type :mariadb_client_install
        cookbook_name "install_application"
        version "10.5"
        setup_repo true
      end
      
      System Info:
      ------------
      chef_version=16.0.257
      platform=ubuntu
      platform_version=22.04
      ruby=ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]
      program_name=/usr/bin/chef-client
      executable=/opt/chef/bin/chef-client
      
    
    ================================================================================
    Error executing action `install` on resource 'mariadb_server_install[package]'
    ================================================================================
    
    Chef::Exceptions::Package
    -------------------------
    mariadb_client_install[Install MariaDB Client] (/var/chef/cache/cookbooks/mariadb/resources/server_install.rb line 38) had an error: Chef::Exceptions::Package: apt_package[mariadb-client-10.5] (/var/chef/cache/cookbooks/mariadb/resources/client_install.rb line 32) had an error: Chef::Exceptions::Package: No candidate version available for mariadb-client-10.5
    
    Cookbook Trace:
    ---------------
    /var/chef/cache/cookbooks/mariadb/resources/client_install.rb:32:in `block in class_from_file'
    /var/chef/cache/cookbooks/mariadb/resources/server_install.rb:38:in `block in class_from_file'
    
    Resource Declaration:
    ---------------------
    # In /var/chef/cache/cookbooks/install_application/recipes/mariadb.rb
    
      7: mariadb_server_install 'package' do
      8:   action [:install, :create]
      9:   version node.default[:application][:mariadb][:version]
     10:   password node.default[:application][:mariadb][:root][:password]
     11: end
     12: 
    
    Compiled Resource:
    ------------------
    # Declared in /var/chef/cache/cookbooks/install_application/recipes/mariadb.rb:7:in `from_file'
    
    mariadb_server_install("package") do
      action [:install, :create]
      default_guard_interpreter :default
      declared_type :mariadb_server_install
      cookbook_name "install_application"
      recipe_name "mariadb"
      version "10.5"
      password "WdEfaruDFfMBP76J"
      extconf_directory "/etc/mysql/conf.d"
      data_directory "/var/lib/mysql"
    end
    
    System Info:
    ------------
    chef_version=16.0.257
    platform=ubuntu
    platform_version=22.04
    ruby=ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]
    program_name=/usr/bin/chef-client
    executable=/opt/chef/bin/chef-client

the recipe is:

apt_update

mariadb_repository 'install' do
  version "10.5"
end

mariadb_server_install 'package' do
  action [:install, :create]
  version "10.5"
  password "topsecret"
end

mariadb_server_configuration 'MariaDB Server Configuration' do
  version "10.5"
end

node.default[:application][:mariadb][:databases].each do |index, database|
    mariadb_database database[:name] do
        database_name database[:name]
        encoding database[:encoding]
        collation database[:collation]
        action :create
    end
end

node.default[:application][:mariadb][:users].each do |index, user|
    mariadb_user user[:user] do
        password user[:password]
        host user[:host]
        database_name user[:database]
        privileges [:all]
        action [:create, :grant]
    end
end

mariadb_database 'flush privileges' do
    sql 'flush privileges'
    action :query
end

The metadata.rb file contains depends 'mariadb' and the Berksfile contains cookbook 'mariadb'. I also ran berks install && berks upload. The Chef Infra Server is hosted at api.chef.io.

I wonder why mariadb_client is getting installed since I did not defined this anywhere in my recipe. Further, test kitchen runs the recipe successfully whereas the installation on a node with chef-client fails.

Please let me know if you need more information and I can support you.

Thank you in advance!

@fozboz
Copy link
Contributor

fozboz commented Mar 9, 2023

The server resource calls the client resource, which is why the client is being installed. This is expected behaviour.

My guess is that 10.5 is unavailable for the OS version you're running. Is there any difference between the OS of your test kitchen and the "real" node?

Incidentally, since you are using all defaults for the apt repository, there is no need for the initial mariadb_repository resource, because it is called by the mariadb_server_install resource by default.

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

2 participants