foreman_rh_cloud 7.0.46 → 7.0.47
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c5493c69d3f1918da42b12dfc523e6bf387203e1d1cdd057d6bea1e401caeef6
|
|
4
|
+
data.tar.gz: 7413d1788622b27285da6a7257928b57b79bb6de8660ca9f966edcbb4cc7ee00
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bf2220d31d2bc0b41291560ea0f25a8a88c33d73e281915ebe4534bf0a2fbd80be8f815776b38eade95366e92824179519decf91062f607a60c396e03a0387e2
|
|
7
|
+
data.tar.gz: 9d16b6f204bc3585e00b012e0fa47132ae4209fbaa85015c8db99ebce79aac167fa85374423366b2ff4ecd2cb725a20d7a5d52b61873f525b37ea7094e23fc7f
|
|
@@ -43,7 +43,17 @@ module InsightsCloud
|
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
def done?(current_status = invocation_status)
|
|
46
|
-
|
|
46
|
+
ActiveModel::Type::Boolean.new.cast(current_status[:task_state][:task_done_reported])
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def job_finished?
|
|
50
|
+
job_invocation.finished?
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def all_hosts_finished?(current_status)
|
|
54
|
+
current_status[:hosts_state].values.all? do |status|
|
|
55
|
+
ActiveModel::Type::Boolean.new.cast(status['report_done'] == true)
|
|
56
|
+
end
|
|
47
57
|
end
|
|
48
58
|
|
|
49
59
|
# noop, we don't want to do anything when the polling task starts
|
|
@@ -95,7 +105,11 @@ module InsightsCloud
|
|
|
95
105
|
end
|
|
96
106
|
|
|
97
107
|
def host_status(host)
|
|
98
|
-
external_task&.dig('invocation_status', host)
|
|
108
|
+
external_task&.dig('invocation_status', :hosts_state, host)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def task_done_state
|
|
112
|
+
ActiveModel::Type::Boolean.new.cast(external_task&.dig('invocation_status', :task_state, :task_done_reported))
|
|
99
113
|
end
|
|
100
114
|
|
|
101
115
|
def sequence(host)
|
|
@@ -111,13 +125,15 @@ module InsightsCloud
|
|
|
111
125
|
end
|
|
112
126
|
|
|
113
127
|
def invocation_status
|
|
114
|
-
Hash[job_invocation.targeting.hosts.map do |host|
|
|
128
|
+
hosts_state = Hash[job_invocation.targeting.hosts.map do |host|
|
|
115
129
|
next unless host.insights&.uuid
|
|
116
130
|
[
|
|
117
131
|
host.insights.uuid,
|
|
118
132
|
task_status(job_invocation.sub_task_for_host(host), host.insights.uuid),
|
|
119
133
|
]
|
|
120
134
|
end.compact]
|
|
135
|
+
|
|
136
|
+
{task_state: {task_done_reported: task_done_state}, hosts_state: hosts_state}
|
|
121
137
|
end
|
|
122
138
|
|
|
123
139
|
def task_status(host_task, host_name)
|
|
@@ -128,7 +144,7 @@ module InsightsCloud
|
|
|
128
144
|
{
|
|
129
145
|
'state' => host_task.state,
|
|
130
146
|
'output' => host_task.main_action.live_output.map { |line| line['output'] }.join("\n"),
|
|
131
|
-
'exit_status' => host_task.main_action.exit_status,
|
|
147
|
+
'exit_status' => ActiveModel::Type::Integer.new.cast(host_task.main_action.exit_status),
|
|
132
148
|
'sequence' => sequence(host_name),
|
|
133
149
|
'report_done' => host_done?(host_name),
|
|
134
150
|
}
|
|
@@ -138,9 +154,9 @@ module InsightsCloud
|
|
|
138
154
|
generator = InsightsCloud::Generators::PlaybookProgressGenerator.new(correlation_id)
|
|
139
155
|
all_hosts_success = true
|
|
140
156
|
|
|
141
|
-
invocation_status.each do |host_name, status|
|
|
157
|
+
invocation_status[:hosts_state].each do |host_name, status|
|
|
142
158
|
# skip host if the host already reported that it's finished
|
|
143
|
-
next if status['report_done']
|
|
159
|
+
next if ActiveModel::Type::Boolean.new.cast(status['report_done'])
|
|
144
160
|
|
|
145
161
|
unless status['state'] == 'unknown'
|
|
146
162
|
sequence = status['sequence']
|
|
@@ -154,7 +170,11 @@ module InsightsCloud
|
|
|
154
170
|
all_hosts_success &&= status['exit_status'] == 0
|
|
155
171
|
end
|
|
156
172
|
end
|
|
157
|
-
|
|
173
|
+
|
|
174
|
+
if (job_finished? || all_hosts_finished?(invocation_status))
|
|
175
|
+
generator.job_finished_message(all_hosts_success)
|
|
176
|
+
invocation_status[:task_state][:task_done_reported] = true
|
|
177
|
+
end
|
|
158
178
|
|
|
159
179
|
send_report(generator.generate)
|
|
160
180
|
end
|
data/package.json
CHANGED
|
@@ -29,7 +29,11 @@ class ConnectorPlaybookExecutionReporterTaskTest < ActiveSupport::TestCase
|
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
test 'It reports finish playbook messages' do
|
|
32
|
-
|
|
32
|
+
host1_task = @job_invocation.sub_task_for_host(Host.where(name: 'host1').first)
|
|
33
|
+
host1_task.state = 'stopped'
|
|
34
|
+
host1_task.save!
|
|
35
|
+
|
|
36
|
+
TestConnectorPlaybookExecutionReporterTask.any_instance.stubs(:job_finished?).returns(true)
|
|
33
37
|
|
|
34
38
|
actual = ForemanTasks.sync_task(TestConnectorPlaybookExecutionReporterTask, @job_invocation)
|
|
35
39
|
|
|
@@ -39,6 +43,13 @@ class ConnectorPlaybookExecutionReporterTaskTest < ActiveSupport::TestCase
|
|
|
39
43
|
assert_not_nil actual_report
|
|
40
44
|
actual_jsonl = read_jsonl(actual_report)
|
|
41
45
|
|
|
46
|
+
assert_equal true, actual.output['task']['invocation_status']['task_state']['task_done_reported']
|
|
47
|
+
assert_equal 0, actual.output['task']['invocation_status']['hosts_state']['TEST_UUID1']['exit_status']
|
|
48
|
+
assert_equal 0, actual.output['task']['invocation_status']['hosts_state']['TEST_UUID2']['exit_status']
|
|
49
|
+
|
|
50
|
+
assert_equal true, @job_invocation.finished?
|
|
51
|
+
assert_equal 'stopped', @job_invocation.sub_task_for_host(Host.where(name: 'host1').first)['state']
|
|
52
|
+
|
|
42
53
|
assert_not_nil actual_report_finished = actual_jsonl.find { |l| l['type'] == 'playbook_run_completed' }
|
|
43
54
|
assert_equal 'TEST_CORRELATION', actual_report_finished['correlation_id']
|
|
44
55
|
assert_equal 'success', actual_report_finished['status']
|
|
@@ -49,57 +60,127 @@ class ConnectorPlaybookExecutionReporterTaskTest < ActiveSupport::TestCase
|
|
|
49
60
|
end
|
|
50
61
|
|
|
51
62
|
test 'It reports single progress message for done host' do
|
|
52
|
-
|
|
63
|
+
class ArrangeTestHost < InsightsCloud::Async::ConnectorPlaybookExecutionReporterTask
|
|
64
|
+
def send_report(report)
|
|
65
|
+
host1_task = @job_invocation.sub_task_for_host(Host.where(name: 'host1').first)
|
|
66
|
+
host1_task.state = 'stopped'
|
|
67
|
+
host1_task.save!
|
|
68
|
+
|
|
69
|
+
output[:saved_reports] = (output[:saved_reports] || []) << report
|
|
70
|
+
end
|
|
71
|
+
end
|
|
53
72
|
|
|
54
|
-
|
|
73
|
+
ArrangeTestHost.instance_variable_set(:@connector_feature_id, nil)
|
|
74
|
+
host1_task = @job_invocation.sub_task_for_host(Host.where(name: 'host1').first)
|
|
75
|
+
host1_task.state = 'running'
|
|
76
|
+
host1_task.save!
|
|
55
77
|
|
|
56
|
-
|
|
78
|
+
ArrangeTestHost.any_instance.stubs(:job_finished?).returns(false, true)
|
|
57
79
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
80
|
+
actual = ForemanTasks.sync_task(ArrangeTestHost, @job_invocation)
|
|
81
|
+
|
|
82
|
+
actual_report1 = actual.output[:saved_reports].first.to_s
|
|
83
|
+
actual_report2 = actual.output[:saved_reports].second.to_s
|
|
84
|
+
|
|
85
|
+
assert_equal 2, actual.output[:saved_reports].size
|
|
86
|
+
assert_not_nil actual_report1
|
|
87
|
+
assert_not_nil actual_report2
|
|
88
|
+
|
|
89
|
+
actual_json1 = read_jsonl(actual_report1)
|
|
90
|
+
actual_json2 = read_jsonl(actual_report2)
|
|
91
|
+
|
|
92
|
+
assert_equal true, actual.output['task']['invocation_status']['task_state']['task_done_reported']
|
|
93
|
+
assert_equal 0, actual.output['task']['invocation_status']['hosts_state']['TEST_UUID1']['exit_status']
|
|
61
94
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
assert_equal
|
|
95
|
+
assert_equal 'stopped', @job_invocation.sub_task_for_host(Host.where(name: 'host1').first)['state']
|
|
96
|
+
|
|
97
|
+
assert_not_nil actual_report_updated = actual_json1.find { |l| l['type'] == 'playbook_run_update' && l['host'] == 'TEST_UUID1' }
|
|
98
|
+
assert_equal 'TEST_CORRELATION', actual_report_updated['correlation_id']
|
|
99
|
+
assert_equal 'TEST_UUID1', actual_report_updated['host']
|
|
100
|
+
assert_equal 0, actual_report_updated['sequence']
|
|
101
|
+
assert_equal 6, actual_report_updated.size
|
|
102
|
+
|
|
103
|
+
assert_not_nil actual_report_updated = actual_json2.find { |l| l['type'] == 'playbook_run_update' && l['host'] == 'TEST_UUID1' }
|
|
104
|
+
assert_equal 'TEST_CORRELATION', actual_report_updated['correlation_id']
|
|
105
|
+
assert_equal 'TEST_UUID1', actual_report_updated['host']
|
|
106
|
+
assert_equal 1, actual_report_updated['sequence']
|
|
107
|
+
assert_equal 6, actual_report_updated.size
|
|
108
|
+
|
|
109
|
+
assert_not_nil actual_host_finished = actual_json2.find { |l| l['type'] == 'playbook_run_finished' && l['host'] == 'TEST_UUID1' }
|
|
110
|
+
assert_equal 'TEST_CORRELATION', actual_host_finished['correlation_id']
|
|
111
|
+
assert_equal 'TEST_UUID1', actual_host_finished['host']
|
|
112
|
+
assert_equal 'success', actual_host_finished['status']
|
|
113
|
+
assert_equal 7, actual_host_finished.size
|
|
114
|
+
|
|
115
|
+
assert_not_nil actual_report_finished = actual_json2.find { |l| l['type'] == 'playbook_run_completed' }
|
|
116
|
+
assert_equal 'TEST_CORRELATION', actual_report_finished['correlation_id']
|
|
117
|
+
assert_equal 'success', actual_report_finished['status']
|
|
118
|
+
assert_equal 4, actual_report_finished.size
|
|
66
119
|
end
|
|
67
120
|
|
|
68
121
|
test 'It reports two progress messages for in progress host' do
|
|
69
|
-
|
|
122
|
+
class ArrangeTestHostTwo < InsightsCloud::Async::ConnectorPlaybookExecutionReporterTask
|
|
123
|
+
def send_report(report)
|
|
124
|
+
iteration_number = output[:iteration_number].to_i
|
|
125
|
+
|
|
126
|
+
if iteration_number == 1
|
|
127
|
+
host1_task = job_invocation.sub_task_for_host(Host.where(name: 'host1').first)
|
|
128
|
+
host1_task.state = 'stopped'
|
|
129
|
+
host1_task.save!
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
output[:iteration_number] = iteration_number + 1
|
|
133
|
+
output[:saved_reports] = (output[:saved_reports] || []) << report
|
|
134
|
+
end
|
|
135
|
+
end
|
|
70
136
|
|
|
71
|
-
|
|
137
|
+
ArrangeTestHostTwo.instance_variable_set(:@connector_feature_id, nil)
|
|
138
|
+
host1_task = @job_invocation.sub_task_for_host(Host.where(name: 'host1').first)
|
|
72
139
|
host1_task.state = 'running'
|
|
73
140
|
host1_task.save!
|
|
74
141
|
|
|
75
|
-
|
|
142
|
+
ArrangeTestHostTwo.any_instance.stubs(:job_finished?).returns(false, false, true)
|
|
76
143
|
|
|
77
|
-
|
|
144
|
+
actual = ForemanTasks.sync_task(ArrangeTestHostTwo, @job_invocation)
|
|
145
|
+
|
|
146
|
+
actual_report1 = actual.output[:saved_reports].first.to_s
|
|
147
|
+
actual_report2 = actual.output[:saved_reports].second.to_s
|
|
148
|
+
actual_report3 = actual.output[:saved_reports].third.to_s
|
|
149
|
+
|
|
150
|
+
assert_equal 3, actual.output[:saved_reports].size
|
|
151
|
+
assert_not_nil actual_report1
|
|
152
|
+
assert_not_nil actual_report2
|
|
153
|
+
assert_not_nil actual_report3
|
|
78
154
|
|
|
79
|
-
|
|
80
|
-
|
|
155
|
+
actual_json1 = read_jsonl(actual_report1)
|
|
156
|
+
actual_json2 = read_jsonl(actual_report2)
|
|
157
|
+
actual_json3 = read_jsonl(actual_report3)
|
|
81
158
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
assert_equal 1, actual_host_updates.size
|
|
85
|
-
assert_equal 0, actual_host_updates.first['sequence']
|
|
159
|
+
assert_equal true, actual.output['task']['invocation_status']['task_state']['task_done_reported']
|
|
160
|
+
assert_equal 0, actual.output['task']['invocation_status']['hosts_state']['TEST_UUID1']['exit_status']
|
|
86
161
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
assert_equal
|
|
90
|
-
assert_equal 0,
|
|
162
|
+
assert_not_nil actual_report_updated = actual_json1.find { |l| l['type'] == 'playbook_run_update' && l['host'] == 'TEST_UUID1' }
|
|
163
|
+
assert_equal 'TEST_CORRELATION', actual_report_updated['correlation_id']
|
|
164
|
+
assert_equal 'TEST_UUID1', actual_report_updated['host']
|
|
165
|
+
assert_equal 0, actual_report_updated['sequence']
|
|
166
|
+
assert_equal 6, actual_report_updated.size
|
|
91
167
|
|
|
92
|
-
|
|
93
|
-
|
|
168
|
+
assert_not_nil actual_report_updated = actual_json2.find { |l| l['type'] == 'playbook_run_update' && l['host'] == 'TEST_UUID1' }
|
|
169
|
+
assert_equal 'TEST_CORRELATION', actual_report_updated['correlation_id']
|
|
170
|
+
assert_equal 'TEST_UUID1', actual_report_updated['host']
|
|
171
|
+
assert_equal 1, actual_report_updated['sequence']
|
|
172
|
+
assert_equal 6, actual_report_updated.size
|
|
94
173
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
assert_equal
|
|
98
|
-
assert_equal
|
|
174
|
+
assert_not_nil actual_host_finished = actual_json3.find { |l| l['type'] == 'playbook_run_finished' && l['host'] == 'TEST_UUID1' }
|
|
175
|
+
assert_equal 'TEST_CORRELATION', actual_host_finished['correlation_id']
|
|
176
|
+
assert_equal 'TEST_UUID1', actual_host_finished['host']
|
|
177
|
+
assert_equal 'success', actual_host_finished['status']
|
|
178
|
+
assert_equal 7, actual_host_finished.size
|
|
99
179
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
assert_equal
|
|
180
|
+
assert_not_nil actual_report_finished = actual_json3.find { |l| l['type'] == 'playbook_run_completed' }
|
|
181
|
+
assert_equal 'TEST_CORRELATION', actual_report_finished['correlation_id']
|
|
182
|
+
assert_equal 'success', actual_report_finished['status']
|
|
183
|
+
assert_equal 4, actual_report_finished.size
|
|
103
184
|
end
|
|
104
185
|
|
|
105
186
|
private
|
|
@@ -164,10 +245,12 @@ class ConnectorPlaybookExecutionReporterTaskTest < ActiveSupport::TestCase
|
|
|
164
245
|
:value => '1'
|
|
165
246
|
)
|
|
166
247
|
|
|
167
|
-
@host1 = FactoryBot.create(:host, :with_insights_hits
|
|
248
|
+
@host1 = FactoryBot.create(:host, :with_insights_hits)
|
|
249
|
+
@host1.name = 'host1' # overriding name since there is an issue with Factorybot and setting the name correctly, same for 2nd host
|
|
168
250
|
@host1.insights.uuid = 'TEST_UUID1'
|
|
169
251
|
@host1.insights.save!
|
|
170
|
-
@host2 = FactoryBot.create(:host, :with_insights_hits
|
|
252
|
+
@host2 = FactoryBot.create(:host, :with_insights_hits)
|
|
253
|
+
@host2.name = 'host2'
|
|
171
254
|
@host2.insights.uuid = 'TEST_UUID2'
|
|
172
255
|
@host2.insights.save!
|
|
173
256
|
|
|
@@ -190,7 +273,7 @@ class ConnectorPlaybookExecutionReporterTaskTest < ActiveSupport::TestCase
|
|
|
190
273
|
{ 'timestamp' => (Time.now - (5 - i)).to_f, 'output' => "#{i}\n" }
|
|
191
274
|
end
|
|
192
275
|
Support::DummyDynflowAction.any_instance.stubs(:live_output).returns(fake_output)
|
|
193
|
-
Support::DummyDynflowAction.any_instance.stubs(:exit_status).returns(0)
|
|
276
|
+
Support::DummyDynflowAction.any_instance.stubs(:exit_status).returns("0")
|
|
194
277
|
|
|
195
278
|
job_invocation
|
|
196
279
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: foreman_rh_cloud
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 7.0.
|
|
4
|
+
version: 7.0.47
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Foreman Red Hat Cloud team
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2023-
|
|
11
|
+
date: 2023-09-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: katello
|
|
@@ -650,7 +650,7 @@ homepage: https://github.com/theforeman/foreman_rh_cloud
|
|
|
650
650
|
licenses:
|
|
651
651
|
- GPL-3.0
|
|
652
652
|
metadata: {}
|
|
653
|
-
post_install_message:
|
|
653
|
+
post_install_message:
|
|
654
654
|
rdoc_options: []
|
|
655
655
|
require_paths:
|
|
656
656
|
- lib
|
|
@@ -665,8 +665,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
665
665
|
- !ruby/object:Gem::Version
|
|
666
666
|
version: '0'
|
|
667
667
|
requirements: []
|
|
668
|
-
rubygems_version: 3.3.
|
|
669
|
-
signing_key:
|
|
668
|
+
rubygems_version: 3.3.5
|
|
669
|
+
signing_key:
|
|
670
670
|
specification_version: 4
|
|
671
671
|
summary: Summary of ForemanRhCloud.
|
|
672
672
|
test_files:
|