Sha256: b71a9c3b1ba4c4a2e822b7ad0b0ca15764db559f4f959badd973d2960026365a

Contents?: true

Size: 938 Bytes

Versions: 24

Compression:

Stored size: 938 Bytes

Contents

namespace :foreman_tasks do
  desc <<~DESC
    Reschedules the long running task checker recurring logic to run at a different schedule. ENV variables:

      * FOREMAN_TASKS_CHECK_LONG_RUNNING_TASKS_CRONLINE : A cron line describing the schedule, defaults to 0 0 * * *
  DESC
  task :reschedule_long_running_tasks_checker => ['environment', 'dynflow:client'] do
    User.as_anonymous_admin do
      task_class = Actions::CheckLongRunningTasks
      cronline = ENV['FOREMAN_TASKS_CHECK_LONG_RUNNING_TASKS_CRONLINE'] || '0 0 * * *'
      rl = ForemanTasks::RecurringLogic.joins(:tasks)
                                       .where(state: 'active')
                                       .merge(ForemanTasks::Task.where(label: task_class.name))
                                       .first
      if rl&.cron_line != cronline
        rl.cancel
        ForemanTasks.register_scheduled_task(task_class, cronline)
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
foreman-tasks-10.0.2 lib/foreman_tasks/tasks/reschedule_long_running_tasks_checker.rake
foreman-tasks-10.0.1 lib/foreman_tasks/tasks/reschedule_long_running_tasks_checker.rake
foreman-tasks-10.0.0 lib/foreman_tasks/tasks/reschedule_long_running_tasks_checker.rake
foreman-tasks-9.2.3 lib/foreman_tasks/tasks/reschedule_long_running_tasks_checker.rake
foreman-tasks-9.2.2 lib/foreman_tasks/tasks/reschedule_long_running_tasks_checker.rake
foreman-tasks-9.2.1 lib/foreman_tasks/tasks/reschedule_long_running_tasks_checker.rake
foreman-tasks-9.2.0 lib/foreman_tasks/tasks/reschedule_long_running_tasks_checker.rake
foreman-tasks-9.1.1 lib/foreman_tasks/tasks/reschedule_long_running_tasks_checker.rake
foreman-tasks-9.0.4 lib/foreman_tasks/tasks/reschedule_long_running_tasks_checker.rake
foreman-tasks-9.1.0 lib/foreman_tasks/tasks/reschedule_long_running_tasks_checker.rake
foreman-tasks-9.0.2 lib/foreman_tasks/tasks/reschedule_long_running_tasks_checker.rake
foreman-tasks-9.0.1 lib/foreman_tasks/tasks/reschedule_long_running_tasks_checker.rake
foreman-tasks-8.3.3 lib/foreman_tasks/tasks/reschedule_long_running_tasks_checker.rake
foreman-tasks-9.0.0 lib/foreman_tasks/tasks/reschedule_long_running_tasks_checker.rake
foreman-tasks-8.2.1 lib/foreman_tasks/tasks/reschedule_long_running_tasks_checker.rake
foreman-tasks-8.1.4 lib/foreman_tasks/tasks/reschedule_long_running_tasks_checker.rake
foreman-tasks-8.3.2 lib/foreman_tasks/tasks/reschedule_long_running_tasks_checker.rake
foreman-tasks-8.3.1 lib/foreman_tasks/tasks/reschedule_long_running_tasks_checker.rake
foreman-tasks-8.1.3 lib/foreman_tasks/tasks/reschedule_long_running_tasks_checker.rake
foreman-tasks-8.3.0 lib/foreman_tasks/tasks/reschedule_long_running_tasks_checker.rake