agents: always write the memory cap, infinity for none
The cap file was removed for a cap of `infinity` or a RAM percentage, so the boot check warned on every start of such an agent, for a legitimate config. The file is now written on every start: - a size: its byte count, as before; - `infinity`: the literal `infinity`. The generators set no JSC heap ceiling and no subagent MemoryHigh=, and the boot check is quiet; - a percentage: resolved on the host the way systemd resolves MemoryMax=N% for the container@ unit. That is permyriad (at most two decimals, at most 100%) of sysconf(_SC_PHYS_PAGES) * sysconf(_SC_PAGESIZE), rounded down to a page; - a value systemd ignores (zero, over 100%, more than two decimals, unparseable) leaves the unit uncapped, so it is `infinity`. The file is missing only when hive-c0re can't tell the cap: the limits file and the kept drop-in are both unreadable, or a percentage meets an unknown host memory size. The boot check now warns only for a missing file or a first line that is neither a byte count nor `infinity`. Part of #5081 (slice S0-2).
This commit is contained in:
parent
57955a6c53
commit
eaca3c4eb3
5 changed files with 253 additions and 67 deletions
|
|
@ -58,11 +58,11 @@ check() {
|
|||
fi
|
||||
|
||||
# The warning goes to stderr with the journal's `<4>` priority prefix, and
|
||||
# nothing goes anywhere for a usable cap.
|
||||
# nothing goes anywhere for a byte count or `infinity`.
|
||||
got=$(env -i "$dir/check" 2>&1)
|
||||
local want_warn=
|
||||
if [ -n "$want_why" ]; then
|
||||
want_warn="<4>$cap $want_why: no BUN_JSC_forceRAMSize heap ceiling and no MemoryHigh= on hive-subagent-daemon; the host's MemoryMax= on the container still applies. hive-c0re writes no file for a cap of infinity or a RAM percentage."
|
||||
want_warn="<4>$cap $want_why: no BUN_JSC_forceRAMSize heap ceiling and no MemoryHigh= on hive-subagent-daemon; the host's MemoryMax= on the container still applies."
|
||||
fi
|
||||
if [ "$got" != "$want_warn" ]; then
|
||||
fail "boot check printed:"$'\n'"$got"$'\n'"wanted:"$'\n'"$want_warn"
|
||||
|
|
@ -88,17 +88,26 @@ check "a line without a newline is kept" 3221225472 2863311530
|
|||
printf '4294967296\nLD_PRELOAD=/x\n' >"$cap"
|
||||
check "only the first line is read" 3221225472 2863311530
|
||||
|
||||
printf 'infinity\n' >"$cap"
|
||||
check "infinity sets nothing and warns of nothing" "" "" ""
|
||||
|
||||
printf 'infinity' >"$cap"
|
||||
check "infinity without a newline" "" "" ""
|
||||
|
||||
printf 'infinityx\n' >"$cap"
|
||||
check "a word that only starts with infinity" "" "" "holds neither a byte count nor infinity"
|
||||
|
||||
printf '8G\n' >"$cap"
|
||||
check "a size with a suffix is ignored" "" "" "does not start with a plain byte count"
|
||||
check "a size with a suffix is ignored" "" "" "holds neither a byte count nor infinity"
|
||||
|
||||
printf '0123\n' >"$cap"
|
||||
check "a leading zero is ignored" "" "" "does not start with a plain byte count"
|
||||
check "a leading zero is ignored" "" "" "holds neither a byte count nor infinity"
|
||||
|
||||
printf '1234567890123456\n' >"$cap"
|
||||
check "sixteen digits are ignored" "" "" "does not start with a plain byte count"
|
||||
check "sixteen digits are ignored" "" "" "holds neither a byte count nor infinity"
|
||||
|
||||
: >"$cap"
|
||||
check "an empty file" "" "" "does not start with a plain byte count"
|
||||
check "an empty file" "" "" "holds neither a byte count nor infinity"
|
||||
|
||||
rm -f "$cap"
|
||||
check "no file" "" "" "is missing"
|
||||
|
|
|
|||
Loading…
Reference in a new issue