NOTE: This updates the reserved RAM to 8 GiB from 4 GiB!

* Adds support for 'anvil_resources:🐏:reserved' that can be set to a number of MiB to override the default 8192.
* Adds support for 'anvil::<anvil_uuid>::resources:🐏:reserved' to allow for per-Anvil! node override on the reserved RAM default, and over the 'anvil_resources:🐏:reserved' option.

Signed-off-by: digimer <mkelly@alteeve.ca>
main
digimer 2 years ago
parent f086c1be39
commit 89eae7098e
  1. 85
      Anvil/Tools/Get.pm
  2. 10
      anvil.conf
  3. 2
      share/words.xml

@ -689,34 +689,103 @@ ORDER BY
}
# Check if the reserved RAM is overriden by the config
my $default_reserved = 8192;
if (not exists $anvil->data->{anvil_resources}{ram}{reserved})
{
$anvil->data->{anvil_resources}{ram}{reserved} = $default_reserved;
}
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"anvil_resources::ram::reserved" => $anvil->data->{anvil_resources}{ram}{reserved}." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{anvil_resources}{ram}{reserved}}).")",
}});
$anvil->data->{anvil_resources}{ram}{reserved} =~ s/,//g;
$anvil->data->{anvil_resources}{ram}{reserved} =~ s/\s//g;
$anvil->data->{anvil_resources}{ram}{reserved} =~ s/MiB$//i;
$anvil->data->{anvil_resources}{ram}{reserved} =~ s/MB$//i;
$anvil->data->{anvil_resources}{ram}{reserved} =~ s/M$//i;
if ((not $anvil->data->{anvil_resources}{ram}{reserved}) or ($anvil->data->{anvil_resources}{ram}{reserved} =~ /\D/))
{
# Invalid value.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "alert", key => "warning_0151", variables => {
was => $anvil->data->{anvil_resources}{ram}{reserved},
set => $default_reserved,
}});
$anvil->data->{anvil_resources}{ram}{reserved} = $default_reserved;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"anvil_resources::ram::reserved" => $anvil->data->{anvil_resources}{ram}{reserved},
}});
}
#anvil::<anvil_uuid>::resources::ram::reserved
if (exists $anvil->data->{anvil}{$anvil_uuid}{resources}{ram}{reserved})
{
$anvil->data->{anvil}{$anvil_uuid}{resources}{ram}{reserved} =~ s/,//g;
$anvil->data->{anvil}{$anvil_uuid}{resources}{ram}{reserved} =~ s/\s//g;
$anvil->data->{anvil}{$anvil_uuid}{resources}{ram}{reserved} =~ s/MiB$//i;
$anvil->data->{anvil}{$anvil_uuid}{resources}{ram}{reserved} =~ s/MB$//i;
$anvil->data->{anvil}{$anvil_uuid}{resources}{ram}{reserved} =~ s/M$//i;
if ((not $anvil->data->{anvil_resources}{ram}{reserved}) or ($anvil->data->{anvil_resources}{ram}{reserved} =~ /\D/))
{
# Invalid value.
my $anvil_name = $anvil->Get->anvil_name_from_uuid({anvil_uuid => $anvil_uuid});
$anvil_name = $anvil_uuid if not $anvil_name;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "alert", key => "warning_0152", variables => {
anvil => $anvil_name,
was => $anvil->data->{anvil}{$anvil_uuid}{resources}{ram}{reserved},
set => $anvil->data->{anvil_resources}{ram}{reserved},
}});
$anvil->data->{anvil}{$anvil_uuid}{resources}{ram}{reserved} = $anvil->data->{anvil_resources}{ram}{reserved};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"anvil::${anvil_uuid}::resources::ram::reserved" => $anvil->data->{anvil}{$anvil_uuid}{resources}{ram}{reserved},
}});
}
if ($anvil->data->{anvil}{$anvil_uuid}{resources}{ram}{reserved})
{
$anvil->data->{anvil_resources}{ram}{reserved} = $anvil->data->{anvil}{$anvil_uuid}{resources}{ram}{reserved};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"anvil_resources::ram::reserved" => $anvil->data->{anvil_resources}{ram}{reserved},
}});
}
}
my $ram_reserved = $anvil->Convert->human_readable_to_bytes({
base2 => 1,
size => $anvil->data->{anvil_resources}{ram}{reserved},
size => $anvil->data->{anvil_resources}{ram}{reserved}." MiB",
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
ram_reserved => $ram_reserved." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $ram_reserved}).")",
}});
if (($ram_reserved eq "!!error!!") or
(not $ram_reserved) or
($ram_reserved < (2**30)) or
($ram_reserved > $anvil->data->{anvil_resources}{$anvil_uuid}{ram}{hardware}))
{
# The reserved RAM is invalid, so reset it.
$ram_reserved = 0;
}
# The reserved RAM is invalid, so reset it to 8 GiB
$ram_reserved = 8589934592;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"anvil_resources::ram::reserved" => $ram_reserved." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $ram_reserved}).")",
ram_reserved => $ram_reserved." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $ram_reserved}).")",
}});
}
# Take 4 GiB or what was provided by the config off the available RAM for the host
$anvil->data->{anvil_resources}{$anvil_uuid}{ram}{reserved} = $ram_reserved ? $ram_reserved : (4*(2**30)); # Reserve 4 GiB by default or what's set in the config file.
$anvil->data->{anvil_resources}{$anvil_uuid}{ram}{reserved} = $ram_reserved;
$anvil->data->{anvil_resources}{$anvil_uuid}{ram}{available} -= $anvil->data->{anvil_resources}{$anvil_uuid}{ram}{reserved};
$anvil->data->{anvil_resources}{$anvil_uuid}{ram}{available} -= $anvil->data->{anvil_resources}{$anvil_uuid}{ram}{allocated};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"anvil_resources::${anvil_uuid}::ram::allocated" => $anvil->data->{anvil_resources}{$anvil_uuid}{ram}{allocated}." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{anvil_resources}{$anvil_uuid}{ram}{allocated}}).")",
"anvil_resources::${anvil_uuid}::ram::reserved" => $anvil->data->{anvil_resources}{$anvil_uuid}{ram}{reserved}." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{anvil_resources}{$anvil_uuid}{ram}{reserved}}).")",
"anvil_resources::${anvil_uuid}::ram::available" => $anvil->data->{anvil_resources}{$anvil_uuid}{ram}{available}." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{anvil_resources}{$anvil_uuid}{ram}{available}}).")",
}});
if ($anvil->data->{anvil_resources}{$anvil_uuid}{ram}{available} < 0)
{
$anvil->data->{anvil_resources}{$anvil_uuid}{ram}{available} = 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"anvil_resources::${anvil_uuid}::ram::available" => $anvil->data->{anvil_resources}{$anvil_uuid}{ram}{available}." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{anvil_resources}{$anvil_uuid}{ram}{available}}).")",
}});
}
# process bridges now
foreach my $bridge_name (sort {$a cmp $b} keys %{$anvil->data->{anvil_resources}{$anvil_uuid}{bridges}})
{

@ -193,6 +193,16 @@ striker::repo::extra-packages =
# Setting this to '0' will disable auto-management of the firewall.
sys::manage::firewall = 1
# By default, Anvil! nodes reserve 8 GiB of RAM for host OS use. That is to say, if a node (pair) has 128GiB
# of physical RAM, 120 GiB will be available for allocation to servers. Generally, this should NOT be reduced
# as doing so could trigger oom-killer (out of memory killer) to terminate servers. This is an integer
# representing the reserved RAM in MiB
# NOTE: Minimum is 1024, but really, never go below 4096 unless you _really_ know what you're doing.
#anvil_resources::ram::reserved = 8192
# If you wish to alter the amount of reservered RAM for a single Anvil! node, you can use:
#anvil::<anvil_uuid>::resources::ram::reserved = 8192
### Server related options
# This is the "short list" of servers shown when provisioning a new server. To see the full list of options,

@ -3584,6 +3584,8 @@ The error was:
<key name="warning_0148">[ Warning ] - The IPMI stonith resource: [#!variable!resource!#] is in the role: [#!variable!role!#] (should be 'Started'). Will check the IPMI config now.</key>
<key name="warning_0149">[ Warning ] - Failed to find a valid IP address or password to be used to setup the DR host's IPMI.</key>
<key name="warning_0150">[ Warning ] - The test "fail file": [#!variable!fail_file!#] was found. So long as this file exists, the ocf:alteeve:server RA will return 'OCF_ERR_GENERIC' (exit code 1). Delete the file to resume normal operation.</key>
<key name="warning_0151">[ Warning ] - The configured reserved RAM was set to: [#!variable!was!#], which appears invalid. It must be an integer value representing the amount of RAM to reserve, in MiB. The reserved RAM is being set to: [#!variable!was!#].</key>
<key name="warning_0152">[ Warning ] - The configured reserved RAM was set to: [#!variable!was!#], which appears invalid. It must be an integer value representing the amount of RAM to reserve, in MiB. The reserved RAM is being set to: [#!variable!was!#].</key>
</language>
<!-- 日本語 -->
<language name="jp" long_name="日本語" description="Anvil! language file.">

Loading…
Cancel
Save