Class: RescheduleTasksForMissingRunners

Inherits:
Object
  • Object
show all
Defined in:
app/services/reschedule_tasks_for_missing_runners.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(runner_ids:, started_tasks:) ⇒ RescheduleTasksForMissingRunners

Returns a new instance of RescheduleTasksForMissingRunners.



6
7
8
9
# File 'app/services/reschedule_tasks_for_missing_runners.rb', line 6

def initialize(runner_ids:, started_tasks:)
  @started_tasks = started_tasks
  @runner_ids = runner_ids
end

Instance Attribute Details

#runner_idsObject (readonly)

Returns the value of attribute runner_ids.



4
5
6
# File 'app/services/reschedule_tasks_for_missing_runners.rb', line 4

def runner_ids
  @runner_ids
end

#started_tasksObject (readonly)

Returns the value of attribute started_tasks.



4
5
6
# File 'app/services/reschedule_tasks_for_missing_runners.rb', line 4

def started_tasks
  @started_tasks
end

Instance Method Details

#performObject



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/services/reschedule_tasks_for_missing_runners.rb', line 11

def perform
  tasks_without_runner.each do |runner_id|
    task = started_tasks_group_by_runner_id[runner_id]
    message = "Task retryied because runner #{runner_id} is missing (#{task} #{task&.slot})"
    Rails.logger.debug(message)

    report_event(message: message, task: task, runner_id: runner_id)

    slot = task.slot
    task.mark_as_retry(error: message)
    slot&.release
  end
end