foreman-tasks-core 0.1.1 → 0.1.2
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 +4 -4
- data/lib/foreman_tasks_core.rb +1 -1
- data/lib/foreman_tasks_core/continuous_output.rb +1 -1
- data/lib/foreman_tasks_core/runner/action.rb +2 -2
- data/lib/foreman_tasks_core/runner/base.rb +2 -2
- data/lib/foreman_tasks_core/runner/command_runner.rb +1 -1
- data/lib/foreman_tasks_core/runner/dispatcher.rb +6 -6
- data/lib/foreman_tasks_core/runner/update.rb +1 -1
- data/lib/foreman_tasks_core/settings_loader.rb +2 -2
- data/lib/foreman_tasks_core/version.rb +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7182c93db320880e8ab630c2edcfef6baa2f6ce0
|
4
|
+
data.tar.gz: b578ed3de2672e41910921ad1b5cfe0cc1872f6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f8d31d820535c4ed018bad60c64710579f31761f3c0cd16477ee776233a0b98498f57821e72899275c20f9b2de8d3a780d5b4dcfa4ccd4e5db2a51b801a2d54
|
7
|
+
data.tar.gz: 9c6c676b311f5d9507765409df16d1c49c72f3da1fea223d9c3496312a62048219cf89197f81aa5787a505b4f7204eb8f6ee6d0e8fd7631badddb08d6e7d346a
|
data/lib/foreman_tasks_core.rb
CHANGED
@@ -5,7 +5,7 @@ require 'foreman_tasks_core/settings_loader'
|
|
5
5
|
|
6
6
|
module ForemanTasksCore
|
7
7
|
def self.dynflow_world
|
8
|
-
raise
|
8
|
+
raise 'Dynflow world not set. Call initialize first' unless @dynflow_world
|
9
9
|
@dynflow_world
|
10
10
|
end
|
11
11
|
|
@@ -8,7 +8,7 @@ module ForemanTasksCore
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def add_raw_output(raw_output)
|
11
|
-
missing_args = %w
|
11
|
+
missing_args = %w(output_type output timestamp) - raw_output.keys
|
12
12
|
unless missing_args.empty?
|
13
13
|
raise ArgumentError, "Missing args for raw output: #{missing_args.inspect}"
|
14
14
|
end
|
@@ -17,12 +17,12 @@ module ForemanTasksCore
|
|
17
17
|
end
|
18
18
|
rescue => e
|
19
19
|
action_logger.error(e)
|
20
|
-
process_update(Runner::Update.encode_exception(
|
20
|
+
process_update(Runner::Update.encode_exception('Proxy error', e))
|
21
21
|
end
|
22
22
|
|
23
23
|
def finalize
|
24
24
|
# To mark the task as a whole as failed
|
25
|
-
error!
|
25
|
+
error! 'Script execution failed' if failed_run?
|
26
26
|
end
|
27
27
|
|
28
28
|
def rescue_strategy_for_self
|
@@ -6,7 +6,7 @@ module ForemanTasksCore
|
|
6
6
|
attr_reader :id
|
7
7
|
attr_accessor :logger
|
8
8
|
|
9
|
-
def initialize(*
|
9
|
+
def initialize(*_args)
|
10
10
|
@id = SecureRandom.uuid
|
11
11
|
@continuous_output = ::ForemanTasksCore::ContinuousOutput.new
|
12
12
|
end
|
@@ -16,7 +16,7 @@ module ForemanTasksCore
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def run_refresh
|
19
|
-
logger.debug(
|
19
|
+
logger.debug('refreshing runner')
|
20
20
|
refresh
|
21
21
|
new_data = @continuous_output
|
22
22
|
@continuous_output = ForemanTasksCore::ContinuousOutput.new
|
@@ -3,8 +3,8 @@ module ForemanTasksCore
|
|
3
3
|
class Dispatcher
|
4
4
|
def self.instance
|
5
5
|
return @instance if @instance
|
6
|
-
@instance =
|
7
|
-
|
6
|
+
@instance = new(ForemanTasksCore.dynflow_world.clock,
|
7
|
+
ForemanTasksCore.dynflow_world.logger)
|
8
8
|
end
|
9
9
|
|
10
10
|
class RunnerActor < ::Dynflow::Actor
|
@@ -34,7 +34,7 @@ module ForemanTasksCore
|
|
34
34
|
|
35
35
|
def refresh_runner
|
36
36
|
@logger.debug("refresh runner #{@runner.id}")
|
37
|
-
if update = @runner.run_refresh
|
37
|
+
if (update = @runner.run_refresh)
|
38
38
|
@suspended_action << update
|
39
39
|
finish if update.exit_status
|
40
40
|
end
|
@@ -68,7 +68,7 @@ module ForemanTasksCore
|
|
68
68
|
def plan_next_refresh
|
69
69
|
if !@finishing && !@refresh_planned
|
70
70
|
@logger.debug("planning to refresh #{@runner.id}")
|
71
|
-
@clock.ping(reference, Time.now + @refresh_interval, :refresh_runner)
|
71
|
+
@clock.ping(reference, Time.now.getlocal + @refresh_interval, :refresh_runner)
|
72
72
|
@refresh_planned = true
|
73
73
|
end
|
74
74
|
end
|
@@ -137,7 +137,7 @@ module ForemanTasksCore
|
|
137
137
|
def _finish(runner_id)
|
138
138
|
runner_actor = @runner_actors.delete(runner_id)
|
139
139
|
return unless runner_actor
|
140
|
-
@logger.debug("closing session for command [#{runner_id}],"
|
140
|
+
@logger.debug("closing session for command [#{runner_id}]," \
|
141
141
|
"#{@runner_actors.size} actors left ")
|
142
142
|
runner_actor.tell([:start_termination, Concurrent.future])
|
143
143
|
ensure
|
@@ -149,7 +149,7 @@ module ForemanTasksCore
|
|
149
149
|
"#{exception.class} #{exception.message}:\n #{exception.backtrace.join("\n")}")
|
150
150
|
suspended_action = @runner_suspended_actions[runner_id]
|
151
151
|
if suspended_action
|
152
|
-
suspended_action << Runner::Update.encode_exception(
|
152
|
+
suspended_action << Runner::Update.encode_exception('Runner error', exception, fatal)
|
153
153
|
end
|
154
154
|
_finish(runner_id) if fatal
|
155
155
|
end
|
@@ -14,7 +14,7 @@ module ForemanTasksCore
|
|
14
14
|
def self.encode_exception(context, exception, fatal = true)
|
15
15
|
continuous_output = ::ForemanTasksCore::ContinuousOutput.new
|
16
16
|
continuous_output.add_exception(context, exception)
|
17
|
-
|
17
|
+
new(continuous_output, fatal ? 'EXCEPTION' : nil)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -19,7 +19,7 @@ module ForemanTasksCore
|
|
19
19
|
def self.register_settings(names, object)
|
20
20
|
names = [names] unless names.is_a? Array
|
21
21
|
names.each do |name|
|
22
|
-
raise
|
22
|
+
raise 'settings name has to be a symbol' unless name.is_a? Symbol
|
23
23
|
raise "settings #{name} already registered" if SettingsLoader.settings_registered?(name)
|
24
24
|
name_to_settings[name] = object
|
25
25
|
end
|
@@ -47,7 +47,7 @@ module ForemanTasksCore
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def validate_settings!
|
50
|
-
raise
|
50
|
+
raise 'Only symbols expected in keys' unless @settings.keys.all? { |key| key.is_a? Symbol }
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
metadata
CHANGED
@@ -1,17 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman-tasks-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
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:
|
11
|
+
date: 2017-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
14
|
-
|
13
|
+
description: 'Common code used both at Forman and Foreman proxy regarding tasks
|
14
|
+
|
15
|
+
'
|
15
16
|
email:
|
16
17
|
- inecas@redhat.com
|
17
18
|
executables: []
|
@@ -49,7 +50,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
49
50
|
version: '0'
|
50
51
|
requirements: []
|
51
52
|
rubyforge_project:
|
52
|
-
rubygems_version: 2.
|
53
|
+
rubygems_version: 2.5.1
|
53
54
|
signing_key:
|
54
55
|
specification_version: 4
|
55
56
|
summary: Common code used both at Forman and Foreman proxy regarding tasks
|