smart_proxy_dynflow 0.9.2 → 0.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e2bb41902cd0541c6537d973025ab615df030b6f9edf9a1d7938234b0b8830f1
4
- data.tar.gz: '06059e08fb8a8bfb9b5bc2bfea93c27ad9ed343ea5ae7fd0355893b8ddbcf664'
3
+ metadata.gz: e7e0e12ddc21b25d46fe7d1ea6c7af572f98d0fff69e19ebf4764059e41a6644
4
+ data.tar.gz: 2326988132e96960c1739c41b1b99f53452cf3684839f97e8cb4c050459b43df
5
5
  SHA512:
6
- metadata.gz: bed67548c8a5b98708b02ca0b7c40a526662e57323bd28b41820b2eb15df2b0d6963f3ccfdc10e379507f4aaaa82b081d7eb4fc31804155cd52e8e9f316f93aa
7
- data.tar.gz: a701930113e81e6e9a14dad07826b239f2f73265617b9666a3610d9d19750ca2817a129f86d8741ff835cbdb68e5c1e1bfd8c907ed796e4da0069482ffe7b6d0
6
+ metadata.gz: bc8c5012e01624d165f801e6de4f3d0707cbdcfa42437fc0887fe10ccc89d5606813fae0fc8761c73cee40bae0ae275d0115165521f903e7ee24f90a129423bb
7
+ data.tar.gz: a20e4eb660064c01d2ede0c5e38ccadaded5d0feac2768865e59295b2a3ba44a47be743a3bd074f68cdb11891930bbe08f8b554033f24907b64e0d0d09bd843b
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Proxy::Dynflow::Action::Middleware
4
+ class AssembleResults < ::Dynflow::Middleware
5
+ def present
6
+ unless %i[error success skipped].include?(action.run_step&.state)
7
+ action.output[:result] = action.output_result
8
+ end
9
+ pass
10
+ end
11
+ end
12
+ end
@@ -2,12 +2,16 @@
2
2
 
3
3
  require 'smart_proxy_dynflow/action/shareable'
4
4
  require 'smart_proxy_dynflow/action/external_polling'
5
+ require 'smart_proxy_dynflow/action/middleware/assemble_results'
6
+
5
7
  module Proxy::Dynflow
6
8
  module Action
7
9
  class Runner < Shareable
8
10
  include ::Dynflow::Action::Cancellable
9
11
  include ::Proxy::Dynflow::Action::WithExternalPolling
10
12
 
13
+ middleware.use ::Proxy::Dynflow::Action::Middleware::AssembleResults
14
+
11
15
  def run(event = nil)
12
16
  case event
13
17
  when nil
@@ -59,6 +63,7 @@ module Proxy::Dynflow
59
63
 
60
64
  def finish_run(update)
61
65
  output[:exit_status] = update.exit_status
66
+ output[:exit_status_timestamp] = update.exit_status_timestamp.to_f
62
67
  output[:result] = output_result
63
68
  drop_output_chunks!
64
69
  end
@@ -37,18 +37,20 @@ module Proxy::Dynflow
37
37
  raw_outputs.map { |output| output['output'] }.join("\n")
38
38
  end
39
39
 
40
- def add_exception(context, exception, timestamp = Time.now.getlocal)
41
- add_output(context + ": #{exception.class} - #{exception.message}", 'debug', timestamp)
40
+ def add_exception(context, exception, timestamp: Time.now.getlocal, id: nil)
41
+ add_output(context + ": #{exception.class} - #{exception.message}", 'debug', timestamp: timestamp, id: id)
42
42
  end
43
43
 
44
- def add_output(*args)
45
- add_raw_output(self.class.format_output(*args))
44
+ def add_output(...)
45
+ add_raw_output(self.class.format_output(...))
46
46
  end
47
47
 
48
- def self.format_output(message, type = 'debug', timestamp = Time.now.getlocal)
49
- { 'output_type' => type,
50
- 'output' => message,
51
- 'timestamp' => timestamp.to_f }
48
+ def self.format_output(message, type = 'debug', timestamp: Time.now.getlocal, id: nil)
49
+ base = { 'output_type' => type,
50
+ 'output' => message,
51
+ 'timestamp' => timestamp.to_f }
52
+ base['id'] = id if id
53
+ base
52
54
  end
53
55
  end
54
56
  end
@@ -72,16 +72,10 @@ module Proxy
72
72
  end
73
73
  end
74
74
 
75
- def expand_output(action)
76
- hash = action.to_hash
77
- hash[:output][:result] = action.output_result if action.is_a?(Proxy::Dynflow::Action::Runner)
78
- hash
79
- end
80
-
81
75
  def execution_plan_status(plan)
82
76
  actions = plan.actions.map do |action|
83
77
  refresh_output(plan, action)
84
- expand_output(action)
78
+ action.to_hash
85
79
  end
86
80
  plan.to_hash.merge(:actions => actions)
87
81
  end
@@ -58,8 +58,8 @@ module Proxy::Dynflow
58
58
  # or nil for no timeout
59
59
  end
60
60
 
61
- def publish_data(data, type)
62
- @continuous_output.add_output(data, type)
61
+ def publish_data(...)
62
+ @continuous_output.add_output(...)
63
63
  end
