From 83a05ec2d263472f54446c94d257a1fafb501464 Mon Sep 17 00:00:00 2001 From: Eric Enns <492127+ericenns@users.noreply.github.com> Date: Wed, 8 Jan 2025 13:46:34 -0600 Subject: [PATCH] chore: remove wait_untill delay from queuing jobs except for status job (#886) --- app/jobs/workflow_execution_cancelation_job.rb | 2 +- app/jobs/workflow_execution_preparation_job.rb | 2 +- app/jobs/workflow_execution_status_job.rb | 8 ++++---- app/jobs/workflow_execution_submission_job.rb | 2 +- app/services/data_exports/create_service.rb | 2 +- app/services/workflow_executions/cancel_service.rb | 8 +++----- app/services/workflow_executions/cancelation_service.rb | 2 +- app/services/workflow_executions/completion_service.rb | 2 +- app/services/workflow_executions/create_service.rb | 4 ++-- 9 files changed, 15 insertions(+), 17 deletions(-) diff --git a/app/jobs/workflow_execution_cancelation_job.rb b/app/jobs/workflow_execution_cancelation_job.rb index dfaf16f172..3c25aa9b63 100644 --- a/app/jobs/workflow_execution_cancelation_job.rb +++ b/app/jobs/workflow_execution_cancelation_job.rb @@ -30,7 +30,7 @@ class WorkflowExecutionCancelationJob < ApplicationJob workflow_execution.http_error_code = exception.http_error_code workflow_execution.save - WorkflowExecutionCleanupJob.set(wait_until: 30.seconds.from_now).perform_later(workflow_execution) + WorkflowExecutionCleanupJob.perform_later(workflow_execution) workflow_execution end diff --git a/app/jobs/workflow_execution_preparation_job.rb b/app/jobs/workflow_execution_preparation_job.rb index 9b54bafa4b..121db72b69 100644 --- a/app/jobs/workflow_execution_preparation_job.rb +++ b/app/jobs/workflow_execution_preparation_job.rb @@ -10,7 +10,7 @@ def perform(workflow_execution) result = WorkflowExecutions::PreparationService.new(workflow_execution).execute if result - WorkflowExecutionSubmissionJob.set(wait_until: 30.seconds.from_now).perform_later(workflow_execution) + WorkflowExecutionSubmissionJob.perform_later(workflow_execution) else @workflow_execution.state = :error @workflow_execution.cleaned = true diff --git a/app/jobs/workflow_execution_status_job.rb b/app/jobs/workflow_execution_status_job.rb index 1c7a350377..cb670e5a72 100644 --- a/app/jobs/workflow_execution_status_job.rb +++ b/app/jobs/workflow_execution_status_job.rb @@ -14,12 +14,12 @@ class WorkflowExecutionStatusJob < ApplicationJob workflow_execution.http_error_code = exception.http_error_code workflow_execution.save - WorkflowExecutionCleanupJob.set(wait_until: 30.seconds.from_now).perform_later(workflow_execution) + WorkflowExecutionCleanupJob.perform_later(workflow_execution) workflow_execution end - def perform(workflow_execution) # rubocop:disable Metrics/AbcSize + def perform(workflow_execution) # User signaled to cancel return if workflow_execution.canceling? || workflow_execution.canceled? @@ -28,9 +28,9 @@ def perform(workflow_execution) # rubocop:disable Metrics/AbcSize case workflow_execution.state.to_sym when :canceled, :error - WorkflowExecutionCleanupJob.set(wait_until: 30.seconds.from_now).perform_later(workflow_execution) + WorkflowExecutionCleanupJob.perform_later(workflow_execution) when :completing - WorkflowExecutionCompletionJob.set(wait_until: 30.seconds.from_now).perform_later(workflow_execution) + WorkflowExecutionCompletionJob.perform_later(workflow_execution) else WorkflowExecutionStatusJob.set(wait_until: 30.seconds.from_now).perform_later(workflow_execution) end diff --git a/app/jobs/workflow_execution_submission_job.rb b/app/jobs/workflow_execution_submission_job.rb index f4740ef9c7..1574872ac4 100644 --- a/app/jobs/workflow_execution_submission_job.rb +++ b/app/jobs/workflow_execution_submission_job.rb @@ -14,7 +14,7 @@ class WorkflowExecutionSubmissionJob < ApplicationJob workflow_execution.http_error_code = exception.http_error_code workflow_execution.save - WorkflowExecutionCleanupJob.set(wait_until: 30.seconds.from_now).perform_later(workflow_execution) + WorkflowExecutionCleanupJob.perform_later(workflow_execution) workflow_execution end diff --git a/app/services/data_exports/create_service.rb b/app/services/data_exports/create_service.rb index 2c67f0f4cf..b2559eb880 100644 --- a/app/services/data_exports/create_service.rb +++ b/app/services/data_exports/create_service.rb @@ -15,7 +15,7 @@ def execute if @data_export.valid? @data_export.export_type == 'analysis' ? validate_analysis_ids : validate_sample_ids @data_export.save - DataExports::CreateJob.set(wait_until: 30.seconds.from_now).perform_later(@data_export) + DataExports::CreateJob.perform_later(@data_export) end @data_export diff --git a/app/services/workflow_executions/cancel_service.rb b/app/services/workflow_executions/cancel_service.rb index 32921b01af..258e5fa575 100644 --- a/app/services/workflow_executions/cancel_service.rb +++ b/app/services/workflow_executions/cancel_service.rb @@ -8,7 +8,7 @@ def initialize(workflow_execution, user = nil) @workflow_execution = workflow_execution end - def execute # rubocop:disable Metrics/MethodLength,Metrics/AbcSize + def execute # rubocop:disable Metrics/MethodLength return false unless @workflow_execution.cancellable? authorize! @workflow_execution, to: :cancel? @@ -17,9 +17,7 @@ def execute # rubocop:disable Metrics/MethodLength,Metrics/AbcSize # Schedule a job to cancel the run on the ga4gh wes server @workflow_execution.state = :canceling @workflow_execution.save - WorkflowExecutionCancelationJob.set( - wait_until: 30.seconds.from_now - ).perform_later(@workflow_execution, current_user) + WorkflowExecutionCancelationJob.perform_later(@workflow_execution, current_user) elsif @workflow_execution.initial? # No files to clean up, mark as cleaned and do not create a cleanup job. @workflow_execution.state = :canceled @@ -29,7 +27,7 @@ def execute # rubocop:disable Metrics/MethodLength,Metrics/AbcSize # Files were generated but not sent to ga4gh, schedule a cleanup job @workflow_execution.state = :canceled @workflow_execution.save - WorkflowExecutionCleanupJob.set(wait_until: 30.seconds.from_now).perform_later(@workflow_execution) + WorkflowExecutionCleanupJob.perform_later(@workflow_execution) end @workflow_execution diff --git a/app/services/workflow_executions/cancelation_service.rb b/app/services/workflow_executions/cancelation_service.rb index 4583616248..b476ff727e 100644 --- a/app/services/workflow_executions/cancelation_service.rb +++ b/app/services/workflow_executions/cancelation_service.rb @@ -19,7 +19,7 @@ def execute @workflow_execution.save - WorkflowExecutionCleanupJob.set(wait_until: 30.seconds.from_now).perform_later(@workflow_execution) + WorkflowExecutionCleanupJob.perform_later(@workflow_execution) @workflow_execution end diff --git a/app/services/workflow_executions/completion_service.rb b/app/services/workflow_executions/completion_service.rb index fc2064898b..66f18c47d8 100644 --- a/app/services/workflow_executions/completion_service.rb +++ b/app/services/workflow_executions/completion_service.rb @@ -45,7 +45,7 @@ def execute # rubocop:disable Metrics/MethodLength @workflow_execution.save - WorkflowExecutionCleanupJob.set(wait_until: 30.seconds.from_now).perform_later(@workflow_execution) + WorkflowExecutionCleanupJob.perform_later(@workflow_execution) @workflow_execution end diff --git a/app/services/workflow_executions/create_service.rb b/app/services/workflow_executions/create_service.rb index 850f319d53..bc1ec9f378 100644 --- a/app/services/workflow_executions/create_service.rb +++ b/app/services/workflow_executions/create_service.rb @@ -7,7 +7,7 @@ def initialize(user = nil, params = {}) super end - def execute # rubocop:disable Metrics/AbcSize + def execute return false if params.empty? @workflow_execution = WorkflowExecution.new(params) @@ -24,7 +24,7 @@ def execute # rubocop:disable Metrics/AbcSize if @workflow_execution.save create_activities - WorkflowExecutionPreparationJob.set(wait_until: 30.seconds.from_now).perform_later(@workflow_execution) + WorkflowExecutionPreparationJob.perform_later(@workflow_execution) end @workflow_execution