foreman_remote_execution 1.6.2 → 1.6.3
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/app/lib/actions/remote_execution/run_hosts_job.rb +2 -0
- data/app/lib/foreman_remote_execution/renderer/scope/input.rb +8 -0
- data/app/models/job_invocation.rb +2 -0
- data/app/models/remote_execution_feature.rb +7 -1
- data/lib/foreman_remote_execution/version.rb +1 -1
- data/test/unit/renderer_scope_input.rb +49 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f8f8c5208313baaca0c289321f6cc4c07c8d27d9f8d97c83e764d58a902f152
|
4
|
+
data.tar.gz: cf6df45271fa254133e0c15e1084f835984e857247b1b8980b61555db9b43ae2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c0ebcfd20e690e37e882e7a1d93be312989252d9b875977852e4587b7b3fe2232bc745f89f7d5d83bce1dc6c6480871ad4daae5d30b482d3f9b7fccf64089fd
|
7
|
+
data.tar.gz: 1fc408ceb6aebaddd2fb83fe91ceb9f7674ae3735bc2eb89c522903dc1f67175f348261557a95ae30d091dc409aa20cfc9a4133426b1f42913c2f6da165c3781
|
@@ -49,6 +49,8 @@ module Actions
|
|
49
49
|
job_invocation.password = job_invocation.key_passphrase = job_invocation.sudo_password = nil
|
50
50
|
job_invocation.save!
|
51
51
|
|
52
|
+
Rails.logger.debug "cleaning cache for keys that begin with 'job_invocation_#{job_invocation.id}'"
|
53
|
+
Rails.cache.delete_matched(/\A#{JobInvocation::CACHE_PREFIX}_#{job_invocation.id}/)
|
52
54
|
# creating the success notification should be the very last thing this tasks do
|
53
55
|
job_invocation.build_notification.deliver!
|
54
56
|
end
|
@@ -15,6 +15,14 @@ module ForemanRemoteExecution
|
|
15
15
|
!!@preview
|
16
16
|
end
|
17
17
|
|
18
|
+
def cached(key, &block)
|
19
|
+
return yield if preview?
|
20
|
+
|
21
|
+
cache_key = "#{JobInvocation::CACHE_PREFIX}_#{invocation.job_invocation_id}_#{key}"
|
22
|
+
Rails.logger.debug "cache hit for #{cache_key}" if Rails.cache.exist?(cache_key)
|
23
|
+
Rails.cache.fetch(cache_key, &block)
|
24
|
+
end
|
25
|
+
|
18
26
|
def render_template(template_name, input_values = {}, options = {})
|
19
27
|
options.assert_valid_keys(:with_foreign_input_set)
|
20
28
|
with_foreign_input_set = options.fetch(:with_foreign_input_set, true)
|
@@ -25,7 +25,13 @@ class RemoteExecutionFeature < ApplicationRecord
|
|
25
25
|
|
26
26
|
# rubocop:disable Metrics/PerceivedComplexity
|
27
27
|
def self.register(label, name, options = {})
|
28
|
-
|
28
|
+
begin
|
29
|
+
return false unless RemoteExecutionFeature.table_exists?
|
30
|
+
rescue ActiveRecord::NoDatabaseError => e
|
31
|
+
# just ignore the problem if DB does not exist yet (rake db:create call)
|
32
|
+
return false
|
33
|
+
end
|
34
|
+
|
29
35
|
options.assert_valid_keys(*VALID_OPTIONS)
|
30
36
|
options[:host_action_button] = false unless options.key?(:host_action_button)
|
31
37
|
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'test_plugin_helper'
|
2
|
+
|
3
|
+
class RendererScopeInputTest < ActiveSupport::TestCase
|
4
|
+
let(:source) { Foreman::Renderer::Source::String.new(content: '') }
|
5
|
+
|
6
|
+
describe 'caching helper in real mode' do
|
7
|
+
let(:input) do
|
8
|
+
input = ForemanRemoteExecution::Renderer::Scope::Input.new(source: source)
|
9
|
+
input.stubs(:invocation => OpenStruct.new(:job_invocation_id => 1))
|
10
|
+
input
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'caches the value under given key' do
|
14
|
+
i = 1
|
15
|
+
result = input.cached('some_key') { i }
|
16
|
+
result.must_equal 1
|
17
|
+
|
18
|
+
i += 1
|
19
|
+
result = input.cached('some_key') { i }
|
20
|
+
result.must_equal 1
|
21
|
+
|
22
|
+
i += 1
|
23
|
+
result = input.cached('different_key') { i }
|
24
|
+
result.must_equal 3
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe 'caching helper in preview mode' do
|
29
|
+
let(:input) do
|
30
|
+
input = ForemanRemoteExecution::Renderer::Scope::Input.new(source: source)
|
31
|
+
input.stubs(:invocation => OpenStruct.new(:job_invocation_id => 1), :preview? => true)
|
32
|
+
input
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'does not cache the value' do
|
36
|
+
i = 1
|
37
|
+
result = input.cached('some_key') { i }
|
38
|
+
result.must_equal 1
|
39
|
+
|
40
|
+
i += 1
|
41
|
+
result = input.cached('some_key') { i }
|
42
|
+
result.must_equal 2
|
43
|
+
|
44
|
+
i += 1
|
45
|
+
result = input.cached('different_key') { i }
|
46
|
+
result.must_equal 3
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_remote_execution
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Foreman Remote Execution team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-09-
|
11
|
+
date: 2018-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: deface
|
@@ -384,6 +384,7 @@ files:
|
|
384
384
|
- test/unit/job_template_test.rb
|
385
385
|
- test/unit/remote_execution_feature_test.rb
|
386
386
|
- test/unit/remote_execution_provider_test.rb
|
387
|
+
- test/unit/renderer_scope_input.rb
|
387
388
|
- test/unit/targeting_test.rb
|
388
389
|
- test/unit/template_input_test.rb
|
389
390
|
- test/unit/template_invocation_input_value_test.rb
|
@@ -449,6 +450,7 @@ test_files:
|
|
449
450
|
- test/unit/job_template_test.rb
|
450
451
|
- test/unit/remote_execution_feature_test.rb
|
451
452
|
- test/unit/remote_execution_provider_test.rb
|
453
|
+
- test/unit/renderer_scope_input.rb
|
452
454
|
- test/unit/targeting_test.rb
|
453
455
|
- test/unit/template_input_test.rb
|
454
456
|
- test/unit/template_invocation_input_value_test.rb
|