sensu / sensu-go-chef

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

sensu_agent Should Restart the Service Instead of Reloading #144

Open devinlyons opened 1 year ago

devinlyons commented 1 year ago

The sensu_agent resource notifies the sensu-agent process to reload via systemd. However, the unit does not have a reload option. All other attempts to reload the agent's configuration are done with the :restart action.

Based on the logs, I believe the issue is located here: https://github.com/sensu/sensu-go-chef/blob/aa421dd10d66c36b2aacd28efd683410fafc3d69/resources/agent.rb#L80

Here are the results I get when I run this resource.

  * sensu_agent[default] action install
    * packagecloud_repo[sensu/stable] action add
      * yum_package[pygpgme] action install (up to date)
      * log[pygpgme_warning] action write (skipped due to not_if)
      * template[/etc/yum.repos.d/sensu_stable.repo] action create (up to date)
      * execute[yum-makecache-sensu_stable] action nothing (skipped due to actio                                                                                                                                                             n :nothing)
      * ruby_block[yum-cache-reload-sensu_stable] action nothing (skipped due to                                                                                                                                                              action :nothing)
       (up to date)
    * yum_package[sensu-go-agent] action install
      - install version 6.9.2-7020 of package sensu-go-agent
    * systemd_unit[sensu-agent] action reload

      ================================================================================
      Error executing action `reload` on resource 'systemd_unit[sensu-agent]'
      ================================================================================

      Mixlib::ShellOut::ShellCommandFailed
      ------------------------------------
      Expected process to exit with [0], but received '3'
      ---- Begin output of ["/usr/bin/systemctl", "--system", "reload", "sensu-agent"] ----
      STDOUT:
      STDERR: Failed to reload sensu-agent.service: Job type reload is not applicable for unit sensu-agent.service.
      See system logs and 'systemctl status sensu-agent.service' for details.
      ---- End output of ["/usr/bin/systemctl", "--system", "reload", "sensu-agent"] ----
      Ran ["/usr/bin/systemctl", "--system", "reload", "sensu-agent"] returned 3

      Resource Declaration:
      ---------------------
      # In /var/chef/cache/cookbooks/sensu-go/resources/agent.rb

       59:     systemd_unit 'sensu-agent' do
       60:       action :nothing
       61:     end
       62:

      Compiled Resource:
      ------------------
      # Declared in /var/chef/cache/cookbooks/sensu-go/resources/agent.rb:59:in                                                                                                                                                              `block in class_from_file'

      systemd_unit("sensu-agent") do
        action [:nothing]
        default_guard_interpreter :default
        declared_type :systemd_unit
        cookbook_name "ac_sensu_agent"
        unit_name "sensu-agent"
      end

      System Info:
      ------------
      chef_version=16.16.13
      platform=centos
      platform_version=7.9.2009
      ruby=ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [x86_64-linux]
      program_name=/usr/bin/chef-client
      executable=/opt/chef/bin/chef-client

    ================================================================================
    Error executing action `install` on resource 'sensu_agent[default]'
    ================================================================================