Skip to content

Commit

Permalink
Merge pull request #554 from cpanel/subrename
Browse files Browse the repository at this point in the history
Rename should_run_distro_upgrade to upgrade_distro_manually
  • Loading branch information
cPholloway authored Nov 20, 2024
2 parents 23dbc87 + 9ec66df commit c7a8098
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 30 deletions.
24 changes: 12 additions & 12 deletions elevate-cpanel
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ BEGIN { # Suppress load of all of these at earliest point.
BEGIN {
my @_DELEGATE_TO_CPEV = qw{
getopt
should_run_distro_upgrade
upgrade_distro_manually
ssystem
ssystem_and_die
ssystem_capture_output
Expand Down Expand Up @@ -686,7 +686,7 @@ BEGIN { # Suppress load of all of these at earliest point.

sub check ($self) {

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

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

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

Expand Down Expand Up @@ -2448,7 +2448,7 @@ EOS
sub check ($self) {

return 1 unless Elevate::OS::needs_leapp();
return 1 unless $self->should_run_distro_upgrade; # skip when --upgrade-distro-manually is provided
return 1 unless $self->upgrade_distro_manually; # skip when --upgrade-distro-manually is provided

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

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

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

if ( _is_container_envtype() ) {
return $self->has_blocker( <<~'EOS');
Expand Down Expand Up @@ -3328,7 +3328,7 @@ EOS

return unless Elevate::OS::needs_leapp();

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

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

Expand Down Expand Up @@ -4162,7 +4162,7 @@ EOS
sub check ($self) {

return 1 unless Elevate::OS::needs_leapp();
return 1 unless $self->should_run_distro_upgrade;
return 1 unless $self->upgrade_distro_manually;

return $self->_blocker_bad_nics_naming;
}
Expand Down Expand Up @@ -8519,7 +8519,7 @@ deb https://wp-toolkit.plesk.com/cPanel/Ubuntu-22.04-x86_64/latest/thirdparty/ .

sub upgrade ($self) {

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

$self->cpev->run_once(
setup_answer_file => sub {
Expand Down Expand Up @@ -8648,7 +8648,7 @@ deb https://wp-toolkit.plesk.com/cPanel/Ubuntu-22.04-x86_64/latest/thirdparty/ .
sub wait_for_leapp_completion ($self) {
return 1 unless Elevate::OS::needs_leapp();

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

my $upgrade_log = LEAPP_UPGRADE_LOG;

Expand Down Expand Up @@ -10714,7 +10714,7 @@ sub run_stage_1 ($self) {

Elevate::Motd->setup();

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

$self->run_once('run_final_components_pre_distro_upgrade');

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

Expand Down Expand Up @@ -11219,7 +11219,7 @@ 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_distro_upgrade ($self) {
sub upgrade_distro_manually ($self) {

# 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
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 @@ -29,7 +29,7 @@ use Log::Log4perl qw(:easy);
BEGIN {
my @_DELEGATE_TO_CPEV = qw{
getopt
should_run_distro_upgrade
upgrade_distro_manually
ssystem
ssystem_and_die
ssystem_capture_output
Expand Down
2 changes: 1 addition & 1 deletion lib/Elevate/Components/BootKernel.pm
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use Try::Tiny;

sub check ($self) {

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

my $ok = 0;
try {
Expand Down
4 changes: 2 additions & 2 deletions lib/Elevate/Components/Grub2.pm
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ sub _remove_but_dont_stop_service ($self) {

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

Expand Down Expand Up @@ -320,7 +320,7 @@ sub post_distro_upgrade ($self) {
sub check ($self) {

return 1 unless Elevate::OS::needs_leapp();
return 1 unless $self->should_run_distro_upgrade; # skip when --upgrade-distro-manually is provided
return 1 unless $self->upgrade_distro_manually; # 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/Components/IsContainer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use Log::Log4perl qw(:easy);

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

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

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

return unless Elevate::OS::needs_leapp();

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

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

Expand Down
2 changes: 1 addition & 1 deletion lib/Elevate/Components/NICs.pm
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ sub check ($self) {

# This only matters for upgrades performed with the leapp utility
return 1 unless Elevate::OS::needs_leapp();
return 1 unless $self->should_run_distro_upgrade;
return 1 unless $self->upgrade_distro_manually;

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

sub upgrade ($self) {

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

$self->cpev->run_once(
setup_answer_file => sub {
Expand Down Expand Up @@ -240,7 +240,7 @@ sub wait_for_leapp_completion ($self) {
return 1 unless Elevate::OS::needs_leapp();

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

my $upgrade_log = LEAPP_UPGRADE_LOG;

Expand Down
6 changes: 3 additions & 3 deletions script/elevate-cpanel.PL
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@ sub run_stage_1 ($self) {

Elevate::Motd->setup();

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

$self->run_once('run_final_components_pre_distro_upgrade');

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

Expand Down Expand Up @@ -1445,7 +1445,7 @@ 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_distro_upgrade ($self) {
sub upgrade_distro_manually ($self) {

# 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
Expand Down
4 changes: 2 additions & 2 deletions t/components-BootKernel.t
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ my $comp = cpev->new->get_component('BootKernel');
reboot_status => sub { die "should not be called here\n"; },
);

$mock_cpev->redefine( should_run_distro_upgrade => 0 );
$mock_cpev->redefine( upgrade_distro_manually => 0 );
is( $comp->check(), 1, 'Should skip when upgrade-distro-manually is passed' );
}

{
note 'Test BootKernel behavior';

$mock_cpev->redefine( should_run_distro_upgrade => 1 );
$mock_cpev->redefine( upgrade_distro_manually => 1 );

my $rv;
my $bv;
Expand Down
4 changes: 2 additions & 2 deletions t/components-Grub2.t
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ $mock_stage_file->redefine( _save_stage_file => sub { $stage_data = $_[0]; retur
my $cmdline;
$mock_slurp->redefine( read_binary => sub { return $cmdline } );

$mock_cpev->redefine( should_run_distro_upgrade => 1 );
$mock_cpev->redefine( do_cleanup => sub { $stage_data = undef; return; } );
$mock_cpev->redefine( upgrade_distro_manually => 1 );
$mock_cpev->redefine( do_cleanup => sub { $stage_data = undef; return; } );

my $mock_comp = Test::MockModule->new('Elevate::Components::Grub2');
$mock_comp->redefine( _default_kernel => "kernel-image" );
Expand Down
4 changes: 2 additions & 2 deletions t/leapp_upgrade.t
Original file line number Diff line number Diff line change
Expand Up @@ -314,13 +314,13 @@ note 'LEAPP upgrade log failure checks';
$mock_leapp_upgrade_log->unlink;

$mock_elevate->redefine(
should_run_distro_upgrade => 0,
upgrade_distro_manually => 0,
);

is( cpev->leapp->wait_for_leapp_completion, 1, 'wait_for_leapp_completion returns early when it should NOT run leapp' );

$mock_elevate->redefine(
should_run_distro_upgrade => 1,
upgrade_distro_manually => 1,
);

is( cpev->leapp->wait_for_leapp_completion, 0, "wait_for_leapp_completion fails when the upgrade log is missing." );
Expand Down

0 comments on commit c7a8098

Please sign in to comment.