Skip to content

Commit

Permalink
Update DiskSpace check to account for Ubuntu
Browse files Browse the repository at this point in the history
Case RE-672: This increasing the amount of free space needed on '/boot'.
It also adds a check for '/tmp' and '/' ensuring that they have a
minimally amount of free space as well.

Changelog: Update DiskSpace check to account for Ubuntu
  • Loading branch information
Travis Holloway committed Nov 19, 2024
1 parent 23dbc87 commit 86556d3
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 22 deletions.
4 changes: 3 additions & 1 deletion elevate-cpanel
Original file line number Diff line number Diff line change
Expand Up @@ -1590,9 +1590,11 @@ BEGIN { # Suppress load of all of these at earliest point.
sub _disk_space_check ($self) {

my $need_space = {
'/boot' => 120 * MEG,
'/boot' => 200 * MEG,
'/usr/local/cpanel' => 1.5 * GIG, #
'/var/lib' => 5 * GIG,
'/tmp' => 5 * MEG,
'/' => 5 * GIG,
};

my @keys = ( sort keys %$need_space );
Expand Down
4 changes: 3 additions & 1 deletion lib/Elevate/Components/DiskSpace.pm
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ sub _disk_space_check ($self) {
# - /boot is small enough
# - /usr/local/cpanel is not going to be used at the same time than /var/lib
my $need_space = {
'/boot' => 120 * MEG,
'/boot' => 200 * MEG,
'/usr/local/cpanel' => 1.5 * GIG, #
'/var/lib' => 5 * GIG,
'/tmp' => 5 * MEG,
'/' => 5 * GIG,
};

my @keys = ( sort keys %$need_space );
Expand Down
50 changes: 30 additions & 20 deletions t/components-DiskSpace.t
Original file line number Diff line number Diff line change
Expand Up @@ -50,43 +50,49 @@ EOS

like(
dies { check_blocker() },
qr{expected 3 lines ; got 1 lines},
qr{expected 5 lines ; got 1 lines},
"_disk_space_check"
);

$saferun_output = <<EOS;
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/vda1 83874796 76307692 7567104 91% /
/dev/vda1 83874796 76307692 7567104 91% /
/dev/vda1 83874796 76307692 7567104 91% /
/dev/vda1 20134592 11245932 8872276 56% /
/dev/vda1 20134592 11245932 8872276 56% /
/dev/loop6 714624 92 677364 1% /tmp
/dev/vda1 20134592 11245932 8872276 56% /
/dev/vda1 20134592 11245932 8872276 56% /
EOS

is( check_blocker(), 1, "_disk_space_check ok" );

my $boot = 121 * MEG;
my $boot = 201 * MEG;

$saferun_output = <<"EOS";
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/vda1 83874796 76307692 $boot 91% /
/dev/vda1 83874796 76307692 7567104 91% /
/dev/vda1 83874796 76307692 7567104 91% /
/dev/vda1 20134592 11245932 8872276 56% /
/dev/vda1 20134592 11245932 $boot 56% /
/dev/loop6 714624 92 677364 1% /tmp
/dev/vda1 20134592 11245932 8872276 56% /
/dev/vda1 20134592 11245932 8872276 56% /
EOS

is( check_blocker(), 1, "_disk_space_check ok - /boot 121 M" );
is( check_blocker(), 1, "_disk_space_check ok - /boot 201 M" );

$boot = 119 * MEG;
$boot = 199 * MEG;

$saferun_output = <<"EOS";
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/vda1 83874796 76307692 $boot 91% /
/dev/vda1 83874796 76307692 7567104 91% /
/dev/vda1 83874796 76307692 7567104 91% /
/dev/vda1 20134592 11245932 8872276 56% /
/dev/vda1 20134592 11245932 $boot 56% /
/dev/loop6 714624 92 677364 1% /tmp
/dev/vda1 20134592 11245932 8872276 56% /
/dev/vda1 20134592 11245932 8872276 56% /
EOS

my $check;
like(
warnings { $check = check_blocker() },
[qr{/boot needs 120 M => available 119 M}],
[qr{/boot needs 200 M => available 199 M}],
q[Got expected warnings]
);

Expand All @@ -96,9 +102,11 @@ my $usr_local_cpanel = 2 * GIG;

$saferun_output = <<"EOS";
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/vda1 83874796 76307692 7567104 91% /
/dev/vda1 83874796 76307692 $usr_local_cpanel 91% /
/dev/vda1 83874796 76307692 7567104 91% /
/dev/vda1 20134592 11245932 8872276 56% /
/dev/vda1 20134592 11245932 8872276 56% /
/dev/loop6 714624 92 677364 1% /tmp
/dev/vda1 20134592 11245932 $usr_local_cpanel 56% /
/dev/vda1 20134592 11245932 8872276 56% /
EOS

is( check_blocker(), 1, "_disk_space_check ok - /usr/local/cpanel 2 G" );
Expand All @@ -107,9 +115,11 @@ $usr_local_cpanel = 1.4 * GIG;

$saferun_output = <<"EOS";
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/vda1 83874796 76307692 7567104 91% /
/dev/vda1 83874796 76307692 $usr_local_cpanel 91% /
/dev/vda1 83874796 76307692 7567104 91% /
/dev/vda1 20134592 11245932 8872276 56% /
/dev/vda1 20134592 11245932 8872276 56% /
/dev/loop6 714624 92 677364 1% /tmp
/dev/vda1 20134592 11245932 $usr_local_cpanel 56% /
/dev/vda1 20134592 11245932 8872276 56% /
EOS

like(
Expand Down

0 comments on commit 86556d3

Please sign in to comment.