Skip to content

Commit

Permalink
Use rails_worker? in find_all_starting/stopping query
Browse files Browse the repository at this point in the history
  • Loading branch information
agrare committed Jul 29, 2024
1 parent 80ff67c commit 281736e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
8 changes: 3 additions & 5 deletions app/models/miq_server/worker_management/kubernetes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ def sync_from_system
end

def sync_starting_workers
MiqWorker.find_all_starting.each do |worker|
next if worker.class.rails_worker?

worker_pod = current_pods[worker[:system_uid]]
MiqWorker.find_all_starting.reject(&:rails_worker?).each do |worker|
worker_pod = current_pods[worker.system_uid]
next if worker_pod.nil?

container_status = worker_pod.status.containerStatuses.find { |container| container.name == worker.worker_deployment_name }
Expand All @@ -35,7 +33,7 @@ def sync_starting_workers
end

def sync_stopping_workers
MiqWorker.find_all_stopping.reject { |w| w.class.rails_worker? }.each do |worker|
MiqWorker.find_all_stopping.reject(&:rails_worker?).each do |worker|
next if current_pods.key?(worker[:system_uid])

worker.update!(:status => MiqWorker::STATUS_STOPPED)
Expand Down
6 changes: 2 additions & 4 deletions app/models/miq_server/worker_management/systemd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ def sync_from_system

def sync_starting_workers
sync_from_system
MiqWorker.find_all_starting.each do |worker|
next if worker.class.rails_worker?

MiqWorker.find_all_starting.reject(&:rails_worker?).each do |worker|
systemd_worker = miq_services_by_unit[worker[:system_uid]]
next if systemd_worker.nil?

Expand All @@ -20,7 +18,7 @@ def sync_starting_workers

def sync_stopping_workers
sync_from_system
MiqWorker.find_all_stopping.reject { |w| w.class.rails_worker? }.each do |worker|
MiqWorker.find_all_stopping.reject(&:rails_worker?).each do |worker|
# If the worker record is "stopping" and the systemd unit is gone then the
# worker has successfully exited.
next if miq_services_by_unit[worker[:system_uid]].present?
Expand Down
1 change: 1 addition & 0 deletions app/models/miq_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def self.rails_worker?

true
end
delegate :rails_worker?, :to => :class

def self.scalable?
maximum_workers_count.nil? || maximum_workers_count > 1
Expand Down

0 comments on commit 281736e

Please sign in to comment.