smart_proxy_remote_execution_ssh 0.10.1 → 0.10.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/smart_proxy_remote_execution_ssh/actions/pull_script.rb +8 -2
- data/lib/smart_proxy_remote_execution_ssh/mqtt/dispatcher.rb +28 -10
- data/lib/smart_proxy_remote_execution_ssh/multiplexed_ssh_connection.rb +2 -1
- data/lib/smart_proxy_remote_execution_ssh/runners/script_runner.rb +9 -4
- data/lib/smart_proxy_remote_execution_ssh/version.rb +1 -1
- data/lib/smart_proxy_remote_execution_ssh.rb +4 -1
- metadata +8 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e155b0459ac25c633c9c38de0d288b22779f5ea7f6d82146e5505b83cfd7e12e
|
|
4
|
+
data.tar.gz: 700810a05b8fac1b57ebcc4ca52c5c2de45575dac1b81fe9b84f5c066c6f1dad
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 11d92de711f06ee33deabf98442e5eb998a24cbd78f8b548a977cd2189a19e7ee998106d8935dbbfe7f1d7b74cc0fc7eb924430fb6f6a98b9565bcde09f917fd
|
|
7
|
+
data.tar.gz: f23cce7baef47c6651c1ef894b7f39d27b6b043153ed04e388940bab4898633689acd5aa66587be5f01651037d754357c8dd79f162e3d8a72a3430d6f7294efd
|
|
@@ -54,7 +54,9 @@ module Proxy::RemoteExecution::Ssh::Actions
|
|
|
54
54
|
|
|
55
55
|
plan_event(PickupTimeout, input[:time_to_pickup], optional: true) if input[:time_to_pickup]
|
|
56
56
|
|
|
57
|
-
input[:job_uuid] =
|
|
57
|
+
input[:job_uuid] =
|
|
58
|
+
job_storage.store_job(host_name, execution_plan_id, run_step_id, input[:script].tr("\r", ''),
|
|
59
|
+
effective_user: input[:effective_user])
|
|
58
60
|
output[:state] = READY_FOR_PICKUP
|
|
59
61
|
output[:result] = []
|
|
60
62
|
|
|
@@ -83,7 +85,11 @@ module Proxy::RemoteExecution::Ssh::Actions
|
|
|
83
85
|
|
|
84
86
|
def process_external_unversioned(payload)
|
|
85
87
|
continuous_output = Proxy::Dynflow::ContinuousOutput.new
|
|
86
|
-
|
|
88
|
+
if payload.key?('output')
|
|
89
|
+
Array(payload['output']).each do |line|
|
|
90
|
+
continuous_output.add_output(line, payload['type'])
|
|
91
|
+
end
|
|
92
|
+
end
|
|
87
93
|
exit_code = payload['exit_code'].to_i if payload['exit_code']
|
|
88
94
|
process_update(Proxy::Dynflow::Runner::Update.new(continuous_output, exit_code))
|
|
89
95
|
end
|
|
@@ -2,15 +2,39 @@ require 'concurrent'
|
|
|
2
2
|
require 'mqtt'
|
|
3
3
|
|
|
4
4
|
class Proxy::RemoteExecution::Ssh::MQTT
|
|
5
|
+
class DispatcherSupervisor < Concurrent::Actor::RestartingContext
|
|
6
|
+
def initialize
|
|
7
|
+
limit = Proxy::RemoteExecution::Ssh::Plugin.settings[:mqtt_rate_limit]
|
|
8
|
+
@dispatcher = DispatcherActor.spawn('MQTT dispatcher',
|
|
9
|
+
Proxy::Dynflow::Core.world.clock,
|
|
10
|
+
limit)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def on_message(message)
|
|
14
|
+
case message
|
|
15
|
+
when :dispatcher_reference
|
|
16
|
+
@dispatcher
|
|
17
|
+
when :resumed
|
|
18
|
+
# Carry on
|
|
19
|
+
else
|
|
20
|
+
pass
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# In case an exception is raised during processing, instruct concurrent-ruby
|
|
25
|
+
# to keep going without losing state
|
|
26
|
+
def behaviour_definition
|
|
27
|
+
Concurrent::Actor::Behaviour.restarting_behaviour_definition(:resume!)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
5
31
|
class Dispatcher
|
|
6
32
|
include Singleton
|
|
7
33
|
|
|
8
34
|
attr_reader :reference
|
|
9
35
|
def initialize
|
|
10
|
-
|
|
11
|
-
@reference =
|
|
12
|
-
Proxy::Dynflow::Core.world.clock,
|
|
13
|
-
limit)
|
|
36
|
+
@supervisor = DispatcherSupervisor.spawn(name: 'RestartingSupervisor', args: [])
|
|
37
|
+
@reference = @supervisor.ask!(:dispatcher_reference)
|
|
14
38
|
end
|
|
15
39
|
|
|
16
40
|
def new(uuid, topic, payload)
|
|
@@ -159,11 +183,5 @@ class Proxy::RemoteExecution::Ssh::MQTT
|
|
|
159
183
|
def timer_off
|
|
160
184
|
@timer.shutdown
|
|
161
185
|
end
|
|
162
|
-
|
|
163
|
-
# In case an exception is raised during processing, instruct concurrent-ruby
|
|
164
|
-
# to keep going without losing state
|
|
165
|
-
def behaviour_definition
|
|
166
|
-
Concurrent::Actor::Behaviour.restarting_behaviour_definition(:resume!)
|
|
167
|
-
end
|
|
168
186
|
end
|
|
169
187
|
end
|
|
@@ -103,7 +103,8 @@ module Proxy::RemoteExecution::Ssh::Runners
|
|
|
103
103
|
# does not close its stderr which trips up the process manager which
|
|
104
104
|
# expects all FDs to be closed
|
|
105
105
|
|
|
106
|
-
full_command = [method.ssh_command_prefix, 'ssh', establish_ssh_options, method.ssh_options, @host,
|
|
106
|
+
full_command = [method.ssh_command_prefix, 'ssh', establish_ssh_options, method.ssh_options, @host,
|
|
107
|
+
'true'].flatten
|
|
107
108
|
log_command(full_command)
|
|
108
109
|
pm = Proxy::Dynflow::ProcessManager.new(full_command)
|
|
109
110
|
pm.start!
|
|
@@ -90,7 +90,6 @@ module Proxy::RemoteExecution::Ssh::Runners
|
|
|
90
90
|
def reset; end
|
|
91
91
|
end
|
|
92
92
|
|
|
93
|
-
# rubocop:disable Metrics/ClassLength
|
|
94
93
|
class ScriptRunner < Proxy::Dynflow::Runner::Base
|
|
95
94
|
include Proxy::Dynflow::Runner::ProcessManagerCommand
|
|
96
95
|
include CommandLogging
|
|
@@ -180,7 +179,10 @@ module Proxy::RemoteExecution::Ssh::Runners
|
|
|
180
179
|
@output_path = File.join(File.dirname(@remote_script), 'output')
|
|
181
180
|
@exit_code_path = File.join(File.dirname(@remote_script), 'exit_code')
|
|
182
181
|
@pid_path = File.join(File.dirname(@remote_script), 'pid')
|
|
183
|
-
@remote_script_wrapper = upload_data(
|
|
182
|
+
@remote_script_wrapper = upload_data(
|
|
183
|
+
"echo $$ > #{@pid_path}; exec \"$@\";",
|
|
184
|
+
File.join(File.dirname(@remote_script), 'script-wrapper'),
|
|
185
|
+
555)
|
|
184
186
|
end
|
|
185
187
|
|
|
186
188
|
# the script that initiates the execution
|
|
@@ -192,7 +194,11 @@ module Proxy::RemoteExecution::Ssh::Runners
|
|
|
192
194
|
#{@remote_script_wrapper} #{@user_method.cli_command_prefix}#{su_method ? "'#{@remote_script} < /dev/null '" : "#{@remote_script} < /dev/null"}
|
|
193
195
|
echo \\$?>#{@exit_code_path}
|
|
194
196
|
EOF
|
|
195
|
-
|
|
197
|
+
if [ -f #{@exit_code_path} ] && [ $(wc -l < #{@exit_code_path}) -gt 0 ]; then
|
|
198
|
+
exit $(cat #{@exit_code_path})
|
|
199
|
+
else
|
|
200
|
+
exit 1
|
|
201
|
+
fi
|
|
196
202
|
SCRIPT
|
|
197
203
|
end
|
|
198
204
|
|
|
@@ -394,5 +400,4 @@ module Proxy::RemoteExecution::Ssh::Runners
|
|
|
394
400
|
end
|
|
395
401
|
end
|
|
396
402
|
end
|
|
397
|
-
# rubocop:enable Metrics/ClassLength
|
|
398
403
|
end
|
|
@@ -50,7 +50,10 @@ module Proxy::RemoteExecution
|
|
|
50
50
|
raise 'mqtt_port has to be set when pull-mqtt mode is used' if Plugin.settings.mqtt_port.nil?
|
|
51
51
|
|
|
52
52
|
if Plugin.settings.mqtt_tls.nil?
|
|
53
|
-
Plugin.settings.mqtt_tls = [[:foreman_ssl_cert, :ssl_certificate], [:foreman_ssl_key, :ssl_private_key],
|
|
53
|
+
Plugin.settings.mqtt_tls = [[:foreman_ssl_cert, :ssl_certificate], [:foreman_ssl_key, :ssl_private_key],
|
|
54
|
+
[:foreman_ssl_ca, :ssl_ca_file]].all? do |(client, server)|
|
|
55
|
+
::Proxy::SETTINGS[client] || ::Proxy::SETTINGS[server]
|
|
56
|
+
end
|
|
54
57
|
end
|
|
55
58
|
end
|
|
56
59
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: smart_proxy_remote_execution_ssh
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.10.
|
|
4
|
+
version: 0.10.2
|
|
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: 2023-
|
|
11
|
+
date: 2023-10-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -58,14 +58,14 @@ dependencies:
|
|
|
58
58
|
requirements:
|
|
59
59
|
- - "~>"
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '
|
|
61
|
+
version: '2.0'
|
|
62
62
|
type: :development
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
66
|
- - "~>"
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: '
|
|
68
|
+
version: '2.0'
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
70
|
name: webmock
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -192,7 +192,7 @@ homepage: https://github.com/theforeman/smart_proxy_remote_execution_ssh
|
|
|
192
192
|
licenses:
|
|
193
193
|
- GPL-3.0
|
|
194
194
|
metadata: {}
|
|
195
|
-
post_install_message:
|
|
195
|
+
post_install_message:
|
|
196
196
|
rdoc_options: []
|
|
197
197
|
require_paths:
|
|
198
198
|
- lib
|
|
@@ -207,8 +207,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
207
207
|
- !ruby/object:Gem::Version
|
|
208
208
|
version: '0'
|
|
209
209
|
requirements: []
|
|
210
|
-
rubygems_version: 3.
|
|
211
|
-
signing_key:
|
|
210
|
+
rubygems_version: 3.1.6
|
|
211
|
+
signing_key:
|
|
212
212
|
specification_version: 4
|
|
213
213
|
summary: Ssh remote execution provider for Foreman Smart-Proxy
|
|
214
214
|
test_files: []
|