From 9fce321e3149ec069df3102ffdc6736f5b542e9c Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Wed, 20 Mar 2024 13:33:46 +0100 Subject: [PATCH] Fixes #TBFL - Fix proxy task gone missing, vol. 2 --- .../middleware/watch_delegated_proxy_sub_tasks.rb | 2 +- app/lib/actions/proxy_action.rb | 11 ++--------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/app/lib/actions/middleware/watch_delegated_proxy_sub_tasks.rb b/app/lib/actions/middleware/watch_delegated_proxy_sub_tasks.rb index ae2a612fc..8748c2266 100644 --- a/app/lib/actions/middleware/watch_delegated_proxy_sub_tasks.rb +++ b/app/lib/actions/middleware/watch_delegated_proxy_sub_tasks.rb @@ -46,7 +46,7 @@ def process_task_results(tasks, results) notify ::Actions::ProxyAction::ProxyActionMissing.new, missing if missing.any? stopped = present.select { |task| %w[stopped paused].include? results.dig(task.remote_task_id, 'state') } - notify ::Actions::ProxyAction::ProxyActionStopped.new, stopped if stopped.any? + notify ::Actions::ProxyAction::ProxyActionStoppedEvent[nil], stopped if stopped.any? end def notify(event, tasks) diff --git a/app/lib/actions/proxy_action.rb b/app/lib/actions/proxy_action.rb index 05e73daf6..41e749fb9 100644 --- a/app/lib/actions/proxy_action.rb +++ b/app/lib/actions/proxy_action.rb @@ -93,15 +93,8 @@ def proxy_input(task_id = task.id) def check_task_status response = proxy.status_of_task(proxy_task_id) - if %w[stopped paused].include? response['state'] - if response['result'] == 'error' - raise ::Foreman::Exception, _('The smart proxy task %s failed.') % proxy_task_id - else - on_data(get_proxy_data(response)) - end - else - suspend - end + on_data(get_proxy_data(response)) + suspend unless %w[stopped paused].include? response['state'] rescue RestClient::NotFound on_proxy_action_missing end