foreman_maintain 1.6.8 → 1.6.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 693bf5fa41d37437188c4990278301d1965819e37fad7b0dc680e1fdff8f8631
4
- data.tar.gz: d56694b7ed8093eeaa814fdf950f5c308d76eeffbf97a654ecbb20ef55611759
3
+ metadata.gz: 6d9b63f8c0c837772d8b3970d21f05e1b1a10a8b4a85784c4aca8cf337668dd1
4
+ data.tar.gz: 97034a6b9d3afef56fe2e996d7704e46c4eed61d9f86fc5cf9e9b62ddc425b96
5
5
  SHA512:
6
- metadata.gz: 40503012245738da00890d0d224141754f00c110f9bbc7c62112b3e11bea7beb066718bfffdc36056ae9afbed29f2ac8ca6d9dd474e4af9a1eee50099a636352
7
- data.tar.gz: d71cfc02366e99a507f1453706d0ffcfe01f1dcdb8cf231a03a4b8468716f1c4b3ae25acfa5938f32858bf17fb37d974d511173b047808b84a03e8dd38ce1d1a
6
+ metadata.gz: cf9b2cf09d804f042cabb04f2215b088776ceee4987fb1aef6be1e09e19207e949b8fc028792729eef29445c8946c3103999bc4f43b07d4509106a1079f49cb0
7
+ data.tar.gz: f50fc364c0d8d1bfd1dc14764381cabdcde43483e302571a96cc171b4a9c607fad71251424211ed771ebd17cce80559a396ed0345d2a998d26d3239877988d21
@@ -12,15 +12,15 @@ module Checks
12
12
 
13
13
  def run
14
14
  current_db_version = feature(:foreman_database).db_version
15
- fail!(db_upgrade_message(current_db_version)) if current_db_version.major < 12
15
+ fail!(db_upgrade_message(current_db_version)) if current_db_version.major < 13
16
16
  end
17
17
 
18
18
  def db_upgrade_message(db_version)
19
19
  product_name = feature(:instance).product_name
20
20
 
21
21
  "\n\n*** ERROR: Server is running on PostgreSQL #{db_version} database.\n"\
22
- "*** Newer version of #{product_name} supports only PostgreSQL version 12.\n"\
23
- "*** Before proceeding further, you must upgrade database to PostgreSQL 12.\n"
22
+ "*** Newer version of #{product_name} supports only PostgreSQL version 13.\n"\
23
+ "*** Before proceeding further, you must upgrade database to PostgreSQL 13.\n"
24
24
  end
25
25
  end
26
26
  end
@@ -9,4 +9,16 @@ class Features::ForemanInstall < ForemanMaintain::Feature
9
9
  !feature(:instance).downstream && feature(:foreman_server)
10
10
  end
11
11
  end
12
+
13
+ def target_version
14
+ '3.11'
15
+ end
16
+
17
+ def current_version
18
+ @current_version ||= package_version(package_name)
19
+ end
20
+
21
+ def package_name
22
+ 'foreman'
23
+ end
12
24
  end
@@ -91,6 +91,24 @@ class Features::Instance < ForemanMaintain::Feature
91
91
  feature(:foreman_install) || feature(:katello_install)
92
92
  end
93
93
 
94
+ def current_version
95
+ version = if feature(:instance).downstream
96
+ feature(:instance).downstream.current_version
97
+ else
98
+ feature(:foreman_install).current_version
99
+ end
100
+
101
+ version.to_s[/^\d+\.\d+\.\d+/]
102
+ end
103
+
104
+ def target_version
105
+ if feature(:instance).downstream
106
+ Features::Satellite.new.target_version
107
+ else
108
+ Features::ForemanInstall.new.target_version
109
+ end
110
+ end
111
+
94
112
  private
95
113
 
96
114
  # rubocop:disable Metrics/AbcSize
@@ -9,10 +9,6 @@ class Features::Katello < ForemanMaintain::Feature
9
9
  end
