foreman_remote_execution 8.1.0 → 8.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/lib/actions/remote_execution/proxy_action.rb +7 -3
- data/app/lib/actions/remote_execution/run_host_job.rb +1 -1
- data/db/migrate/20221129170145_redefine_template_invocation_events_index.rb +36 -0
- data/lib/foreman_remote_execution/engine.rb +1 -1
- data/lib/foreman_remote_execution/version.rb +1 -1
- data/webpack/JobWizard/JobWizard.js +2 -1
- data/webpack/JobWizard/JobWizard.scss +1 -4
- data/webpack/JobWizard/steps/Schedule/ScheduleRecurring.js +3 -3
- data/webpack/JobWizard/submit.js +3 -2
- data/webpack/react_app/components/FeaturesDropdown/actions.js +4 -6
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13f80e6dffc1166fb7f5e423ea6543b6d89a5f8f45930c29073bf28e232bde0b
|
4
|
+
data.tar.gz: 0f489c08c07a1eb217feec2d1b9325f3e5c9ce248becbaf68562471aac889cd0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88032e02e3375cb7d19992efaad18932e7eef3948e8822dc8ad573a790ce4077273012f861b49a8351cda44f4b272b84ef0bc8e8a7124a2d2a71c759026a1d87
|
7
|
+
data.tar.gz: 8d0aec0264bdae9ba1530940088daeef369546a2ad9102d7d4eb1b7527f2cd1402d37915d4e9f659d845706938cd0dc7fc8299d1559c21b17cd404cdf91a22df
|
@@ -21,8 +21,11 @@ module Actions
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def process_proxy_data(data)
|
24
|
-
events = data['result'].map do |update|
|
24
|
+
events = data['result'].each_with_index.map do |update, seq_id|
|
25
25
|
{
|
26
|
+
# For N-1 compatibility, we assume that the output provided here is
|
27
|
+
# complete
|
28
|
+
sequence_id: update['sequence_id'] || seq_id,
|
26
29
|
template_invocation_id: template_invocation.id,
|
27
30
|
event: update['output'],
|
28
31
|
timestamp: Time.at(update['timestamp']).getlocal,
|
@@ -31,14 +34,15 @@ module Actions
|
|
31
34
|
end
|
32
35
|
if data['exit_status']
|
33
36
|
events << {
|
37
|
+
sequence_id: events.last[:sequence_id] + 1,
|
34
38
|
template_invocation_id: template_invocation.id,
|
35
39
|
event: data['exit_status'],
|
36
|
-
timestamp: events.last[:timestamp]
|
40
|
+
timestamp: events.last[:timestamp],
|
37
41
|
event_type: 'exit',
|
38
42
|
}
|
39
43
|
end
|
40
44
|
events.each_slice(1000) do |batch|
|
41
|
-
TemplateInvocationEvent.upsert_all(batch, unique_by: [:template_invocation_id, :
|
45
|
+
TemplateInvocationEvent.upsert_all(batch, unique_by: [:template_invocation_id, :sequence_id]) # rubocop:disable Rails/SkipsModelValidations
|
42
46
|
end
|
43
47
|
end
|
44
48
|
end
|
@@ -169,7 +169,7 @@ module Actions
|
|
169
169
|
# This is enough, the error will get shown using add_exception at the end of the method
|
170
170
|
end
|
171
171
|
|
172
|
-
task.template_invocation.template_invocation_events.find_each do |output|
|
172
|
+
task.template_invocation.template_invocation_events.order(:sequence_id).find_each do |output|
|
173
173
|
if output.event_type == 'exit'
|
174
174
|
continuous_output.add_output(_('Exit status: %s') % output.event, 'stdout', output.timestamp)
|
175
175
|
else
|
@@ -0,0 +1,36 @@
|
|
1
|
+
class RedefineTemplateInvocationEventsIndex < ActiveRecord::Migration[6.0]
|
2
|
+
def up
|
3
|
+
change_table :template_invocation_events do |t|
|
4
|
+
t.remove_index name: :unique_template_invocation_events_index
|
5
|
+
t.integer :sequence_id
|
6
|
+
end
|
7
|
+
|
8
|
+
execute <<~SQL
|
9
|
+
WITH extended_t AS
|
10
|
+
(
|
11
|
+
SELECT id, row_number() over (PARTITION BY template_invocation_id ORDER BY timestamp ASC) AS rn
|
12
|
+
FROM template_invocation_events
|
13
|
+
)
|
14
|
+
UPDATE template_invocation_events SET sequence_id = extended_t.rn
|
15
|
+
FROM extended_t
|
16
|
+
WHERE template_invocation_events.id = extended_t.id;
|
17
|
+
SQL
|
18
|
+
|
19
|
+
change_table :template_invocation_events do |t|
|
20
|
+
t.index [:template_invocation_id, :sequence_id],
|
21
|
+
unique: true,
|
22
|
+
name: 'unique_template_invocation_events_index'
|
23
|
+
t.change :sequence_id, :integer, null: false
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def down
|
28
|
+
change_table :template_invocation_events do |t|
|
29
|
+
t.remove_index name: :unique_template_invocation_events_index
|
30
|
+
t.remove :sequence_id
|
31
|
+
t.index [:template_invocation_id, :timestamp, :event_type],
|
32
|
+
unique: true,
|
33
|
+
name: 'unique_template_invocation_events_index'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -79,7 +79,7 @@ module ForemanRemoteExecution
|
|
79
79
|
type: :string,
|
80
80
|
description: N_('Default user to use for executing the script. If the user differs from the SSH user, su or sudo is used to switch the user.'),
|
81
81
|
default: 'root',
|
82
|
-
full_name: N_('
|
82
|
+
full_name: N_('Effective User')
|
83
83
|
setting 'remote_execution_effective_user_method',
|
84
84
|
type: :string,
|
85
85
|
description: N_('What command should be used to switch to the effective user. One of %s') % SSHExecutionProvider::EFFECTIVE_USER_METHODS.inspect,
|
@@ -48,7 +48,7 @@ export const JobWizard = ({ rerunData }) => {
|
|
48
48
|
rerunData?.job_category || jobCategoriesResponse?.default_category || ''
|
49
49
|
);
|
50
50
|
const [advancedValues, setAdvancedValues] = useState({ templateValues: {} });
|
51
|
-
const [templateValues, setTemplateValues] = useState({});
|
51
|
+
const [templateValues, setTemplateValues] = useState({});
|
52
52
|
const [scheduleValue, setScheduleValue] = useState(initialScheduleState);
|
53
53
|
const [selectedTargets, setSelectedTargets] = useState({
|
54
54
|
hosts: [],
|
@@ -378,6 +378,7 @@ export const JobWizard = ({ rerunData }) => {
|
|
378
378
|
hostsSearchQuery,
|
379
379
|
location,
|
380
380
|
organization,
|
381
|
+
feature: routerSearch?.feature,
|
381
382
|
});
|
382
383
|
}}
|
383
384
|
/>
|
@@ -57,9 +57,6 @@
|
|
57
57
|
margin: 0;
|
58
58
|
}
|
59
59
|
.schedule-tab {
|
60
|
-
.advanced-scheduling-button {
|
61
|
-
text-align: start;
|
62
|
-
}
|
63
60
|
#repeat-on-weekly {
|
64
61
|
display: grid;
|
65
62
|
grid-template-columns: repeat(7, 1fr);
|
@@ -92,7 +89,7 @@
|
|
92
89
|
display: inline-block;
|
93
90
|
align-self: center;
|
94
91
|
}
|
95
|
-
.
|
92
|
+
.schedule-radio-wrapper {
|
96
93
|
display: flex;
|
97
94
|
}
|
98
95
|
}
|
@@ -117,7 +117,7 @@ export const ScheduleRecurring = ({
|
|
117
117
|
id="start-at"
|
118
118
|
className="schedule-radio"
|
119
119
|
label={
|
120
|
-
<div className="
|
120
|
+
<div className="schedule-radio-wrapper">
|
121
121
|
<div className="schedule-radio-title">{__('At')}</div>
|
122
122
|
<DateTimePicker
|
123
123
|
ariaLabel="starts at"
|
@@ -197,7 +197,7 @@ export const ScheduleRecurring = ({
|
|
197
197
|
id="ends-on"
|
198
198
|
className="schedule-radio"
|
199
199
|
label={
|
200
|
-
<div className="
|
200
|
+
<div className="schedule-radio-wrapper">
|
201
201
|
<div className="schedule-radio-title">{__('On')}</div>
|
202
202
|
<DateTimePicker
|
203
203
|
ariaLabel="ends on"
|
@@ -229,7 +229,7 @@ export const ScheduleRecurring = ({
|
|
229
229
|
id="ends-after"
|
230
230
|
className="schedule-radio"
|
231
231
|
label={
|
232
|
-
<div className="
|
232
|
+
<div className="schedule-radio-wrapper">
|
233
233
|
<div className="schedule-radio-title">{__('After')}</div>
|
234
234
|
<FormGroup
|
235
235
|
helperTextInvalid={__(
|
data/webpack/JobWizard/submit.js
CHANGED
@@ -11,6 +11,7 @@ export const submit = ({
|
|
11
11
|
hostsSearchQuery,
|
12
12
|
location,
|
13
13
|
organization,
|
14
|
+
feature,
|
14
15
|
dispatch,
|
15
16
|
}) => {
|
16
17
|
const {
|
@@ -65,7 +66,7 @@ export const submit = ({
|
|
65
66
|
location,
|
66
67
|
organization,
|
67
68
|
job_invocation: {
|
68
|
-
job_template_id: jobTemplateID,
|
69
|
+
job_template_id: feature ? null : jobTemplateID,
|
69
70
|
targeting_type: scheduleValue?.isTypeStatic
|
70
71
|
? 'static_query'
|
71
72
|
: 'dynamic_query',
|
@@ -107,7 +108,7 @@ export const submit = ({
|
|
107
108
|
buildHostQuery(selectedTargets, hostsSearchQuery) || 'name ~ *',
|
108
109
|
description_format: description,
|
109
110
|
execution_timeout_interval: timeoutToKill,
|
110
|
-
feature
|
111
|
+
feature,
|
111
112
|
time_to_pickup: timeToPickup,
|
112
113
|
},
|
113
114
|
};
|
@@ -6,9 +6,10 @@ export const runFeature = (hostId, feature, label) => dispatch => {
|
|
6
6
|
const url = foremanUrl(
|
7
7
|
`/job_invocations?feature=${feature}&host_ids%5B%5D=${hostId}`
|
8
8
|
);
|
9
|
+
const redirectUrl = 'job_invocations/new';
|
9
10
|
|
10
11
|
const successToast = ({ request }) => {
|
11
|
-
if (request.responseURL.includes(
|
12
|
+
if (request.responseURL.includes(redirectUrl)) {
|
12
13
|
return __('Opening job invocation form');
|
13
14
|
}
|
14
15
|
return sprintf(__('%s job has been invoked'), label);
|
@@ -21,12 +22,9 @@ export const runFeature = (hostId, feature, label) => dispatch => {
|
|
21
22
|
successToast,
|
22
23
|
errorToast,
|
23
24
|
handleSuccess: ({ request }) => {
|
24
|
-
if (request.responseURL.includes(
|
25
|
+
if (request.responseURL.includes(redirectUrl)) {
|
25
26
|
// checking if user should be redicted to finish setting up the job
|
26
|
-
window.location.href = request.responseURL
|
27
|
-
'job_invocations?',
|
28
|
-
'job_invocations/new?'
|
29
|
-
);
|
27
|
+
window.location.href = request.responseURL;
|
30
28
|
}
|
31
29
|
},
|
32
30
|
})
|
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: 8.1.
|
4
|
+
version: 8.1.1
|
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: 2022-
|
11
|
+
date: 2022-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: deface
|
@@ -329,6 +329,7 @@ files:
|
|
329
329
|
- db/migrate/20220331112719_add_ssh_user_to_job_invocation.rb
|
330
330
|
- db/migrate/20220713095705_create_template_invocation_events.rb
|
331
331
|
- db/migrate/20220822155946_add_time_to_pickup_to_job_invocation.rb
|
332
|
+
- db/migrate/20221129170145_redefine_template_invocation_events_index.rb
|
332
333
|
- db/seeds.d/100-assign_features_with_templates.rb
|
333
334
|
- db/seeds.d/20-permissions.rb
|
334
335
|
- db/seeds.d/50-notification_blueprints.rb
|