foreman-tasks 0.6.15 → 0.7.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 +8 -8
- data/config/routes.rb +1 -1
- data/lib/foreman_tasks.rb +1 -2
- data/lib/foreman_tasks/dynflow.rb +2 -8
- data/lib/foreman_tasks/dynflow/configuration.rb +19 -13
- data/lib/foreman_tasks/dynflow/daemon.rb +4 -29
- data/lib/foreman_tasks/dynflow/persistence.rb +2 -0
- data/lib/foreman_tasks/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YzVkNDM3MzdlYjM0YmI2NTE5ZjE3YTY4MmYyNWQ2NDMyYmFlYzgxMA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MGFiYzQ3MGQyMWFlMTkyNjBjMDYzZGFkNDA3YTdkNTAyZGI1Yzg5MQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ODk5NDBhNDQ5MDI5YjI0ODQ4NDkyNDUwYTYxY2FjODM0ZTZjNzk5N2Y2YmI3
|
10
|
+
MDhjNWM1MDEyOTg4ZmE5NjIyNGNjYjJhZjUwMjRmMTQ1OGZiNjA5MWNiODQw
|
11
|
+
YTNlOTgwZjM5ZTE4MWQ2OTg3YTc0MzZhMDdiMGE5YjIwN2I1Mjk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZmNmZmM4OGIyNDI0OWY0NGYxYmY4YTQxZmM0NDkyNmFmNmVmYjkwZDdhOWYy
|
14
|
+
MGU1ZDI5MzI1ZmQxNzBkOWNiMWQwNGYzNjk0YTI4YmYzZGI1NTcyZGEwMzgw
|
15
|
+
ZDM3MDFlNzM2YmZkOGQwMGMzMDE3MjI4NzczYzVhNzIyMTQ5OGE=
|
data/config/routes.rb
CHANGED
data/lib/foreman_tasks.rb
CHANGED
@@ -21,8 +21,7 @@ module ForemanTasks
|
|
21
21
|
Match! async, true, false
|
22
22
|
|
23
23
|
match trigger(action, *args, &block),
|
24
|
-
(on ::Dynflow::World::PlaningFailed.(error: ~any) |
|
25
|
-
::Dynflow::World::ExecutionFailed.(error: ~any) do |error|
|
24
|
+
(on ::Dynflow::World::PlaningFailed.(error: ~any) do |error|
|
26
25
|
raise error
|
27
26
|
end),
|
28
27
|
(on ::Dynflow::World::Triggered.(execution_plan_id: ~any, future: ~any) do |id, finished|
|
@@ -45,13 +45,7 @@ module ForemanTasks
|
|
45
45
|
|
46
46
|
# don't try to do any rescuing until the tables are properly migrated
|
47
47
|
if !Foreman.in_rake?('db:migrate') && (ForemanTasks::Task.table_exists? rescue(false))
|
48
|
-
|
49
|
-
# is no remote executor. We should be able to check the consistency
|
50
|
-
# every time the new world is created when there is a register
|
51
|
-
# of executors
|
52
|
-
world.consistency_check
|
53
|
-
world.execute_planned_execution_plans
|
54
|
-
|
48
|
+
world.auto_execute
|
55
49
|
ForemanTasks::Task::DynflowTask.consistency_check
|
56
50
|
end
|
57
51
|
end
|
@@ -87,7 +81,7 @@ module ForemanTasks
|
|
87
81
|
end
|
88
82
|
|
89
83
|
def web_console
|
90
|
-
::Dynflow::
|
84
|
+
::Dynflow::Web.setup do
|
91
85
|
before do
|
92
86
|
if !Setting[:dynflow_enable_console] ||
|
93
87
|
(Setting[:dynflow_console_require_auth] && !ConsoleAuthorizer.new(env).allow?)
|
@@ -18,10 +18,6 @@ module ForemanTasks
|
|
18
18
|
attr_accessor :remote
|
19
19
|
alias_method :remote?, :remote
|
20
20
|
|
21
|
-
# if remote set to true, use this path for socket communication
|
22
|
-
# between this process and the external executor
|
23
|
-
attr_accessor :remote_socket_path
|
24
|
-
|
25
21
|
# what transaction adapater should be used, by default, it uses the ActiveRecord
|
26
22
|
# based adapter, expecting ActiveRecord is used as ORM in the application
|
27
23
|
attr_accessor :transaction_adapter
|
@@ -44,7 +40,6 @@ module ForemanTasks
|
|
44
40
|
self.pool_size = 5
|
45
41
|
self.db_pool_size = pool_size + 5
|
46
42
|
self.remote = Rails.env.production?
|
47
|
-
self.remote_socket_path = File.join(Rails.root, "tmp", "sockets", "dynflow_socket")
|
48
43
|
self.transaction_adapter = ::Dynflow::TransactionAdapters::ActiveRecord.new
|
49
44
|
self.eager_load_paths = []
|
50
45
|
self.lazy_initialization = !Rails.env.production?
|
@@ -58,7 +53,7 @@ module ForemanTasks
|
|
58
53
|
end
|
59
54
|
|
60
55
|
def initialize_world(world_class = ::Dynflow::World)
|
61
|
-
world_class.new(
|
56
|
+
world_class.new(world_config).tap do |world|
|
62
57
|
@on_init.each { |init| init.call(world) }
|
63
58
|
end
|
64
59
|
end
|
@@ -98,12 +93,19 @@ module ForemanTasks
|
|
98
93
|
protected
|
99
94
|
|
100
95
|
# generates the options hash consumable by the Dynflow's world
|
101
|
-
def
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
96
|
+
def world_config
|
97
|
+
::Dynflow::Config.new.tap do |config|
|
98
|
+
config.auto_rescue = true
|
99
|
+
config.logger_adapter = ::Dynflow::LoggerAdapters::Delegator.new(action_logger, dynflow_logger)
|
100
|
+
config.pool_size = 5
|
101
|
+
config.persistence_adapter = initialize_persistence
|
102
|
+
config.transaction_adapter = transaction_adapter
|
103
|
+
config.executor = ->(world, _) { initialize_executor(world) }
|
104
|
+
config.connector = ->(world, _) { initialize_connector(world) }
|
105
|
+
|
106
|
+
# we can't do any operation until the ForemanTasks.dynflow.world is set
|
107
|
+
config.auto_execute = false
|
108
|
+
end
|
107
109
|
end
|
108
110
|
|
109
111
|
def default_sequel_adapter_options
|
@@ -125,12 +127,16 @@ module ForemanTasks
|
|
125
127
|
|
126
128
|
def initialize_executor(world)
|
127
129
|
if self.remote?
|
128
|
-
|
130
|
+
false
|
129
131
|
else
|
130
132
|
::Dynflow::Executors::Parallel.new(world, self.pool_size)
|
131
133
|
end
|
132
134
|
end
|
133
135
|
|
136
|
+
def initialize_connector(world)
|
137
|
+
::Dynflow::Connectors::Database.new(world)
|
138
|
+
end
|
139
|
+
|
134
140
|
# Sequel adapter based on Rails app database.yml configuration
|
135
141
|
def initialize_persistence
|
136
142
|
ForemanTasks::Dynflow::Persistence.new(default_sequel_adapter_options)
|
@@ -3,7 +3,7 @@ require 'fileutils'
|
|
3
3
|
module ForemanTasks
|
4
4
|
class Dynflow::Daemon
|
5
5
|
|
6
|
-
# load the Rails environment and initialize the executor
|
6
|
+
# load the Rails environment and initialize the executor
|
7
7
|
# in this thread.
|
8
8
|
def run(foreman_root = Dir.pwd)
|
9
9
|
STDERR.puts("Starting Rails environment")
|
@@ -13,10 +13,10 @@ module ForemanTasks
|
|
13
13
|
end
|
14
14
|
ForemanTasks.dynflow.executor!
|
15
15
|
require foreman_env_file
|
16
|
-
STDERR.puts("Starting listener")
|
17
|
-
daemon = ::Dynflow::Daemon.new(listener, world, lock_file)
|
18
16
|
STDERR.puts("Everything ready")
|
19
|
-
|
17
|
+
sleep
|
18
|
+
ensure
|
19
|
+
STDERR.puts("Exiting")
|
20
20
|
end
|
21
21
|
|
22
22
|
# run the executor as a daemon
|
@@ -54,35 +54,10 @@ module ForemanTasks
|
|
54
54
|
exit 1
|
55
55
|
end
|
56
56
|
end
|
57
|
-
if command == "start" || command == "restart"
|
58
|
-
STDERR.puts('Waiting for the executor to be ready...')
|
59
|
-
options[:wait_attempts].times do |i|
|
60
|
-
STDERR.print('.')
|
61
|
-
if File.exists?(lock_file)
|
62
|
-
STDERR.puts('executor started successfully')
|
63
|
-
break
|
64
|
-
else
|
65
|
-
sleep options[:wait_sleep]
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
57
|
end
|
70
58
|
|
71
59
|
protected
|
72
60
|
|
73
|
-
def listener
|
74
|
-
FileUtils.mkdir_p(File.dirname(socket_path))
|
75
|
-
::Dynflow::Listeners::Socket.new(world, socket_path)
|
76
|
-
end
|
77
|
-
|
78
|
-
def socket_path
|
79
|
-
ForemanTasks.dynflow.config.remote_socket_path
|
80
|
-
end
|
81
|
-
|
82
|
-
def lock_file
|
83
|
-
File.join(Rails.root, 'tmp', 'dynflow_executor.lock')
|
84
|
-
end
|
85
|
-
|
86
61
|
def world
|
87
62
|
ForemanTasks.dynflow.world
|
88
63
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman-tasks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Nečas
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.8.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.8.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: sequel
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|