10
10
  end
11
11
 
12
- def data_dirs
13
- @dirs ||= ['/var/lib/pulp', '/var/lib/pgsql']
14
- end
15
-
16
12
  def current_version
17
13
  @current_version ||= package_version('katello')
18
14
  end
@@ -10,6 +10,10 @@ class Features::Satellite < ForemanMaintain::Feature
10
10
  end
11
11
  end
12
12
 
13
+ def target_version
14
+ '6.16'
15
+ end
16
+
13
17
  def current_version
14
18
  @current_version ||= package_version(package_name) || version_from_source
15
19
  end
@@ -18,6 +18,10 @@ class Procedures::HammerSetup < ForemanMaintain::Procedure
18
18
  end
19
19
 
20
20
  def necessary?
21
- !feature(:hammer).check_connection
21
+ if feature(:hammer)
22
+ !feature(:hammer).check_connection
23
+ else
24
+ false
25
+ end
22
26
  end
23
27
  end
@@ -2,12 +2,13 @@ module Procedures::Installer
2
2
  class UpgradeRakeTask < ForemanMaintain::Procedure
3
3
  metadata do
4
4
  description 'Execute upgrade:run rake task'
5
+ confine do
6
+ feature(:satellite)
7
+ end
5
8
  end
6
9
 
7
10
  def run
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)
11
+ execute!('foreman-rake upgrade:run')
11
12
  end
12
13
  end
13
14
  end
@@ -8,11 +8,18 @@ module Procedures::Packages
8
8
 
9
9
  def run
10
10
  if @packages.nil? || @packages.empty?
11
- question = "\nWARNING: No specific packages to update were provided\n" \
12
- "so we are going to update all available packages.\n" \
13
- "To Upgrade to next version use 'foreman-maintain upgrade'.\n\n" \
14
- "Do you want to proceed with update of everything regardless\n" \
15
- 'of the recommendations?'
11
+ command = ForemanMaintain.command_name
12
+
13
+ question = <<~MSG
14
+ WARNING: No specific packages to update were provided
15
+ so we are going to update all available packages. We
16
+ recommend using the update command to update to a minor
17
+ version and/or operating system using '#{command} update'.
18
+ To upgrade to the next #{feature(:instance).product_name} version use '#{command} upgrade'.
19
+ Do you want to proceed with update of everything regardless of
20
+ the recommendations?
21
+ MSG
22
+
16
23
  answer = ask_decision(question, actions_msg: 'y(yes), q(quit)')
17
24
  abort! unless answer == :yes
18
25
  end
@@ -17,9 +17,6 @@ module Procedures::Pulpcore
17
17
  spinner.update('Adding image metadata to pulp. You can continue using the ' \
18
18
  'system normally while the task runs in the background.')
19
19
  execute!(pulpcore_manager('container-handle-image-data'))
20
- spinner.update('Adding image metadata to katello. You can continue using the ' \
21
- 'system normally while the task runs in the background.')
22
- execute!('foreman-rake katello:import_container_manifest_labels')
23
20
  end
24
21
  end
25
22
  end
@@ -0,0 +1,17 @@
1
+ module Procedures::Repositories
2
+ class IndexKatelloRepositoriesContainerMetatdata < ForemanMaintain::Procedure
3
+ metadata do
4
+ description 'Import container manifest metadata'
5
+ confine do
6
+ feature(:katello)
7
+ end
8
+ end
9
+
10
+ def run
11
+ with_spinner(('Adding image metadata. You can continue using the ' \
12
+ 'system normally while the task runs in the background.')) do
13
+ execute!('foreman-rake katello:import_container_manifest_labels')
14
+ end
15
+ end
16
+ end
17
+ end
@@ -81,15 +81,13 @@ module ForemanMaintain::Scenarios
81
81
  include_dumps if include_db_dumps?
82
82
  add_step_with_context(Procedures::ForemanProxy::Features, :load_only => true)
83
83
  add_steps_with_context(
84
- find_procedures(:maintenance_mode_on),
85
84
  Procedures::Service::Stop,
86
85
  Procedures::Backup::ConfigFiles,
87
86
  Procedures::Backup::Pulp,
88
87
  Procedures::Backup::Offline::CandlepinDB,
89
88
  Procedures::Backup::Offline::ForemanDB,
90
89
  Procedures::Backup::Offline::PulpcoreDB,
91
- Procedures::Service::Start,
92
- find_procedures(:maintenance_mode_off)
90
+ Procedures::Service::Start
93
91
  )
94
92
  end
95
93
 
@@ -135,7 +135,8 @@ module Scenarios::ForemanUpgrade
135
135
  Checks::ServicesUp,
136
136
  Checks::SystemRegistration,
137
137
  Procedures::Packages::CheckForReboot,
138
- Procedures::Pulpcore::ContainerHandleImageMetadata
138
+ Procedures::Pulpcore::ContainerHandleImageMetadata,
139
+ Procedures::Repositories::IndexKatelloRepositoriesContainerMetatdata
139
140
  )
140
141
  end
141
142
  end
@@ -35,7 +35,7 @@ module ForemanMaintain::Scenarios
35
35
  add_step_with_context(Procedures::Service::Stop)
36
36
  add_steps_with_context(Procedures::Restore::ExtractFiles) if backup.tar_backups_exist?
37
37
 
38
- if backup.sql_dump_files_exist?
38
+ if backup.sql_needs_dump_restore?
39
39
  add_steps_with_context(Procedures::Restore::DropDatabases)
40
40
  restore_sql_dumps(backup)
41
41
  end
@@ -1,11 +1,10 @@
1
- module Scenarios::Satellite_6_16
1
+ module Scenarios::Satellite
2
2
  class Abstract < ForemanMaintain::Scenario
3
3
  def self.upgrade_metadata(&block)
4
4
  metadata do
5
5
  tags :upgrade_scenario
6
6
  confine do
7
- feature(:satellite) &&
8
- (feature(:satellite).current_minor_version == '6.15' || \
7
+ (feature(:instance).downstream.current_minor_version == '6.15' || \
9
8
  ForemanMaintain.upgrade_in_progress == '6.16')
10
9
  end
11
10
  instance_eval(&block)
@@ -19,7 +18,7 @@ module Scenarios::Satellite_6_16
19
18
 
20
19
  class PreUpgradeCheck < Abstract
21
20
  upgrade_metadata do
22
- description 'Checks before upgrading to Satellite 6.16'
21
+ description 'Checks before upgrading'
23
22
  tags :pre_upgrade_checks
24
23
  run_strategy :fail_slow
25
24
  end
@@ -29,14 +28,14 @@ module Scenarios::Satellite_6_16
29
28
  add_steps(find_checks(:pre_upgrade))
30
29
  add_step(Checks::CheckIpv6Disable)
31
30
  add_step(Checks::Disk::AvailableSpacePostgresql13)
32
- add_step(Checks::Repositories::Validate.new(:version => '6.16'))
31
+ add_step(Checks::Repositories::Validate.new(:version => target_version))
33
32
  add_step(Checks::CheckOrganizationContentAccessMode)
34
33
  end
35
34
  end
36
35
 
37
36
  class PreMigrations < Abstract
38
37
  upgrade_metadata do
39
- description 'Procedures before migrating to Satellite 6.16'
38
+ description 'Procedures before migrating'
40
39
  tags :pre_migrations
41
40
  end
42
41
 
@@ -47,7 +46,7 @@ module Scenarios::Satellite_6_16
47
46
 
48
47
  class Migrations < Abstract
49
48
  upgrade_metadata do
50
- description 'Migration scripts to Satellite 6.16'
49
+ description 'Migration scripts'
51
50
  tags :migrations
52
51
  run_strategy :fail_fast
53
52
  end
@@ -57,7 +56,7 @@ module Scenarios::Satellite_6_16
57
56
  end
58
57
 
59
58
  def compose
60
- add_step(Procedures::Repositories::Setup.new(:version => '6.16'))
59
+ add_step(Procedures::Repositories::Setup.new(:version => target_version))
61
60
  if el8?
62
61
  modules_to_switch = ['postgresql:13']
63
62
  add_step(Procedures::Packages::SwitchModules.new(:module_names => modules_to_switch))
@@ -77,7 +76,7 @@ module Scenarios::Satellite_6_16
77
76
 
78
77
  class PostMigrations < Abstract
79
78
  upgrade_metadata do
80
- description 'Procedures after migrating to Satellite 6.16'
79
+ description 'Procedures after migrating'
81
80
  tags :post_migrations
82
81
  end
83
82
 
@@ -90,7 +89,7 @@ module Scenarios::Satellite_6_16
90
89
 
91
90
  class PostUpgradeChecks < Abstract
92
91
  upgrade_metadata do
93
- description 'Checks after upgrading to Satellite 6.16'
92
+ description 'Checks after upgrading'
94
93
  tags :post_upgrade_checks
95
94
  run_strategy :fail_slow
96
95
  end
@@ -100,6 +99,7 @@ module Scenarios::Satellite_6_16
100
99
  add_steps(find_checks(:post_upgrade))
101
100
  add_step(Procedures::Packages::CheckForReboot)
102
101
  add_step(Procedures::Pulpcore::ContainerHandleImageMetadata)
102
+ add_step(Procedures::Repositories::IndexKatelloRepositoriesContainerMetatdata)
103
103
  end
104
104
  end
105
105
  end
@@ -4,11 +4,11 @@ module ForemanMaintain::Scenarios
4
4
  include ForemanMaintain::Concerns::Versions
5
5
 
6
6
  def target_version
7
- @target_version ||= Gem::Version.new(current_version).bump.to_s
7
+ feature(:instance).target_version
8
8
  end
9
9
 
10
10
  def current_version
11
- feature(:instance).downstream.current_version.to_s[/^\d+\.\d+\.\d+/]
11
+ feature(:instance).current_version
12
12
  end
13
13
 
14
14
  def maintenance_repo_label
@@ -47,12 +47,11 @@ module ForemanMaintain::Scenarios
47
47
  end
48
48
  end
49
49
 
50
- def upstream_target_version
51
- if feature(:katello_install)
52
- return foreman_version_by_katello(target_version)
53
- else
54
- target_version
55
- end
50
+ def self_upgrade_allowed?
51
+ target = Gem::Version.new(target_version).version
52
+
53
+ Gem::Version.new(current_version).segments[0..1].join('.') == target ||
54
+ Gem::Version.new(current_version).bump.segments[0..1].join('.') == target
56
55
  end
57
56
  end
58
57
 
@@ -65,6 +64,16 @@ module ForemanMaintain::Scenarios
65
64
  end
66
65
 
67
66
  def downstream_self_upgrade(pkgs_to_update)
67
+ unless self_upgrade_allowed?
68
+ raise(
69
+ ForemanMaintain::Error::Warn,
70
+ "foreman-maintain is too many versions ahead. The target " \
71
+ "version is #{target_version} while the currently installed " \
72
+ "version is #{current_version}. Please rollback " \
73
+ "foreman-maintain to the proper version."
74
+ )
75
+ end
76
+
68
77
  ForemanMaintain.enable_maintenance_module
69
78
 
70
79
  add_step(Procedures::Packages::Update.new(packages: pkgs_to_update, assumeyes: true,
@@ -77,7 +86,7 @@ module ForemanMaintain::Scenarios
77
86
  # 2. Update the foreman-maintain packages from next major version repository
78
87
  # 3. Rollback the repository to current major version
79
88
 
80
- add_step(Procedures::Repositories::Setup.new(:version => upstream_target_version))
89
+ add_step(Procedures::Repositories::Setup.new(:version => target_version))
81
90
  add_step(Procedures::Packages::Update.new(packages: pkgs_to_update, assumeyes: true))
82
91
  ensure
83
92
  rollback_repositories
@@ -74,21 +74,10 @@ module ForemanMaintain
74
74
  interactive_option
75
75
  disable_self_upgrade_option
76
76
 
77
- option '--phase', 'phase', 'run only a specific phase', :required => false do |phase|
78
- unless UpgradeRunner::PHASES.include?(phase.to_sym)
79
- raise Error::UsageError, "Unknown phase #{phase}"
80
- end
81
- phase
82
- end
83
-
84
77
  def execute
85
78
  ForemanMaintain.validate_downstream_packages
86
79
  ForemanMaintain.perform_self_upgrade if allow_self_upgrade?
87
- if phase
88
- upgrade_runner.run_phase(phase.to_sym)
89
- else
90
- upgrade_runner.run
91
- end
80
+ upgrade_runner.run
92
81
  upgrade_runner.save
93
82
  exit upgrade_runner.exit_code
94
83
  end
@@ -46,7 +46,7 @@ module ForemanMaintain
46
46
  def finish_update
47
47
  @finished = true
48
48
  @reporter.hline
49
- @reporter.puts("Update finished.")
49
+ @reporter.puts("Update finished.\n")
50
50
  end
51
51
 
52
52
  def storage
@@ -223,12 +223,20 @@ module ForemanMaintain
223
223
  file_map[:pgsql_data][:present]
224
224
  end
225
225
 
226
+ def sql_tar_files_exist?
227
+ file_map[:pgsql_data][:present]
228
+ end
229
+
226
230
  def sql_dump_files_exist?
227
231
  file_map[:foreman_dump][:present] ||
228
232
  file_map[:candlepin_dump][:present] ||
229
233
  file_map[:pulpcore_dump][:present]
230
234
  end
231
235
 
236
+ def sql_needs_dump_restore?
237
+ !sql_tar_files_exist? && sql_dump_files_exist?
238
+ end
239
+
232
240
  def incremental?
233
241
  !!metadata.fetch('incremental', false)
234
242
  end
@@ -1,3 +1,3 @@
1
1
  module ForemanMaintain
2
- VERSION = '1.6.8'.freeze
2
+ VERSION = '1.6.10'.freeze
3
3
  end
@@ -174,6 +174,10 @@ module ForemanMaintain
174
174
  [main_package_name, 'foreman-maintain']
175
175
  end
176
176
 
177
+ def command_name
178
+ pkg_and_cmd_name[1]
179
+ end
180
+
177
181
  def perform_self_upgrade
178
182
  package_name, command = pkg_and_cmd_name
179
183
 
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: 1.6.8
4
+ version: 1.6.10
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: 2024-06-06 00:00:00.000000000 Z
11
+ date: 2024-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clamp
@@ -284,6 +284,7 @@ files:
284
284
  - definitions/procedures/repositories/backup_enabled_repos.rb
285
285
  - definitions/procedures/repositories/disable.rb
286
286
  - definitions/procedures/repositories/enable.rb
287
+ - definitions/procedures/repositories/index_katello_repositories_container_metadata.rb
287
288
  - definitions/procedures/repositories/setup.rb
288
289
  - definitions/procedures/restore/candlepin_dump.rb
289
290
  - definitions/procedures/restore/configs.rb
@@ -313,11 +314,10 @@ files:
313
314
  - definitions/scenarios/packages.rb
314
315
  - definitions/scenarios/puppet.rb
315
316
  - definitions/scenarios/restore.rb
317
+ - definitions/scenarios/satellite_upgrade.rb
316
318
  - definitions/scenarios/self_upgrade.rb
317
319
  - definitions/scenarios/services.rb
318
320
  - definitions/scenarios/update.rb
319
- - definitions/scenarios/upgrade_to_capsule_6_16.rb
320
- - definitions/scenarios/upgrade_to_satellite_6_16.rb
321
321
  - extras/foreman-maintain.sh
322
322
  - extras/foreman_protector/dnf/foreman-protector.py
323
323
  - extras/foreman_protector/foreman-protector.conf
@@ -1,102 +0,0 @@
1
- module Scenarios::Capsule_6_16
2
- class Abstract < ForemanMaintain::Scenario
3
- def self.upgrade_metadata(&block)
4
- metadata do
5
- tags :upgrade_scenario
6
- confine do
7
- feature(:capsule) &&
8
- (feature(:capsule).current_minor_version == '6.15' || \
9
- ForemanMaintain.upgrade_in_progress == '6.16')
10
- end
11
- instance_eval(&block)
12
- end
13
- end
14
-
15
- def target_version
16
- '6.16'
17
- end
18
- end
19
-
20
- class PreUpgradeCheck < Abstract
21
- upgrade_metadata do
22
- description 'Checks before upgrading to Capsule 6.16'
23
- tags :pre_upgrade_checks
24
- run_strategy :fail_slow
25
- end
26
-
27
- def compose
28
- add_steps(find_checks(:default))
29
- add_steps(find_checks(:pre_upgrade))
30
- add_step(Checks::CheckIpv6Disable)
31
- add_step(Checks::Disk::AvailableSpacePostgresql13)
32
- add_step(Checks::Repositories::Validate.new(:version => '6.16'))
33
- end
34
- end
35
-
36
- class PreMigrations < Abstract
37
- upgrade_metadata do
38
- description 'Procedures before migrating to Capsule 6.16'
39
- tags :pre_migrations
40
- end
41
-
42
- def compose
43
- add_steps(find_procedures(:pre_migrations))
44
- end
45
- end
46
-
47
- class Migrations < Abstract
48
- upgrade_metadata do
49
- description 'Migration scripts to Capsule 6.16'
50
- tags :migrations
51
- end
52
-
53
- def set_context_mapping
54
- context.map(:assumeyes, Procedures::Installer::Run => :assumeyes)
55
- end
56
-
57
- def compose
58
- add_step(Procedures::Repositories::Setup.new(:version => '6.16'))
59
- if el8?
60
- modules_to_switch = ['postgresql:13']
61
- add_step(Procedures::Packages::SwitchModules.new(:module_names => modules_to_switch))
62
- modules_to_enable = ["satellite-capsule:#{el_short_name}"]
63
- add_step(Procedures::Packages::EnableModules.new(:module_names => modules_to_enable))
64
- end
65
- add_step(Procedures::Packages::Update.new(
66
- :assumeyes => true,
67
- :download_only => true
68
- ))
69
- add_step(Procedures::Service::Stop.new)
70
- add_step(Procedures::Packages::Update.new(:assumeyes => true, :clean_cache => false))
71
- add_step_with_context(Procedures::Installer::Run)
72
- end
73
- end
74
-
75
- class PostMigrations < Abstract
76
- upgrade_metadata do
77
- description 'Procedures after migrating to Capsule 6.16'
78
- tags :post_migrations
79
- end
80
-
81
- def compose
82
- add_step(Procedures::RefreshFeatures)
83
- add_step(Procedures::Service::Start.new)
84
- add_steps(find_procedures(:post_migrations))
85
- end
86
- end
87
-
88
- class PostUpgradeChecks < Abstract
89
- upgrade_metadata do
90
- description 'Checks after upgrading to Capsule 6.16'
91
- tags :post_upgrade_checks
92
- run_strategy :fail_slow
93
- end
94
-
95
- def compose
96
- add_steps(find_checks(:default))
97
- add_steps(find_checks(:post_upgrade))
98
- add_step(Procedures::Packages::CheckForReboot)
99
- add_step(Procedures::Pulpcore::ContainerHandleImageMetadata)
100
- end
101
- end
102
- end