64
64
 
65
65
  def publish_exception(context, exception, fatal = true)
@@ -71,6 +71,7 @@ module Proxy::Dynflow
71
71
 
72
72
  def publish_exit_status(status)
73
73
  @exit_status = status
74
+ @exit_status_timestamp = Time.now.utc
74
75
  end
75
76
 
76
77
  def dispatch_exception(context, exception)
@@ -90,7 +91,7 @@ module Proxy::Dynflow
90
91
  end
91
92
 
92
93
  def new_update(data, exit_status)
93
- { @suspended_action => Runner::Update.new(data, exit_status) }
94
+ { @suspended_action => Runner::Update.new(data, exit_status, exit_status_timestamp: @exit_status_timestamp) }
94
95
  end
95
96
 
96
97
  def initialize_continuous_outputs
@@ -13,13 +13,13 @@ module Proxy::Dynflow
13
13
 
14
14
  def generate_updates
15
15
  base = {}
16
- base[@suspended_action] = Runner::Update.new(Proxy::Dynflow::ContinuousOutput.new, @exit_status) if @exit_status
16
+ base[@suspended_action] = Runner::Update.new(Proxy::Dynflow::ContinuousOutput.new, @exit_status, exit_status_timestamp: @exit_status_timestamp) if @exit_status
17
17
  # Operate on all hosts if the main process ended or only on hosts for which we have updates
18
18
  @outputs.reject { |_, output| @exit_status.nil? && output.empty? }
19
19
  .reduce(base) do |acc, (identifier, output)|
20
20
  @outputs[identifier] = Proxy::Dynflow::ContinuousOutput.new # Create a new ContinuousOutput for next round of updates
21
21
  exit_status = @exit_statuses[identifier] || @exit_status if @exit_status
22
- acc.merge(host_action(identifier) => Runner::Update.new(output, exit_status))
22
+ acc.merge(host_action(identifier) => Runner::Update.new(output, exit_status, exit_status_timestamp: @exit_status_timestamp))
23
23
  end
24
24
  end
25
25
 
@@ -35,16 +35,16 @@ module Proxy::Dynflow
35
35
  Dynflow::Action::Suspended.new OpenStruct.new(options)
36
36
  end
37
37
 
38
- def broadcast_data(data, type)
39
- @outputs.each_value { |output| output.add_output(data, type) }
38
+ def broadcast_data(...)
39
+ @outputs.each_value { |output| output.add_output(...) }
40
40
  end
41
41
 
42
42
  def publish_data(_data, _type)
43
43
  true
44
44
  end
45
45
 
46
- def publish_data_for(identifier, data, type)
47
- @outputs[identifier].add_output(data, type)
46
+ def publish_data_for(identifier, data, type, **kwargs)
47
+ @outputs[identifier].add_output(data, type, **kwargs)
48
48
  end
49
49
 
50
50
  def dispatch_exception(context, exception)
@@ -7,11 +7,12 @@ module Proxy::Dynflow
7
7
  # Runner::Update represents chunk of data produced by runner that
8
8
  # can be consumed by other components, such as RunnerAction
9
9
  class Update
10
- attr_reader :continuous_output, :exit_status
10
+ attr_reader :continuous_output, :exit_status, :exit_status_timestamp
11
11
 
12
- def initialize(continuous_output, exit_status)
12
+ def initialize(continuous_output, exit_status, exit_status_timestamp: nil)
13
13
  @continuous_output = continuous_output
14
14
  @exit_status = exit_status
15
+ @exit_status_timestamp = exit_status_timestamp || Time.now.utc if @exit_status
15
16
  end
16
17
 
17
18
  def self.encode_exception(context, exception, fatal = true)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Proxy
4
4
  module Dynflow
5
- VERSION = '0.9.2'
5
+ VERSION = '0.9.4'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_proxy_dynflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Nečas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-05 00:00:00.000000000 Z
11
+ date: 2024-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dynflow
@@ -68,6 +68,7 @@ files:
68
68
  - lib/smart_proxy_dynflow/action/batch_callback.rb
69
69
  - lib/smart_proxy_dynflow/action/batch_runner.rb
70
70
  - lib/smart_proxy_dynflow/action/external_polling.rb
71
+ - lib/smart_proxy_dynflow/action/middleware/assemble_results.rb
71
72
  - lib/smart_proxy_dynflow/action/output_collector.rb
72
73
  - lib/smart_proxy_dynflow/action/runner.rb
73
74
  - lib/smart_proxy_dynflow/action/shareable.rb
@@ -107,7 +108,7 @@ files:
107
108
  - settings.d/dynflow.yml.example
108
109
  homepage: https://github.com/theforeman/smart_proxy_dynflow
109
110
  licenses:
110
- - GPL-3.0
111
+ - GPL-3.0-only
111
112
  metadata:
112
113
  rubygems_mfa_required: 'true'
113
114
  post_install_message:
@@ -128,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
129
  - !ruby/object:Gem::Version
129
130
  version: '0'
130
131
  requirements: []
131
- rubygems_version: 3.3.26
132
+ rubygems_version: 3.3.27
132
133
  signing_key:
133
134
  specification_version: 4
134
135
  summary: Dynflow runtime for Foreman smart proxy