From 8b7a8bb9f2764da011e29b0f9ae645f192932099 Mon Sep 17 00:00:00 2001 From: "Eric D. Helms" Date: Thu, 2 May 2024 16:54:43 -0400 Subject: [PATCH] Combine Satellite and Capsule into a single scenario --- .../procedures/installer/upgrade_rake_task.rb | 7 +- ...satellite_6_16.rb => satellite_upgrade.rb} | 19 ++-- .../scenarios/upgrade_to_capsule_6_16.rb | 102 ------------------ 3 files changed, 13 insertions(+), 115 deletions(-) rename definitions/scenarios/{upgrade_to_satellite_6_16.rb => satellite_upgrade.rb} (80%) delete mode 100644 definitions/scenarios/upgrade_to_capsule_6_16.rb diff --git a/definitions/procedures/installer/upgrade_rake_task.rb b/definitions/procedures/installer/upgrade_rake_task.rb index 488fad8eb..dbca8efc3 100644 --- a/definitions/procedures/installer/upgrade_rake_task.rb +++ b/definitions/procedures/installer/upgrade_rake_task.rb @@ -2,12 +2,13 @@ module Procedures::Installer class UpgradeRakeTask < ForemanMaintain::Procedure metadata do description 'Execute upgrade:run rake task' + confine do + feature(:foreman) + end end def run - # only run this in the Satellite scenario, as in others - # the installer runs this rake task for us already - execute!('foreman-rake upgrade:run') if feature(:satellite) + execute!('foreman-rake upgrade:run') end end end diff --git a/definitions/scenarios/upgrade_to_satellite_6_16.rb b/definitions/scenarios/satellite_upgrade.rb similarity index 80% rename from definitions/scenarios/upgrade_to_satellite_6_16.rb rename to definitions/scenarios/satellite_upgrade.rb index b8d07d64d..03c592566 100644 --- a/definitions/scenarios/upgrade_to_satellite_6_16.rb +++ b/definitions/scenarios/satellite_upgrade.rb @@ -1,11 +1,10 @@ -module Scenarios::Satellite_6_16 +module Scenarios::Satellite class Abstract < ForemanMaintain::Scenario def self.upgrade_metadata(&block) metadata do tags :upgrade_scenario confine do - feature(:satellite) && - (feature(:satellite).current_minor_version == '6.15' || \ + (feature(:downstream).current_minor_version == '6.15' || \ ForemanMaintain.upgrade_in_progress == '6.16') end instance_eval(&block) @@ -19,7 +18,7 @@ def target_version class PreUpgradeCheck < Abstract upgrade_metadata do - description 'Checks before upgrading to Satellite 6.16' + description 'Checks before upgrading' tags :pre_upgrade_checks run_strategy :fail_slow end @@ -29,14 +28,14 @@ def compose add_steps(find_checks(:pre_upgrade)) add_step(Checks::CheckIpv6Disable) add_step(Checks::Disk::AvailableSpacePostgresql13) - add_step(Checks::Repositories::Validate.new(:version => '6.16')) + add_step(Checks::Repositories::Validate.new(:version => target_version)) add_step(Checks::CheckOrganizationContentAccessMode) end end class PreMigrations < Abstract upgrade_metadata do - description 'Procedures before migrating to Satellite 6.16' + description 'Procedures before migrating' tags :pre_migrations end @@ -47,7 +46,7 @@ def compose class Migrations < Abstract upgrade_metadata do - description 'Migration scripts to Satellite 6.16' + description 'Migration scripts' tags :migrations run_strategy :fail_fast end @@ -57,7 +56,7 @@ def set_context_mapping end def compose - add_step(Procedures::Repositories::Setup.new(:version => '6.16')) + add_step(Procedures::Repositories::Setup.new(:version => target_version)) if el8? modules_to_switch = ['postgresql:13'] add_step(Procedures::Packages::SwitchModules.new(:module_names => modules_to_switch)) @@ -77,7 +76,7 @@ def compose class PostMigrations < Abstract upgrade_metadata do - description 'Procedures after migrating to Satellite 6.16' + description 'Procedures after migrating' tags :post_migrations end @@ -90,7 +89,7 @@ def compose class PostUpgradeChecks < Abstract upgrade_metadata do - description 'Checks after upgrading to Satellite 6.16' + description 'Checks after upgrading' tags :post_upgrade_checks run_strategy :fail_slow end diff --git a/definitions/scenarios/upgrade_to_capsule_6_16.rb b/definitions/scenarios/upgrade_to_capsule_6_16.rb deleted file mode 100644 index be3414a97..000000000 --- a/definitions/scenarios/upgrade_to_capsule_6_16.rb +++ /dev/null @@ -1,102 +0,0 @@ -module Scenarios::Capsule_6_16 - class Abstract < ForemanMaintain::Scenario - def self.upgrade_metadata(&block) - metadata do - tags :upgrade_scenario - confine do - feature(:capsule) && - (feature(:capsule).current_minor_version == '6.15' || \ - ForemanMaintain.upgrade_in_progress == '6.16') - end - instance_eval(&block) - end - end - - def target_version - '6.16' - end - end - - class PreUpgradeCheck < Abstract - upgrade_metadata do - description 'Checks before upgrading to Capsule 6.16' - tags :pre_upgrade_checks - run_strategy :fail_slow - end - - def compose - add_steps(find_checks(:default)) - add_steps(find_checks(:pre_upgrade)) - add_step(Checks::CheckIpv6Disable) - add_step(Checks::Disk::AvailableSpacePostgresql13) - add_step(Checks::Repositories::Validate.new(:version => '6.16')) - end - end - - class PreMigrations < Abstract - upgrade_metadata do - description 'Procedures before migrating to Capsule 6.16' - tags :pre_migrations - end - - def compose - add_steps(find_procedures(:pre_migrations)) - end - end - - class Migrations < Abstract - upgrade_metadata do - description 'Migration scripts to Capsule 6.16' - tags :migrations - end - - def set_context_mapping - context.map(:assumeyes, Procedures::Installer::Run => :assumeyes) - end - - def compose - add_step(Procedures::Repositories::Setup.new(:version => '6.16')) - if el8? - modules_to_switch = ['postgresql:13'] - add_step(Procedures::Packages::SwitchModules.new(:module_names => modules_to_switch)) - modules_to_enable = ["satellite-capsule:#{el_short_name}"] - add_step(Procedures::Packages::EnableModules.new(:module_names => modules_to_enable)) - end - add_step(Procedures::Packages::Update.new( - :assumeyes => true, - :download_only => true - )) - add_step(Procedures::Service::Stop.new) - add_step(Procedures::Packages::Update.new(:assumeyes => true, :clean_cache => false)) - add_step_with_context(Procedures::Installer::Run) - end - end - - class PostMigrations < Abstract - upgrade_metadata do - description 'Procedures after migrating to Capsule 6.16' - tags :post_migrations - end - - def compose - add_step(Procedures::RefreshFeatures) - add_step(Procedures::Service::Start.new) - add_steps(find_procedures(:post_migrations)) - end - end - - class PostUpgradeChecks < Abstract - upgrade_metadata do - description 'Checks after upgrading to Capsule 6.16' - tags :post_upgrade_checks - run_strategy :fail_slow - end - - def compose - add_steps(find_checks(:default)) - add_steps(find_checks(:post_upgrade)) - add_step(Procedures::Packages::CheckForReboot) - add_step(Procedures::Pulpcore::ContainerHandleImageMetadata) - end - end -end