Sha256: ab4e3d60bd15c693f9c11f1bcaa302aacc2a06cc615530b529b41a5db118138e

Contents?: true

Size: 953 Bytes

Versions: 8

Compression:

Stored size: 953 Bytes

Contents

module Actions
  module RemoteExecution
    module TemplateInvocationProgressLogging
      def template_invocation
        @template_invocation ||= TemplateInvocation.find_by(:run_host_job_task_id => task.id)
      end

      def log_template_invocation_exception(exception)
        id = 'exception-' + SecureRandom.hex(4)
        template_invocation.template_invocation_events.create!(
          :event_type => 'debug',
          :event => "#{exception.class}: #{exception.message}",
          :timestamp => Time.zone.now,
          :external_id => id
        )
      end

      def with_template_invocation_error_logging
        unless catch(::Dynflow::Action::ERROR) { yield || true }
          log_template_invocation_exception(error.exception)
          throw ::Dynflow::Action::ERROR
        end
      rescue => e # rubocop:disable Style/RescueStandardError
        log_template_invocation_exception(e)
        raise e
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
foreman_remote_execution-15.0.2 app/lib/actions/remote_execution/template_invocation_progress_logging.rb
foreman_remote_execution-15.0.1 app/lib/actions/remote_execution/template_invocation_progress_logging.rb
foreman_remote_execution-15.0.0 app/lib/actions/remote_execution/template_invocation_progress_logging.rb
foreman_remote_execution-14.1.4 app/lib/actions/remote_execution/template_invocation_progress_logging.rb
foreman_remote_execution-14.1.3 app/lib/actions/remote_execution/template_invocation_progress_logging.rb
foreman_remote_execution-14.1.2 app/lib/actions/remote_execution/template_invocation_progress_logging.rb
foreman_remote_execution-14.1.1 app/lib/actions/remote_execution/template_invocation_progress_logging.rb
foreman_remote_execution-14.1.0 app/lib/actions/remote_execution/template_invocation_progress_logging.rb