foreman-tasks-core 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 51ca893401a1fbb6ce8b33970e95867d12b99523b36867ad8ae778efff6af18b
4
- data.tar.gz: 7113cbc6e40d91de62f7275233ef787f6ae35b970be37c33c3cb614bb52fc1b1
3
+ metadata.gz: 9eeba72428b030c0bcec9f51c7b58cbfb7e046eb7279b68b6030b46aaa72a434
4
+ data.tar.gz: 9a40808da08504914c856d9407a7d454a5c5045125a768ee5d6b54424444bd93
5
5
  SHA512:
6
- metadata.gz: '09024d809f19da128ab6f929cd4e50c39aabae1ce1a510ec537f0e36ad83fb4bbce384d1e3ce161c2eb2ecf006c1abf04b1822eaaabcf5c988582fa0858ded21'
7
- data.tar.gz: 0610b37f1608bc3816315d50c9fdde8474a9a9e7a64683efd983e955e109526537266c568fe13d1a2a64e9d4d4d4031a2d9c53e832c8efa13d5076b6f83a6da5
6
+ metadata.gz: c9cd9a1e5c8f247bd5b3f335998d2cba76d2a17ba6edfae529713f6eaaa60de6133d61125e76175544a8248f259f48bfa715de46cd4f1ff5132844d1c5c0250d
7
+ data.tar.gz: 2ddb3a83487315cdbc6ecf32886d67f599badb47f61f02019122fed0103602af72f0c8e5f999016dfec36a3caa56c17202fb3ce0426f5814084d5703bd702991
@@ -120,39 +120,33 @@ module ForemanTasksCore
120
120
 
121
121
  def start(suspended_action, runner)
122
122
  synchronize do
123
- begin
124
- raise "Actor with runner id #{runner.id} already exists" if @runner_actors[runner.id]
125
- runner.logger = @logger
126
- runner_actor = RunnerActor.spawn("runner-actor-#{runner.id}", self, suspended_action, runner, @clock, @logger)
127
- @runner_actors[runner.id] = runner_actor
128
- @runner_suspended_actions[runner.id] = suspended_action
129
- runner_actor.tell(:start_runner)
130
- return runner.id
131
- rescue => exception
132
- _handle_command_exception(runner.id, exception)
133
- return nil
134
- end
123
+ raise "Actor with runner id #{runner.id} already exists" if @runner_actors[runner.id]
124
+ runner.logger = @logger
125
+ runner_actor = RunnerActor.spawn("runner-actor-#{runner.id}", self, suspended_action, runner, @clock, @logger)
126
+ @runner_actors[runner.id] = runner_actor
127
+ @runner_suspended_actions[runner.id] = suspended_action
128
+ runner_actor.tell(:start_runner)
129
+ return runner.id
130
+ rescue => exception
131
+ _handle_command_exception(runner.id, exception)
132
+ return nil
135
133
  end
136
134
  end
137
135
 
138
136
  def kill(runner_id)
139
137
  synchronize do
140
- begin
141
- runner_actor = @runner_actors[runner_id]
142
- runner_actor.tell(:kill) if runner_actor
143
- rescue => exception
144
- _handle_command_exception(runner_id, exception, false)
145
- end
138
+ runner_actor = @runner_actors[runner_id]
139
+ runner_actor.tell(:kill) if runner_actor
140
+ rescue => exception
141
+ _handle_command_exception(runner_id, exception, false)
146
142
  end
147
143
  end
148
144
 
149
145
  def finish(runner_id)
150
146
  synchronize do
151
- begin
152
- _finish(runner_id)
153
- rescue => exception
154
- _handle_command_exception(runner_id, exception, false)
155
- end
147
+ _finish(runner_id)
148
+ rescue => exception
149
+ _handle_command_exception(runner_id, exception, false)
156
150
  end
157
151
  end
158
152
 
@@ -10,21 +10,19 @@ module ForemanTasksCore
10
10
  end
11
11
 
12
12
  def generate_updates
13
- @outputs.reduce({}) do |acc, (key, value)|
14
- if value.empty? && @exit_status.nil?
15
- acc
16
- else
17
- identifier = key
18
- @outputs[identifier] = ForemanTasksCore::ContinuousOutput.new
19
- key = host_action(identifier) unless identifier == @suspended_action
20
- exit_status = @exit_statuses[identifier] || @exit_status if @exit_status
21
- acc.merge(key => Runner::Update.new(value, exit_status))
22
- end
23
- end
13
+ base = {}
14
+ base[@suspended_action] = Runner::Update.new(ForemanTasksCore::ContinuousOutput.new, @exit_status) if @exit_status
15
+ # Operate on all hosts if the main process ended or only on hosts for which we have updates
16
+ @outputs.reject { |_, output| @exit_status.nil? && output.empty? }
17
+ .reduce(base) do |acc, (identifier, output)|
18
+ @outputs[identifier] = ForemanTasksCore::ContinuousOutput.new # Create a new ContinuousOutput for next round of updates
19
+ exit_status = @exit_statuses[identifier] || @exit_status if @exit_status
20
+ acc.merge(host_action(identifier) => Runner::Update.new(output, exit_status))
21
+ end
24
22
  end
25
23
 
26
24
  def initialize_continuous_outputs
27
- @outputs = ([@suspended_action] + @targets.keys).reduce({}) do |acc, target|
25
+ @outputs = @targets.keys.reduce({}) do |acc, target|
28
26
  acc.merge(target => ForemanTasksCore::ContinuousOutput.new)
29
27
  end
30
28
  end
@@ -39,8 +37,8 @@ module ForemanTasksCore
39
37
  @outputs.each { |_k, output| output.add_output(data, type) }
40
38
  end
41
39
 
42
- def publish_data(data, type)
43
- @outputs[@suspended_action].add_output(data, type)
40
+ def publish_data(_data, _type)
41
+ true
44
42
  end
45
43
 
46
44
  def publish_data_for(identifier, data, type)
@@ -1,3 +1,3 @@
1
1
  module ForemanTasksCore
2
- VERSION = '0.3.4'.freeze
2
+ VERSION = '0.3.5'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman-tasks-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Nečas
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-03 00:00:00.000000000 Z
11
+ date: 2021-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dynflow
@@ -26,7 +26,7 @@ dependencies:
26
26
  version: 1.2.0
27
27
  description: 'Common code used both at Forman and Foreman proxy regarding tasks
28
28
 
29
- '
29
+ '
30
30
  email:
31
31
  - inecas@redhat.com
32
32
  executables: []
@@ -60,9 +60,10 @@ files:
60
60
  - lib/foreman_tasks_core/ticker.rb
61
61
  - lib/foreman_tasks_core/version.rb
62
62
  homepage: https://github.com/theforeman/foreman-tasks
63
- licenses: []
63
+ licenses:
64
+ - GPL-3.0
64
65
  metadata: {}
65
- post_install_message:
66
+ post_install_message:
66
67
  rdoc_options: []
67
68
  require_paths:
68
69
  - lib
@@ -77,8 +78,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
78
  - !ruby/object:Gem::Version
78
79
  version: '0'
79
80
  requirements: []
80
- rubygems_version: 3.0.3
81
- signing_key:
81
+ rubygems_version: 3.1.2
82
+ signing_key:
82
83
  specification_version: 4
83
84
  summary: Common code used both at Forman and Foreman proxy regarding tasks
84
85
  test_files: []