Sha256: 11be67bbc5d43645907ec6a55abe0fc8298f7e7a930b73e4ad486d12e514b891
Contents?: true
Size: 1.84 KB
Versions: 7
Compression:
Stored size: 1.84 KB
Contents
module Actions module RemoteExecution class ProxyAction < ::Actions::ProxyAction include Actions::RemoteExecution::TemplateInvocationProgressLogging def on_data(data, meta = {}) super process_proxy_data(output[:proxy_output]) end def run(event = nil) with_template_invocation_error_logging { super } end private def check_task_status response = proxy.status_of_task(proxy_task_id) get_proxy_data(response) suspend unless %w[stopped paused].include? response['state'] rescue RestClient::NotFound on_proxy_action_missing end def get_proxy_data(response) data = super process_proxy_data(data) data end def process_proxy_data(data) events = data['result'].each_with_index.map do |update, seq_id| { # For N-1 compatibility, we assume that the output provided here is # complete sequence_id: update['sequence_id'] || seq_id, template_invocation_id: template_invocation.id, event: update['output'], timestamp: Time.at(update['timestamp']).getlocal, event_type: update['output_type'], } end if data['exit_status'] last = events.last || {:sequence_id => -1, :timestamp => Time.zone.now} events << { sequence_id: last[:sequence_id] + 1, template_invocation_id: template_invocation.id, event: data['exit_status'], timestamp: last[:timestamp], event_type: 'exit', } end events.each_slice(1000) do |batch| TemplateInvocationEvent.insert_all(batch, unique_by: [:template_invocation_id, :sequence_id]) # rubocop:disable Rails/SkipsModelValidations end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems