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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: debc9989aade4d23bda1b90e9fa8e85c99948f5b9ca37d6cecca7573bb994e5e
4
- data.tar.gz: 38a2731c7f28643daaa33ddd29f93172b7467877f36b12c750b82f86e921c04d
3
+ metadata.gz: e155b0459ac25c633c9c38de0d288b22779f5ea7f6d82146e5505b83cfd7e12e
4
+ data.tar.gz: 700810a05b8fac1b57ebcc4ca52c5c2de45575dac1b81fe9b84f5c066c6f1dad
5
5
  SHA512:
6
- metadata.gz: a3f5776ce0f6ad361f2c344d0ff5d5cef9b6b032e23dc42ae0e877298abd9e95c0156c77334b106036f376e62c60c01ab13344d6bda53baa52c93c7caba79b71
7
- data.tar.gz: d1de077038e5fce86df1871e4702e2abb4c7de4937f66aa8730803bb4542aa8f26c1c848d24bb74db1ce5594514d3a552b92b7ad315d346ead5e7586cb20da20
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] = job_storage.store_job(host_name, execution_plan_id, run_step_id, input[:script].tr("\r", ''), effective_user: input[:effective_user])
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
- Array(payload['output']).each { |line| continuous_output.add_output(line, payload['type']) } if payload.key?('output')
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
- limit = Proxy::RemoteExecution::Ssh::Plugin.settings[:mqtt_rate_limit]
11
- @reference = DispatcherActor.spawn('MQTT dispatcher',
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, 'true'].flatten
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("echo $$ > #{@pid_path}; exec \"$@\";", File.join(File.dirname(@remote_script), 'script-wrapper'), 555)
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
- exit $(cat #{@exit_code_path})
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
@@ -1,7 +1,7 @@
1
1
  module Proxy
2
2
  module RemoteExecution
3
3
  module Ssh
4
- VERSION = '0.10.1'
4
+ VERSION = '0.10.2'
5
5
  end
6
6
  end
7
7
  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], [:foreman_ssl_ca, :ssl_ca_file]].all? { |(client, server)| ::Proxy::SETTINGS[client] || ::Proxy::SETTINGS[server] }
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.1
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-01-18 00:00:00.000000000 Z
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: '1'
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: '1'
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.3.20
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: []