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

systemd time deactivation not working #683

Open
chuhn opened this issue May 15, 2020 · 0 comments
Open

systemd time deactivation not working #683

chuhn opened this issue May 15, 2020 · 0 comments

Comments

@chuhn
Copy link

chuhn commented May 15, 2020

When chef-client.timer has been configured and then is deactivated again (node['chef_client']['systemd']['timer'] = false), a restart notification is sent to the deleted unit:
https://github.com/chef-cookbooks/chef-client/blob/14435f7a42af11aaf8d0a06ace4221ecefa3e752/recipes/systemd_service.rb#L90

The logic has to be the other way around if at all (notifies :restart, to_s, :delayed **if** timer).

         * systemd_unit[chef-client.timer] action restart
           
           ================================================================================
           Error executing action `restart` on resource 'systemd_unit[chef-client.timer]'
           ================================================================================
           
           Mixlib::ShellOut::ShellCommandFailed
           ------------------------------------
           Expected process to exit with [0], but received '5'
           ---- Begin output of /usr/bin/systemctl --system restart chef-client.timer ----
           STDOUT: 
           STDERR: Failed to restart chef-client.timer: Unit chef-client.timer not found.
           ---- End output of /usr/bin/systemctl --system restart chef-client.timer ----
           Ran /usr/bin/systemctl --system restart chef-client.timer returned 5
           
           Resource Declaration:
           ---------------------
           # In /tmp/kitchen/cache/cookbooks/chef-client/recipes/systemd_service.rb
           
            76: systemd_unit 'chef-client.timer' do
            77:   content(
            78:     'Unit' => { 'Description' => 'chef-client periodic run' },
            79:     'Install' => { 'WantedBy' => 'timers.target' },
            80:     'Timer' => {
            81:       'OnBootSec' => '1min',
            82:       'OnUnitInactiveSec' => "#{node['chef_client']['interval']}sec",
            83:       'RandomizedDelaySec' => "#{node['chef_client']['splay']}sec",
            84:     }
            85:   )
            86:   action(timer ? [:create, :enable, :start] : [:stop, :disable, :delete])
            87:   notifies :restart, to_s, :delayed unless timer
            88: end
            89: 
           
           Compiled Resource:
           ------------------
           # Declared in /tmp/kitchen/cache/cookbooks/chef-client/recipes/systemd_service.rb:76:in `from_file'
           
           systemd_unit("chef-client.timer") do
             action [:stop, :disable, :delete]
             updated true
             default_guard_interpreter :default
             declared_type :systemd_unit
             cookbook_name "chef-client"
             recipe_name "systemd_service"
             content {"Unit"=>{"Description"=>"chef-client periodic run"}, "Install"=>{"WantedBy"=>"timers.target"}, "Timer"=>{"OnBootSec"=>"1min", "OnUnitInactiveSec"=>"1800sec", "RandomizedDelaySec"=>"300sec"}}
             unit_name "chef-client.timer"
           end
           
           System Info:
           ------------
           chef_version=13.8.7
           platform=debian
           platform_version=10.3
           ruby=ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux-gnu]
           program_name=chef-client worker: ppid=4421;start=12:14:55;
           executable=/usr/bin/chef-client

Cheers,
Christopher

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant