Skip to content

Commit

Permalink
Merge pull request #508 from cpanel/RE-695
Browse files Browse the repository at this point in the history
Genericize `--no-leapp`, et al.
  • Loading branch information
toddr authored Sep 17, 2024
2 parents e41ede3 + e646c2e commit ef84804
Show file tree
Hide file tree
Showing 16 changed files with 96 additions and 72 deletions.
8 changes: 4 additions & 4 deletions docs-website-src/content/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,17 +217,17 @@ A final reboot is performed at the end of this stage.
By default, the elevate script runs the [leapp process](https://almalinux.org/elevate/)
to upgrade you from 7 to 8. `Leapp` may not be compatible with your system.

Using the `--no-leapp` option gives you a way to do the actual distro upgrade in your own way.
Using the `--upgrade-distro-manually` option gives you a way to do the actual distro upgrade in your own way.
This, for instance, can be used to allow `Virtuozzo` systems to upgrade cPanel systems, which are not supported by `Leapp`.

A `--no-leapp` upgrade would look like:
A `--upgrade-distro-manually` upgrade would look like:

1. User runs `/scripts/elevate-cpanel --start --no-leapp` which starts the upgrade process.
1. User runs `/scripts/elevate-cpanel --start --upgrade-distro-manually` which starts the upgrade process.
2. `elevate-cpanel` does all preparatory steps to upgrade the system prior to the distro upgrade.
3. Elevate will then create the file `/waiting_for_distro_upgrade` to indicate that the operating system is ready for an upgrade.
* This is when you would use your distro upgrade tool.
* When you have completed upgrading your system to 8, simply remove `/waiting_for_distro_upgrade` and reboot the system into normal multi-user mode.
5. Elevate will resume upon reboot and complete the upgrade just like it would have without `--no-leapp`
5. Elevate will resume upon reboot and complete the upgrade just like it would have without `--upgrade-distro-manually`

### Using the LEAPP_OVL_SIZE environment variable

Expand Down
65 changes: 33 additions & 32 deletions elevate-cpanel
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ BEGIN { # Suppress load of all of these at earliest point.
my @_DELEGATE_TO_CPEV = qw{
getopt
upgrade_to_pretty_name
should_run_leapp
should_run_distro_upgrade
ssystem
ssystem_capture_output
ssystem_hide_and_capture_output
Expand Down Expand Up @@ -491,7 +491,7 @@ BEGIN { # Suppress load of all of these at earliest point.

sub check ($self) {

return 1 unless $self->should_run_leapp; # skip when --no-leapp is provided
return 1 unless $self->should_run_distro_upgrade; # skip when --upgrade-distro-manually is provided

my $ok = 0;
try {
Expand Down Expand Up @@ -1158,7 +1158,7 @@ EOS

sub check ($self) {

return 1 unless $self->should_run_leapp; # skip when --no-leapp is provided
return 1 unless $self->should_run_distro_upgrade; # skip when --upgrade-distro-manually is provided

my $ok = 1;
$ok = 0 unless $self->_blocker_grub2_workaround;
Expand Down Expand Up @@ -1393,7 +1393,7 @@ EOS

sub check ($self) { # $self is a cpev object here

return 0 unless $self->should_run_leapp;
return 0 unless $self->should_run_distro_upgrade;

if ( _is_container_envtype() ) {
return $self->has_blocker( <<~'EOS');
Expand Down Expand Up @@ -1554,7 +1554,7 @@ EOS
use constant SBIN_IP => Elevate::Constants::SBIN_IP;

sub check ($self) {
return 1 unless $self->should_run_leapp; # skip when --no-leapp is provided
return 1 unless $self->should_run_distro_upgrade; # skip when --upgrade-distro-manually is provided
return $self->_blocker_bad_nics_naming;
}

Expand Down Expand Up @@ -2452,7 +2452,7 @@ EOS

return if $self->is_check_mode(); # skip for --check

return unless $self->should_run_leapp; # skip when --no-leapp is provided
return unless $self->should_run_distro_upgrade; # skip when --upgrade-distro-manually is provided

return if ( $self->blockers->num_blockers_found() > 0 ); # skip if any blockers have already been found

Expand Down Expand Up @@ -2577,7 +2577,7 @@ EOS
my @_DELEGATE_TO_CPEV = qw{
getopt
upgrade_to_pretty_name
should_run_leapp
should_run_distro_upgrade
ssystem
ssystem_and_die
ssystem_capture_output
Expand Down Expand Up @@ -3536,7 +3536,7 @@ EOS
}

sub verify_cmdline ($self) {
if ( $self->cpev->should_run_leapp() ) {
if ( $self->cpev->should_run_distro_upgrade() ) {
my $arg = "elevate-" . _persistent_id;
INFO("Checking for \"$arg\" in booted kernel's command line...");

Expand Down Expand Up @@ -6969,7 +6969,7 @@ EOS

sub upgrade ($self) {

return unless $self->cpev->should_run_leapp();
return unless $self->cpev->should_run_distro_upgrade();

$self->cpev->run_once(
setup_answer_file => sub {
Expand Down Expand Up @@ -7097,7 +7097,7 @@ EOS

sub wait_for_leapp_completion ($self) {

return 1 unless $self->cpev->should_run_leapp();
return 1 unless $self->cpev->should_run_distro_upgrade();

my $upgrade_log = LEAPP_UPGRADE_LOG;

Expand Down Expand Up @@ -8220,7 +8220,7 @@ EOS
service start clean continue manual-reboots status log check:s
skip-cpanel-version-check skip-elevate-version-check
update version
no-leapp
upgrade-distro-manually no-leapp
non-interactive
leappbeta
);
Expand Down Expand Up @@ -8577,8 +8577,9 @@ CloudLinux 7 => CloudLinux 8
--skip-cpanel-version-check Skip the check for whether cPanel is up to date.
This option is intended only for testing!
--no-leapp Do not try to run leapp, and pause instead.
Once leapp has been run you should remove the file
--upgrade-distro-manually
--no-leapp Do not try to run the distro upgrade process, and pause instead.
Once the upgrade has been run you should remove the file
/waiting_for_distro_upgrade
--help Display this documentation.
Expand Down Expand Up @@ -8650,14 +8651,14 @@ the update process by running:
By default, the elevate script runs the L<leapp process|https://almalinux.org/elevate/>
to upgrade you from 7 to 8. `Leapp` may not be compatible with your system.
Using the `--no-leapp` option gives you a way to do the actual distro upgrade in your own way.
Using the `--upgrade-distro-manually` option gives you a way to do the actual distro upgrade in your own way.
This, for instance, can be used to allow `Virtuozzo` systems to upgrade cPanel systems, which are not supported by `Leapp`.
A `--no-leapp` upgrade would look like:
A `--upgrade-distro-manually` upgrade would look like:
=over
=item 1. User runs `/scripts/elevate-cpanel --start --no-leapp` which starts the upgrade process.
=item 1. User runs `/scripts/elevate-cpanel --start --upgrade-distro-manually` which starts the upgrade process.
=item 2. `elevate-cpanel` does all preparatory steps to upgrade the system prior to the distro upgrade.
Expand All @@ -8671,11 +8672,11 @@ A `--no-leapp` upgrade would look like:
=back
=item 4. Elevate will resume upon reboot and complete the upgrade just like it would have without `--no-leapp`
=item 4. Elevate will resume upon reboot and complete the upgrade just like it would have without `--upgrade-distro-manually`
=back
NOTE: `--no-leapp` is not required for helper commands like `--continue` or `--status`
NOTE: `--upgrade-distro-manually` is not required for helper commands like `--continue` or `--status`
=head1 WARNINGS
Expand Down Expand Up @@ -9067,17 +9068,17 @@ sub start ($self) {

$self->_capture_env_variables(); # capture at startup

if ( $self->getopt('no-leapp') ) {
if ( $self->getopt('upgrade-distro-manually') || $self->getopt('no-leapp') ) {
my $touchfile = PAUSE_ELEVATE_TOUCHFILE;
WARN( <<~"EOS");
'leapp' checks and run are disabled.
Automated upgrade of the distro has been disabled.
Please wait for the file '$touchfile' to be created.
At that stage the elevation process is paused then you can upgrade from 7 to 8 on your own.
At that stage, the ELevate process is paused, and you can upgrade from 7 to 8 on your own.
Once the system has been successfully upgraded from 7 to 8 you can then remove that file
to let the elevation process continue and update cPanel for the updated distribution.
Once the system has been successfully upgraded from 7 to 8, you can then remove that file
to let the ELevate process continue and update cPanel for the new distribution.
EOS
Elevate::StageFile::update_stage_file( { no_leapp => 1 } );
Elevate::StageFile::update_stage_file( { upgrade_distro_manually => 1 } );
}

# This starts the service for us:
Expand Down Expand Up @@ -9451,7 +9452,7 @@ sub run_stage_1 ($self) {

Elevate::Motd->setup();

if ( !$self->should_run_leapp() ) {
if ( !$self->should_run_distro_upgrade() ) {
Elevate::Stages::bump_stage();
return ACTION_CONTINUE;
}
Expand Down Expand Up @@ -9529,7 +9530,7 @@ sub run_stage_3 ($self) {

$self->run_once('run_final_components_pre_leapp');

if ( !$self->should_run_leapp() ) {
if ( !$self->should_run_distro_upgrade() ) {
return $self->_request_to_upgrade_distro_manually();
}

Expand Down Expand Up @@ -10004,13 +10005,13 @@ sub post_upgrade_check ($self) {

# TODO: We're going to need to store reboot time so we know if the last reboot has happened when we re-run the script.

sub should_run_leapp ($self) {
sub should_run_distro_upgrade ($self) {

# we store the no_leapp option, but prefer using a positive check instead
# we need to check to see if the no-leapp option is passed via CLI here too in order
# to allow users to run this script with the '--check --no-leapp' options
my $no_leapp = Elevate::StageFile::read_stage_file( 'no_leapp', 0 ) || $self->getopt('no-leapp');
return !$no_leapp;
# we store the upgrade_distro_manually option, but prefer using a positive check instead
# we need to check to see if the CLI option is passed here too in order
# to allow users to run this script with the '--check --upgrade-distro-manually', etc. options
my $manual_distro_upgrade = scalar grep { $self->getopt($_) || Elevate::StageFile::read_stage_file( tr/-/_/r, 0 ) } qw/upgrade-distro-manually no-leapp/;
return !$manual_distro_upgrade;
}

sub get_current_status ($self) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Elevate/Blockers/Base.pm
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ BEGIN {
my @_DELEGATE_TO_CPEV = qw{
getopt
upgrade_to_pretty_name
should_run_leapp
should_run_distro_upgrade
ssystem
ssystem_capture_output
ssystem_hide_and_capture_output
Expand Down
2 changes: 1 addition & 1 deletion lib/Elevate/Blockers/BootKernel.pm
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use Try::Tiny;

sub check ($self) {

return 1 unless $self->should_run_leapp; # skip when --no-leapp is provided
return 1 unless $self->should_run_distro_upgrade; # skip when --upgrade-distro-manually is provided

my $ok = 0;
try {
Expand Down
2 changes: 1 addition & 1 deletion lib/Elevate/Blockers/Grub2.pm
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ sub GRUB2_PREFIX_RHEL { return '/boot/grub2' }

sub check ($self) {

return 1 unless $self->should_run_leapp; # skip when --no-leapp is provided
return 1 unless $self->should_run_distro_upgrade; # skip when --upgrade-distro-manually is provided

my $ok = 1;
$ok = 0 unless $self->_blocker_grub2_workaround;
Expand Down
2 changes: 1 addition & 1 deletion lib/Elevate/Blockers/IsContainer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use Log::Log4perl qw(:easy);

sub check ($self) { # $self is a cpev object here

return 0 unless $self->should_run_leapp;
return 0 unless $self->should_run_distro_upgrade;

if ( _is_container_envtype() ) {
return $self->has_blocker( <<~'EOS');
Expand Down
2 changes: 1 addition & 1 deletion lib/Elevate/Blockers/Leapp.pm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ sub check ($self) {

return if $self->is_check_mode(); # skip for --check

return unless $self->should_run_leapp; # skip when --no-leapp is provided
return unless $self->should_run_distro_upgrade; # skip when --upgrade-distro-manually is provided

return if ( $self->blockers->num_blockers_found() > 0 ); # skip if any blockers have already been found

Expand Down
2 changes: 1 addition & 1 deletion lib/Elevate/Blockers/NICs.pm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use constant ETH_FILE_PREFIX => Elevate::Constants::ETH_FILE_PREFIX;
use constant SBIN_IP => Elevate::Constants::SBIN_IP;

sub check ($self) {
return 1 unless $self->should_run_leapp; # skip when --no-leapp is provided
return 1 unless $self->should_run_distro_upgrade; # skip when --upgrade-distro-manually is provided
return $self->_blocker_bad_nics_naming;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Elevate/Components/Base.pm
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ BEGIN {
my @_DELEGATE_TO_CPEV = qw{
getopt
upgrade_to_pretty_name
should_run_leapp
should_run_distro_upgrade
ssystem
ssystem_and_die
ssystem_capture_output
Expand Down
2 changes: 1 addition & 1 deletion lib/Elevate/Components/Grub2.pm
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ sub _remove_but_dont_stop_service ($self) {
}

sub verify_cmdline ($self) {
if ( $self->cpev->should_run_leapp() ) {
if ( $self->cpev->should_run_distro_upgrade() ) {
my $arg = "elevate-" . _persistent_id;
INFO("Checking for \"$arg\" in booted kernel's command line...");

Expand Down
4 changes: 2 additions & 2 deletions lib/Elevate/Leapp.pm
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ sub preupgrade ($self) {

sub upgrade ($self) {

return unless $self->cpev->should_run_leapp();
return unless $self->cpev->should_run_distro_upgrade();

$self->cpev->run_once(
setup_answer_file => sub {
Expand Down Expand Up @@ -244,7 +244,7 @@ sub extract_error_block_from_output ( $self, $text_ar ) {
sub wait_for_leapp_completion ($self) {

# No use waiting for leapp to complete if we did not run leapp
return 1 unless $self->cpev->should_run_leapp();
return 1 unless $self->cpev->should_run_distro_upgrade();

my $upgrade_log = LEAPP_UPGRADE_LOG;

Expand Down
2 changes: 1 addition & 1 deletion lib/Elevate/Usage.pm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ sub _OPTIONS {
service start clean continue manual-reboots status log check:s
skip-cpanel-version-check skip-elevate-version-check
update version
no-leapp
upgrade-distro-manually no-leapp
non-interactive
leappbeta
);
Expand Down
Loading

0 comments on commit ef84804

Please sign in to comment.