sensu / sensu-go-chef

Chef Library Cookbook for Sensu Go
https://sensu.io
MIT License
11 stars 22 forks source link

Systemd daemon not reloaded on upgrade #131

Closed ValkyrieOps closed 3 years ago

ValkyrieOps commented 3 years ago

Chef Version

Chef: 16.6.4 CentOS 7.6.1810

Input

A stripped down resource to deploy the agent while specifying which version to install

sensu_agent 'default' do
  version node['sensu-go']['linux_version']
end

Output

Recipe: sensu-go::agent
  * linux_user[sensu] action create (up to date)
  * directory[/etc/sensu/tls] action create (up to date)
  * template[/etc/sensu/tls/sensuagent.exampleorg.key.pem] action create (up to date)
  * template[/etc/sensu/tls/sensuagent.exampleorg.com.cert.pem] action create (up to date)
  * sensu_agent[default] action install
    * yum_package[sensu-go-agent] action upgrade
      - upgrade(allow_downgrade) package sensu-go-agent from 0:6.1.0-3465.x86_64 to 0:6.2.5-4040.x86_64
    * file[/etc/sensu/agent.yml] action create (up to date)
    * service[sensu-agent] action enable (up to date)
    * service[sensu-agent] action start (up to date)
    * service[sensu-agent] action restart
      - restart service service[sensu-agent]

[2021-02-03T20:56:22-06:00] WARN: Skipping final node save because override_runlist was given

Running handlers:
Running handlers complete
Chef Infra Client finished, 3/10 resources updated in 08 seconds

[root@sensu03 user]# sensu-agent version
sensu-agent version 6.2.5+ee, enterprise edition, build 6e4770e3b95136fa3fb7307dfd574479db8a5e97, built 2021-02-02T18:02:06Z, built with go1.13.15

[root@sensu03 user]# systemctl restart sensu-agent
Warning: sensu-agent.service changed on disk. Run 'systemctl daemon-reload' to reload units.

Impact

Tiny. I have added an execute statement to the agent resource locally for now

   # Enable and start the sensu-agent service
    service 'sensu-agent' do
      if platform?('ubuntu') && node['platform_version'].to_f == 14.04
        provider Chef::Provider::Service::Init
        action :start
      else
        action [:enable, :start]
      end
    execute 'daemon-reload' do
      command 'systemctl daemon-reload'
      action :run
      end
    end

Expected Behavior

I would think that after running an upgrade the systemd daemon would get reloaded

Actual Behavior

Requires user to execute systemctl daemon-reload

Steps to Reproduce your problem

  1. Install sensu agent
  2. Upgrade sensu agent
  3. Try and manually restart the service with systemd
majormoses commented 3 years ago

Thanks for reporting this.

In most other places I am using chef still I also manage the systemd unit file (which we don't here if I am not mistaken) so when I use the following resource: https://docs.chef.io/resources/systemd_unit/ to create the unit it knows how to handle that for you.

I have not tested this: I think what we would want to do here is define it with an action of :nothing (and no content) to put it in our resource collection to be called later. Then use a notification to reload the unit file configuration before the service restart is called. Let me know if you want any pointers on taking a stab at this, otherwise I will try to get to it when I can. I am sure we are running into this org and we didn't notice the warning.

ValkyrieOps commented 3 years ago

Hey no worries, appreciate you getting back to me. Your suggested fix seems like the way to go, hopefully this coming week I can sit down and try to implement the changes. Will keep you posted on progress. Thanks!