Skip to content

Commit

Permalink
Use the systemd services instead of miq_workers table
Browse files Browse the repository at this point in the history
For the purposes of starting and stopping workers only looking at the
miq_workers table for the "current" list ignores the fact that there
might be existing services out there already created that are starting,
stopping, or failed and don't have a record tracking them in the
miq_workers table.
  • Loading branch information
agrare committed Aug 5, 2020
1 parent 85037e1 commit 7e42ca4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
2 changes: 0 additions & 2 deletions app/models/miq_server/worker_management/monitor/quiesce.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ def quiesce_workers_loop
miq_workers.each do |w|
if w.containerized_worker?
w.delete_container_objects
elsif w.systemd_worker?
w.stop_systemd_worker
else
stop_worker(w)
end
Expand Down
24 changes: 20 additions & 4 deletions app/models/miq_worker/systemd_common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,25 @@ def supports_systemd?
false
end

def systemd_manager
@systemd_manager ||= begin
require "dbus/systemd"
DBus::Systemd::Manager.new
end
end

def services
systemd_manager.units.select { |unit| unit[:name].start_with?(service_name) }
end

def active_services
services.select { |service| service[:active_state] == "active" }
end

def failed_services
services.select { |service| service[:active_state] == "failed" }
end

def ensure_systemd_files
target_file_path.write(target_file) unless target_file_path.exist?
service_file_path.write(unit_file) unless service_file_path.exist?
Expand Down Expand Up @@ -118,10 +137,7 @@ def stop_systemd_unit(mode: "replace")
private

def systemd
@systemd ||= begin
require "dbus/systemd"
DBus::Systemd::Manager.new
end
self.class.systemd_manager
end

def service_base_name
Expand Down

0 comments on commit 7e42ca4

Please sign in to comment.