Skip to content

Commit

Permalink
Set system_uid in miq_server
Browse files Browse the repository at this point in the history
  • Loading branch information
agrare committed Jul 30, 2024
1 parent 69993d6 commit b6315a5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
10 changes: 3 additions & 7 deletions app/models/miq_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ class MiqWorker < ApplicationRecord
include SystemdCommon
include UuidMixin

after_initialize :set_system_uid
before_destroy :error_out_tasks_with_active_queue_message, :log_destroy_of_worker_messages

belongs_to :miq_server
Expand Down Expand Up @@ -351,6 +350,7 @@ def start_runner

def start_runner_via_container
create_container_objects
nil # We don't know the pod name/system_uid until after it is started
end

def self.build_command_line(guid, ems_id = nil)
Expand Down Expand Up @@ -388,8 +388,8 @@ def start_runner_via_spawn
end

def start
self.pid = start_runner
save if !containerized_worker? && !systemd_worker?
self.system_uid = start_runner
save!

msg = "Worker started: ID [#{id}], PID [#{pid}], GUID [#{guid}]"
MiqEvent.raise_evm_event_queue(miq_server || MiqServer.my_server, "evm_worker_start", :event_details => msg, :type => self.class.name)
Expand Down Expand Up @@ -495,10 +495,6 @@ def clean_active_messages
end
end

private def set_system_uid
self.system_uid = unit_name if systemd_worker?
end

private def error_out_tasks_with_active_queue_message
message = "Task Handler: [#{friendly_name}] ID [#{id}] has been deleted!"
processed_messages.includes(:miq_task).where.not(:miq_task_id => nil).each do |m|
Expand Down
13 changes: 10 additions & 3 deletions app/models/miq_worker/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,16 @@ def log_prefix
#

def find_worker_record
@worker = self.class.corresponding_model.find_by(:guid => @cfg[:guid])
do_exit("Unable to find instance for worker GUID [#{@cfg[:guid]}].", 1) if @worker.nil?
MiqWorker.my_guid = @cfg[:guid]
worker_find_opts = {}
if @cfg[:system_uid]
worker_find_opts[:system_uid] = @cfg[:system_uid]
else
worker_find_opts[:guid] = @cfg[:guid]
end

@worker = self.class.corresponding_model.find_by(worker_find_opts)
do_exit("Unable to find instance for worker [#{worker_find_opts.values.first}].", 1) if @worker.nil?
MiqWorker.my_guid = @worker.guid
end

def starting_worker_record
Expand Down
2 changes: 2 additions & 0 deletions app/models/miq_worker/systemd_common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ def start_systemd_worker
enable_systemd_unit
write_unit_settings_file
start_systemd_unit

unit_name
end

def stop_systemd_worker
Expand Down

0 comments on commit b6315a5

Please sign in to comment.