diff --git a/app/models/miq_server/worker_management/monitor/systemd.rb b/app/models/miq_server/worker_management/monitor/systemd.rb index 02db4e39e9e..2a0c40acc48 100644 --- a/app/models/miq_server/worker_management/monitor/systemd.rb +++ b/app/models/miq_server/worker_management/monitor/systemd.rb @@ -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? diff --git a/spec/models/miq_server/worker_management/monitor/systemd_spec.rb b/spec/models/miq_server/worker_management/monitor/systemd_spec.rb index 557f77433f5..ae3b0db2ab8 100644 --- a/spec/models/miq_server/worker_management/monitor/systemd_spec.rb +++ b/spec/models/miq_server/worker_management/monitor/systemd_spec.rb @@ -20,11 +20,14 @@ end context "with failed services" do - let(:units) { [{:name => "generic@68400a7e-1747-4f10-be2a-d0fc91b705ca.service", :description => "ManageIQ Generic Worker", :load_state => "loaded", :active_state => "failed", :sub_state => "plugged", :job_id => 0, :job_type => "", :job_object_path => "/"}] } + let(:service_name) { "generic@68400a7e-1747-4f10-be2a-d0fc91b705ca.service" } + 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("generic@68400a7e-1747-4f10-be2a-d0fc91b705ca.service", "replace") - expect(systemd_manager).to receive(:DisableUnitFiles).with(["generic@68400a7e-1747-4f10-be2a-d0fc91b705ca.service"], 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