Skip to content

Commit

Permalink
Set MiqWorker system_uid if missing on kubernetes
Browse files Browse the repository at this point in the history
  • Loading branch information
agrare committed Jul 29, 2024
1 parent bde5deb commit 9f162cb
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions app/models/miq_server/worker_management/kubernetes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,20 @@ def sync_from_system
end

def sync_starting_workers
# Get a list of pods that aren't currently assigned to MiqWorker records
pods_without_workers = current_pods.keys - MiqWorker.server_scope.pluck(:system_uid).compact

MiqWorker.find_all_starting.reject(&:rails_worker?).each do |worker|
# If the current worker doesn't have a system_uid assigned then find the first
# pod available for our worker type and link them up.
if worker.system_uid.nil?
system_uid = pods_without_workers.detect { |pod_name| pod_name.start_with?(worker.worker_deployment_name) }
if system_uid
pods_without_workers.delete(system_uid)
worker.update!(:system_uid => system_uid)
end
end

worker_pod = current_pods[worker.system_uid]
next if worker_pod.nil?

Expand Down

0 comments on commit 9f162cb

Please sign in to comment.