-
Notifications
You must be signed in to change notification settings - Fork 898
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stop any worker records for failed systemd units
If a systemd unit is failed but there is still a miq_worker record associated with it we should mark that worker record as stopped. This will then be cleaned up by the subsequent `clean_worker_records` method.
- Loading branch information
Showing
2 changed files
with
16 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ | |
context "with failed services" do | ||
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 => "/"}] } | ||
let!(:worker) { FactoryBot.create(:miq_generic_worker, :miq_server => server, :status => "creating", :system_uid => service_name) } | ||
|
||
it "calls DisableUnitFiles with the service name" do | ||
expect(systemd_manager).to receive(:StopUnit).with(service_name, "replace") | ||
|
@@ -34,6 +35,16 @@ | |
|
||
server.worker_manager.cleanup_failed_systemd_services | ||
end | ||
|
||
it "marks any active workers as stopped" do | ||
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.worker_manager.cleanup_failed_systemd_services | ||
|
||
expect(worker.reload.status).to eq("stopped") | ||
end | ||
end | ||
end | ||
|
||
|