chef-cookbooks / chef_client_updater

Chef Cookbook to update the chef client on nodes
https://supermarket.chef.io/cookbooks/chef_client_updater
Apache License 2.0
54 stars 79 forks source link

Update for installation failure in Solaris #233

Closed ayushbhatt29 closed 2 years ago

ayushbhatt29 commented 3 years ago

Signed-off-by: ayushbhatt29 abhatt@msystechnologies.com

Description

These changes fix installation failure of updated chef-client in Solaris when using this cookbook.

Issues Resolved

Fixes #226

ayushbhatt29 commented 3 years ago

Removed delivery.yml as these tests no longer exists.

ayushbhatt29 commented 3 years ago

Please review this @lamont-granquist .

lamont-granquist commented 2 years ago

What is actually being fixed here and what is the bug and what is being held onto and not released on solaris in the chef-client installation?

It seems like we're fairly randomly adding a move_opt_chef and then having three copy_opt_chefs added with no explanation of why they're necessary or what underlying bug is actually being worked around.

ayushbhatt29 commented 2 years ago

Hi @lamont-granquist, thank you for reviewing the PR

The real issue was that the chef-client installation at the time of updating through chef_client_cookbook in Solaris was getting corrupted because of /etc/chef folder being present at the time of installation for updated chef-client version which is fixing this issue for installing new version and I have used already defined mov_opt_chef and copy_opt_chef methods to copy & move /etc/chef.

So in this fix I moved /etc/chef directory to an /etc/chef.upgrade directory just as we move /opt/chef at the time of installation and moving it back to /etc/chef after the installation is done.

chef-client command were not working properly because the installation was not happening properly. I have given below before and after fix of chef-client -v command when we are updating chef-client version through chef_client cookbook.

Before Fix

Starting Chef Infra Client, version 16.8.9
Patents: https://www.chef.io/patents
[2022-01-06T02:37:24-05:00] WARN: Run List override has been provided.
[2022-01-06T02:37:24-05:00] WARN: Original Run List: []
[2022-01-06T02:37:24-05:00] WARN: Overridden Run List: [recipe[chef_client_updater]]
resolving cookbooks for run list: ["chef_client_updater"]
Synchronizing Cookbooks:
  - chef_client_updater (3.12.2)
Installing Cookbook Gems:
Compiling Cookbooks...
Converging 1 resources
Recipe: chef_client_updater::default
  * chef_client_updater[update chef-client] action update
    * chef_gem[mixlib-install] action install
      - install version ~> 3.12 of package mixlib-install
    - move all files under /opt/chef to /opt/chef.upgrade
    - upgrade chef 16.8.9 to 16.9.16[2022-01-06T02:38:18-05:00] WARN: New Chef Infra Client installed and client process exit is allowed and/or specified. Now forcing Chef Infra Client to exit. Disregard any failure messages.

chef-client -v
-bash: /usr/bin/chef-client: /opt/chef/embedded/bin/ruby: bad interpreter: No such file or directory

After fix

Starting Chef Infra Client, version 16.8.9
Patents: https://www.chef.io/patents
[2022-01-06T02:55:24-05:00] WARN: Run List override has been provided.
[2022-01-06T02:55:24-05:00] WARN: Original Run List: []
[2022-01-06T02:55:24-05:00] WARN: Overridden Run List: [recipe[chef_client_updater]]
resolving cookbooks for run list: ["chef_client_updater"]
Synchronizing Cookbooks:
  - chef_client_updater (3.12.0)
Installing Cookbook Gems:
Compiling Cookbooks...
Converging 1 resources
Recipe: chef_client_updater::default
  * chef_client_updater[update chef-client] action update
    * chef_gem[mixlib-install] action install
      - install version ~> 3.12 of package mixlib-install
    - move all files under /etc/chef to /etc/chef.upgrade
    - upgrade chef 16.8.9 to 16.9.16
    - move all files under /etc/chef.upgrade to /etc/chef[2022-01-06T02:56:07-05:00] WARN: New Chef Infra Client installed and client process exit is allowed and/or specified. Now forcing Chef Infra Client to exit. Disregard any failure messages.

chef-client -v
Chef Infra Client: 16.9.16
lamont-granquist commented 2 years ago

That doesn't look like the right fix. Nothing in /etc/chef should be causing /opt/chef/embedded/bin/ruby to throw a "bad interpreter" from the shell.