diff --git a/lib/infra_conversion_throttler.rb b/lib/infra_conversion_throttler.rb index 49fb388b2cf..f36fd33717a 100644 --- a/lib/infra_conversion_throttler.rb +++ b/lib/infra_conversion_throttler.rb @@ -7,9 +7,15 @@ def self.start_conversions _log.debug("- EMS: #{ems.name}") _log.debug("-- Number of pending jobs: #{jobs.size}") running = ems.conversion_hosts.inject(0) { |sum, ch| sum + ch.active_tasks.count } - $log&.debug("There are currently #{running} conversion hosts running.") + _log.debug("-- Currently running jobs in EMS: #{running}") slots = (ems.miq_custom_get('MaxTransformationRunners') || Settings.transformation.limits.max_concurrent_tasks_per_ems).to_i - running - $log&.debug("The maximum number of concurrent tasks for the EMS is: #{slots}.") + + if slots <= 0 + _log.debug("-- No available slot in EMS. Stopping.") + next + end + _log.debug("-- Available slots in EMS: #{slots}") + jobs.each do |job| vm_name = job.migration_task.source.name _log.debug("- Looking for a conversion host for task for #{vm_name}")