app/lib/actions/proxy_action.rb in foreman-tasks-0.8.6 vs app/lib/actions/proxy_action.rb in foreman-tasks-0.9.0

- old
+ new

@@ -45,20 +45,20 @@ suspend do |_suspended_action| set_timeout! unless timeout_set? response = proxy.trigger_task(proxy_action_name, input.merge(:callback => { :task_id => task.id, :step_id => run_step_id })) - output[:proxy_task_id] = response["task_id"] + output[:proxy_task_id] = response['task_id'] end end def check_task_status if output[:proxy_task_id] response = proxy.status_of_task(output[:proxy_task_id]) if %w(stopped paused).include? response['state'] if response['result'] == 'error' - raise ::Foreman::Exception, _("The smart proxy task %s failed.") % (output[:proxy_task_id]) + raise ::Foreman::Exception, _('The smart proxy task %s failed.') % output[:proxy_task_id] else on_data(response['actions'].find { |block_action| block_action['class'] == proxy_action_name }['output']) end else suspend @@ -68,11 +68,11 @@ end end def cancel_proxy_task if output[:cancel_sent] - error! ForemanTasks::Task::TaskCancelledException.new(_("Cancel enforced: the task might be still running on the proxy")) + error! ForemanTasks::Task::TaskCancelledException.new(_('Cancel enforced: the task might be still running on the proxy')) else proxy.cancel_task(output[:proxy_task_id]) output[:cancel_sent] = true suspend end @@ -110,11 +110,11 @@ # The proxy action is able to contribute to continuous output def fill_continuous_output(continuous_output) failed_proxy_tasks.each do |failure_data| message = _('Initialization error: %s') % - "#{failure_data[:exception_class]} - #{failure_data[:exception_message]}" + "#{failure_data[:exception_class]} - #{failure_data[:exception_message]}" continuous_output.add_output(message, 'debug', failure_data[:timestamp]) end end def proxy_output=(output) @@ -134,21 +134,21 @@ def timeout_set? !metadata[:timeout].nil? end def set_timeout! - time = Time.now + input[:connection_options][:timeout] + time = Time.zone.now + input[:connection_options][:timeout] schedule_timeout(time) metadata[:timeout] = time.to_s end def default_connection_options # Fails if the plan is not finished within 60 seconds from the first task trigger attempt on the smart proxy # If the triggering fails, it retries 3 more times with 15 second delays { :retry_interval => Setting['foreman_tasks_proxy_action_retry_interval'] || 15, - :retry_count => Setting['foreman_tasks_proxy_action_retry_count' ] || 4, - :timeout => Setting['foreman_tasks_proxy_action_start_timeout'] || 60 } + :retry_count => Setting['foreman_tasks_proxy_action_retry_count'] || 4, + :timeout => Setting['foreman_tasks_proxy_action_start_timeout'] || 60 } end private def failed_proxy_tasks @@ -177,10 +177,10 @@ failed_proxy_tasks << format_exception(exception) output[:proxy_task_id] = nil if failed_proxy_tasks.count < options[:retry_count] suspend do |suspended_action| @world.clock.ping suspended_action, - Time.now + options[:retry_interval], + Time.zone.now + options[:retry_interval], event end else raise exception end