Skip to content

Commit

Permalink
Merge pull request #20810 from agrare/reset_failed_systemd_unit_files
Browse files Browse the repository at this point in the history
Call ResetFailedUnit when cleaning up failed services
  • Loading branch information
jrafanie authored Nov 19, 2020
2 parents e46091e + 1678e35 commit 0a56551
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/models/miq_server/worker_management/monitor/systemd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def systemd_manager
def systemd_stop_services(service_names)
service_names.each do |service_name|
systemd_manager.StopUnit(service_name, "replace")
systemd_manager.ResetFailedUnit(service_name)

service_settings_dir = systemd_unit_dir.join("#{service_name}.d")
FileUtils.rm_r(service_settings_dir) if service_settings_dir.exist?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@
end

context "with failed services" do
let(:units) { [{:name => "[email protected]", :description => "ManageIQ Generic Worker", :load_state => "loaded", :active_state => "failed", :sub_state => "plugged", :job_id => 0, :job_type => "", :job_object_path => "/"}] }
let(:service_name) { "[email protected]" }
let(:units) { [{:name => service_name, :description => "ManageIQ Generic Worker", :load_state => "loaded", :active_state => "failed", :sub_state => "plugged", :job_id => 0, :job_type => "", :job_object_path => "/"}] }

it "calls DisableUnitFiles with the service name" do
expect(systemd_manager).to receive(:StopUnit).with("[email protected]", "replace")
expect(systemd_manager).to receive(:DisableUnitFiles).with(["[email protected]"], false)
expect(systemd_manager).to receive(:StopUnit).with(service_name, "replace")
expect(systemd_manager).to receive(:ResetFailedUnit).with(service_name)
expect(systemd_manager).to receive(:DisableUnitFiles).with([service_name], false)

server.cleanup_failed_systemd_services
end
end
Expand Down

0 comments on commit 0a56551

Please sign in to comment.