smart_proxy_dynflow 0.9.3 → 1.0.0

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: f4cbd5ee3715ae77a996375dad27d44ef2eba5bde98687c01852b63f018de384
4
- data.tar.gz: f4852c006912c4d80e9ddd1f3aa846d17845dfc46a34ae047ec0dad6887d6c93
3
+ metadata.gz: 1d83b16dc061524ea6fd926d762b5c277ec04d67a343ee284fc07150288bc023
4
+ data.tar.gz: ebce0c873b7c456628669889581c4cddab8c534f81bdd4b60f36dd1de99bb9fe
5
5
  SHA512:
6
- metadata.gz: af596d7d35ec2d1231864f0982f4af90944a723998e6666343ad0cda0fd5b1c470e3ece13e7d89b4940c3ae4c22099d3f31dbd46e58dd8c5a56f90e40e408995
7
- data.tar.gz: be433c2faeaf439e79ef77b05c36bec2c42b44f98e524b216cc0419b2097b32481a75977aa9c34f248b21c944b5ae71a98a71e1f6b5cccf786e3d12ad14d697a
6
+ metadata.gz: 2f0fd0fb0fe9251accb11d7759bfd9ca1319325ac5244d5f17d53af9e887b29bbf45a95689d1cca47b218707a589d6b31e7d7b8b57bf3f92a7a7cfeb465aa2df
7
+ data.tar.gz: af76df1a492d8175052d8211955301390376941814c3780f70d9ade1fd9a1aaa82406f856012667d7c5dd0c9c1b08f6c90cb84c3468dcb50668c5b93e8f285c4
@@ -63,6 +63,7 @@ module Proxy::Dynflow
63
63
 
64
64
  def finish_run(update)
65
65
  output[:exit_status] = update.exit_status
66
+ output[:exit_status_timestamp] = update.exit_status_timestamp.to_f
66
67
  output[:result] = output_result
67
68
  drop_output_chunks!
68
69
  end
@@ -13,7 +13,7 @@ module Proxy
13
13
 
14
14
  include ::Sinatra::Authorization::Helpers
15
15
 
16
- TASK_UPDATE_REGEXP_PATH = %r{/tasks/(\S+)/(update|done)}.freeze
16
+ TASK_UPDATE_REGEXP_PATH = %r{/tasks/(\S+)/(update|done)}
17
17
 
18
18
  before do
19
19
  if match = request.path_info.match(TASK_UPDATE_REGEXP_PATH)
@@ -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
@@ -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.3'
5
+ VERSION = '1.0.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,29 +1,34 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_proxy_dynflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Nečas
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-08-14 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: dynflow
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
- - - "~>"
16
+ - - ">="
18
17
  - !ruby/object:Gem::Version
19
18
  version: '1.6'
19
+ - - "<"
20
+ - !ruby/object:Gem::Version
21
+ version: '3.0'
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
23
25
  requirements:
24
- - - "~>"
26
+ - - ">="
25
27
  - !ruby/object:Gem::Version
26
28
  version: '1.6'
29
+ - - "<"
30
+ - !ruby/object:Gem::Version
31
+ version: '3.0'
27
32
  - !ruby/object:Gem::Dependency
28
33
  name: rest-client
29
34
  requirement: !ruby/object:Gem::Requirement
@@ -108,10 +113,9 @@ files:
108
113
  - settings.d/dynflow.yml.example
109
114
  homepage: https://github.com/theforeman/smart_proxy_dynflow
110
115
  licenses:
111
- - GPL-3.0
116
+ - GPL-3.0-only
112
117
  metadata:
113
118
  rubygems_mfa_required: 'true'
114
- post_install_message:
115
119
  rdoc_options: []
116
120
  require_paths:
117
121
  - lib
@@ -119,18 +123,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
119
123
  requirements:
120
124
  - - ">="
121
125
  - !ruby/object:Gem::Version
122
- version: '2.7'
123
- - - "<"
124
- - !ruby/object:Gem::Version
125
- version: '4'
126
+ version: '3.0'
126
127
  required_rubygems_version: !ruby/object:Gem::Requirement
127
128
  requirements:
128
129
  - - ">="
129
130
  - !ruby/object:Gem::Version
130
131
  version: '0'
131
132
  requirements: []
132
- rubygems_version: 3.3.26
133
- signing_key:
133
+ rubygems_version: 4.0.3
134
134
  specification_version: 4
135
135
  summary: Dynflow runtime for Foreman smart proxy
136
136
  test_files: []