foreman_maintain 0.8.25 → 0.8.28
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/definitions/procedures/content/prepare.rb +1 -0
- data/definitions/procedures/content/switchover.rb +1 -0
- data/definitions/procedures/installer/upgrade_rake_task.rb +3 -1
- data/definitions/procedures/pulp/remove.rb +49 -13
- data/definitions/scenarios/restore.rb +2 -0
- data/definitions/scenarios/self_upgrade.rb +9 -2
- data/lib/foreman_maintain/cli/self_upgrade_command.rb +9 -24
- data/lib/foreman_maintain/concerns/metadata.rb +4 -0
- data/lib/foreman_maintain/reporter/cli_reporter.rb +24 -6
- data/lib/foreman_maintain/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d3f74a8e04cc3255a259318a450eb62e66e4b6042b0fc6f6d0111d91b2e388e
|
4
|
+
data.tar.gz: 6a49ed3303ae84908a4e8ab909dfc048e39464509a0520071a67a74cc2cdbf65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f9167f69ef8e06fe6d414586bf430fb678f37095ae6861db536367e433a3410deed6550bc909a15ba29a6858493b40dbae828b81794f70a7b80c660f4cfd662
|
7
|
+
data.tar.gz: 6ef3022587a94320094ad3938599638848d56b944de7b1923dde9f70cc6ff0d3d117ea91828480d106af822fa429eea9269dcc5a76a21e2a05a16239818022e0
|
@@ -5,7 +5,9 @@ module Procedures::Installer
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def run
|
8
|
-
|
8
|
+
# only run this in the Satellite scenario, as in others
|
9
|
+
# the installer runs this rake task for us already
|
10
|
+
execute!('foreman-rake upgrade:run') if feature(:satellite)
|
9
11
|
end
|
10
12
|
end
|
11
13
|
end
|
@@ -23,7 +23,15 @@ module Procedures::Pulp
|
|
23
23
|
'/var/lib/pulp/uploads',
|
24
24
|
'/var/lib/mongodb/',
|
25
25
|
'/var/cache/pulp'
|
26
|
-
]
|
26
|
+
].select { |dir| File.directory?(dir) }
|
27
|
+
end
|
28
|
+
|
29
|
+
def pulp_data_dirs_mountpoints
|
30
|
+
pulp_data_dirs.select { |d| Pathname(d).mountpoint? }
|
31
|
+
end
|
32
|
+
|
33
|
+
def deletable_pulp_dirs
|
34
|
+
@deletable_pulp_dirs ||= pulp_data_dirs - pulp_data_dirs_mountpoints
|
27
35
|
end
|
28
36
|
|
29
37
|
# rubocop:disable Metrics/MethodLength
|
@@ -52,11 +60,12 @@ module Procedures::Pulp
|
|
52
60
|
@installed_pulp_packages
|
53
61
|
end
|
54
62
|
|
55
|
-
def data_dir_removal_cmds
|
56
|
-
|
63
|
+
def data_dir_removal_cmds(pulp_dirs)
|
64
|
+
pulp_dirs.map { |dir| "rm -rf #{dir}" }
|
57
65
|
end
|
58
66
|
|
59
|
-
def ask_to_proceed
|
67
|
+
def ask_to_proceed
|
68
|
+
rm_cmds = data_dir_removal_cmds(pulp_data_dirs)
|
60
69
|
question = "\nWARNING: All pulp2 packages will be removed with the following commands:\n"
|
61
70
|
question += "\n# rpm -e #{pulp_packages.join(' ')}" if pulp_packages.any?
|
62
71
|
question += "\n# yum remove rh-mongodb34-*"
|
@@ -69,11 +78,9 @@ module Procedures::Pulp
|
|
69
78
|
end
|
70
79
|
|
71
80
|
def run
|
72
|
-
rm_cmds = data_dir_removal_cmds
|
73
|
-
|
74
81
|
assumeyes_val = @assumeyes.nil? ? assumeyes? : @assumeyes
|
75
82
|
|
76
|
-
ask_to_proceed
|
83
|
+
ask_to_proceed unless assumeyes_val
|
77
84
|
|
78
85
|
remove_pulp if pulp_packages.any?
|
79
86
|
|
@@ -85,7 +92,7 @@ module Procedures::Pulp
|
|
85
92
|
|
86
93
|
drop_migrations
|
87
94
|
|
88
|
-
delete_pulp_data
|
95
|
+
delete_pulp_data
|
89
96
|
|
90
97
|
restart_pulpcore_services
|
91
98
|
end
|
@@ -162,12 +169,41 @@ module Procedures::Pulp
|
|
162
169
|
end
|
163
170
|
# rubocop:enable Metrics/BlockLength
|
164
171
|
|
165
|
-
def delete_pulp_data
|
166
|
-
|
167
|
-
|
168
|
-
|
172
|
+
def delete_pulp_data
|
173
|
+
non_mountpoints = data_dir_removal_cmds(deletable_pulp_dirs)
|
174
|
+
mountpoints = pulp_data_dirs_mountpoints
|
175
|
+
with_spinner('') do |spinner|
|
176
|
+
if non_mountpoints.any?
|
177
|
+
spinner.update('Deleting pulp2 data directories.')
|
178
|
+
non_mountpoints.each do |cmd|
|
179
|
+
execute!(cmd)
|
180
|
+
end
|
181
|
+
msg_for_del_non_mountpoints(mountpoints, spinner)
|
182
|
+
end
|
183
|
+
if mountpoints.any?
|
184
|
+
msg_for_del_mountpoints(mountpoints, spinner)
|
169
185
|
end
|
170
|
-
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
def msg_for_del_non_mountpoints(mountpoints, spinner)
|
190
|
+
if mountpoints.empty?
|
191
|
+
spinner.update('Done deleting all pulp2 data directories.')
|
192
|
+
else
|
193
|
+
spinner.update("Deleted: #{deletable_pulp_dirs.join("\n")}")
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
def msg_for_del_mountpoints(mountpoints, spinner)
|
198
|
+
_, cmd_name = ForemanMaintain.pkg_and_cmd_name
|
199
|
+
if mountpoints.count > 1
|
200
|
+
spinner.update("The directories #{mountpoints.join(',')} are individual mountpoints.")
|
201
|
+
puts "\nThe #{cmd_name} won't delete these directories.\n"\
|
202
|
+
'You need to remove content and these directories on your own.'
|
203
|
+
else
|
204
|
+
spinner.update("The directory #{mountpoints.join(',')} is individual mountpoint.")
|
205
|
+
puts "\nThe #{cmd_name} won't delete the directory.\n"\
|
206
|
+
'You need to remove content and the directory on your own.'
|
171
207
|
end
|
172
208
|
end
|
173
209
|
|
@@ -42,6 +42,8 @@ module ForemanMaintain::Scenarios
|
|
42
42
|
add_steps_with_context(Procedures::Restore::RegenerateQueues) if backup.online_backup?
|
43
43
|
add_steps_with_context(Procedures::Service::Start,
|
44
44
|
Procedures::Service::DaemonReload)
|
45
|
+
add_step(Procedures::Installer::Upgrade.new(:assumeyes => true))
|
46
|
+
add_step_with_context(Procedures::Installer::UpgradeRakeTask)
|
45
47
|
add_step_with_context(Procedures::Crond::Start) if feature(:cron)
|
46
48
|
end
|
47
49
|
# rubocop:enable Metrics/MethodLength,Metrics/AbcSize
|
@@ -13,15 +13,22 @@ module ForemanMaintain::Scenarios
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def target_version
|
16
|
-
|
16
|
+
current_full_version = feature(:instance).downstream.current_version
|
17
|
+
@target_version ||= current_full_version.bump
|
17
18
|
end
|
18
19
|
|
19
20
|
def current_version
|
20
21
|
feature(:instance).downstream.current_minor_version
|
21
22
|
end
|
22
23
|
|
24
|
+
def maintenance_repo_label
|
25
|
+
@maintenance_repo_label ||= context.get(:maintenance_repo_label)
|
26
|
+
end
|
27
|
+
|
23
28
|
def maintenance_repo_id(version)
|
24
|
-
if
|
29
|
+
if maintenance_repo_label
|
30
|
+
return maintenance_repo_label
|
31
|
+
elsif (repo = ENV['MAINTENANCE_REPO_LABEL'])
|
25
32
|
return repo unless repo.empty?
|
26
33
|
end
|
27
34
|
|
@@ -1,38 +1,23 @@
|
|
1
1
|
module ForemanMaintain
|
2
2
|
module Cli
|
3
3
|
class SelfUpgradeCommand < Base
|
4
|
-
option ['--
|
5
|
-
'
|
6
|
-
|
4
|
+
option ['--maintenance-repo-label'], 'REPOSITORY_LABEL',\
|
5
|
+
'Repository label from which packages should be updated.'\
|
6
|
+
'This can be used when standard CDN repositories are unavailable.'
|
7
7
|
def execute
|
8
|
-
allow_major_version_upgrade_only
|
9
8
|
run_scenario(upgrade_scenario, upgrade_rescue_scenario)
|
10
9
|
end
|
11
10
|
|
12
11
|
def upgrade_scenario
|
13
|
-
Scenarios::SelfUpgrade.new(
|
12
|
+
Scenarios::SelfUpgrade.new(
|
13
|
+
maintenance_repo_label: maintenance_repo_label
|
14
|
+
)
|
14
15
|
end
|
15
16
|
|
16
17
|
def upgrade_rescue_scenario
|
17
|
-
Scenarios::SelfUpgradeRescue.new(
|
18
|
-
|
19
|
-
|
20
|
-
def current_downstream_version
|
21
|
-
ForemanMaintain.detector.feature(:instance).downstream.current_version
|
22
|
-
end
|
23
|
-
|
24
|
-
def allow_major_version_upgrade_only
|
25
|
-
begin
|
26
|
-
next_version = Gem::Version.new(target_version)
|
27
|
-
rescue ArgumentError => err
|
28
|
-
raise Error::UsageError, "Invalid version! #{err}"
|
29
|
-
end
|
30
|
-
if current_downstream_version >= next_version
|
31
|
-
message = "The target-version #{target_version} should be "\
|
32
|
-
"greater than existing version #{current_downstream_version},"\
|
33
|
-
"\nand self-upgrade should be used for major version upgrades only!"
|
34
|
-
raise Error::UsageError, message
|
35
|
-
end
|
18
|
+
Scenarios::SelfUpgradeRescue.new(
|
19
|
+
maintenance_repo_label: maintenance_repo_label
|
20
|
+
)
|
36
21
|
end
|
37
22
|
end
|
38
23
|
end
|
@@ -100,6 +100,10 @@ module ForemanMaintain
|
|
100
100
|
@data[:advanced_run] = advanced_run
|
101
101
|
end
|
102
102
|
|
103
|
+
def do_not_whitelist
|
104
|
+
@data[:do_not_whitelist] = true
|
105
|
+
end
|
106
|
+
|
103
107
|
def self.eval_dsl(metadata, &block)
|
104
108
|
new(metadata).tap do |dsl|
|
105
109
|
dsl.instance_eval(&block)
|
@@ -317,7 +317,11 @@ module ForemanMaintain
|
|
317
317
|
|
318
318
|
steps_with_error = scenario.steps_with_error(:whitelisted => false)
|
319
319
|
steps_with_skipped = scenario.steps_with_skipped(:whitelisted => true)
|
320
|
-
|
320
|
+
not_skippable_steps = scenario.steps_with_error.select do |step|
|
321
|
+
step.metadata[:do_not_whitelist] == true
|
322
|
+
end
|
323
|
+
|
324
|
+
steps_to_whitelist = steps_with_error + steps_with_skipped - not_skippable_steps
|
321
325
|
unless steps_with_error.empty?
|
322
326
|
message << format(<<-MESSAGE.strip_heredoc, format_steps(steps_with_error, "\n", 2))
|
323
327
|
The following steps ended up in failing state:
|
@@ -325,11 +329,25 @@ module ForemanMaintain
|
|
325
329
|
%s
|
326
330
|
MESSAGE
|
327
331
|
whitelist_labels = steps_to_whitelist.map(&:label_dashed).join(',')
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
332
|
+
unless whitelist_labels.empty?
|
333
|
+
recommend << if scenario.detector.feature(:instance).downstream
|
334
|
+
format(<<-MESSAGE.strip_heredoc, whitelist_labels)
|
335
|
+
Resolve the failed steps and rerun the command.
|
336
|
+
|
337
|
+
If the situation persists and, you are unclear what to do next,
|
338
|
+
contact Red Hat Technical Support.
|
339
|
+
|
340
|
+
In case the failures are false positives, use
|
341
|
+
--whitelist="%s"
|
342
|
+
MESSAGE
|
343
|
+
else
|
344
|
+
format(<<-MESSAGE.strip_heredoc, whitelist_labels)
|
345
|
+
Resolve the failed steps and rerun the command.
|
346
|
+
In case the failures are false positives, use
|
347
|
+
--whitelist="%s"
|
348
|
+
MESSAGE
|
349
|
+
end
|
350
|
+
end
|
333
351
|
end
|
334
352
|
|
335
353
|
steps_with_warning = scenario.steps_with_warning(:whitelisted => false)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_maintain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.28
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Nečas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clamp
|