From ade69f14a7713408a6141e8d5540f2f2181dda5e Mon Sep 17 00:00:00 2001 From: Daniel Hilst <392820+dhilst@users.noreply.github.com> Date: Thu, 5 Nov 2026 08:21:55 -0300 Subject: [PATCH] fix(xcat-core): the Ubuntu installer dies with curtin NotExclusiveError A diskful Ubuntu 24.04 install reaches Subiquity, runs curtin, and dies in exclusive_open on the root partition with curtin.util.NotExclusiveError. The console names apt-get as a user of the partition. pre.ubuntu.subiquity starts rsyslogd inside the live installer to forward the install log to the management node. In the 24.04 installer that process holds 11.9G of a 16G node while its message queue is empty: impstats reports "main Q: size=0 enqueued=7 maxqsize=6" beside "maxrss=11951868", so no rsyslog setting bounds it. rsyslogd runs in the cgroup of snap.subiquity.subiquity-server.service, so the kernel OOM killer stops the installer. systemd starts a second subiquity-server, and that server runs curtin partitioning while the first server's curtin is still installing the kernel into the target, so clear_holders cannot open the root partition. xcat_start_installer_rsyslog starts the forwarder with systemd-run, in a transient unit with MemoryMax=128M and MemorySwapMax=0. The kernel then kills the forwarder alone. Where systemd-run is absent the install forwards no syslog, because the install is worth more than its remote log. ubuntu_subiquity_installer_syslog.bats reads the command line the routine asks for. Dropping the two memory properties fails the limit assertions and leaves the launcher and the no-fallback assertions green. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com> (cherry picked from commit 2db399cd6c07e98494353c292990c150a9adce15) --- .../xcat/install/scripts/pre.ubuntu.subiquity | 33 ++++++++- .../ubuntu_subiquity_installer_syslog.bats | 69 +++++++++++++++++++ 2 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 xCAT-test/bats/ubuntu_subiquity_installer_syslog.bats diff --git a/xCAT-server/share/xcat/install/scripts/pre.ubuntu.subiquity b/xCAT-server/share/xcat/install/scripts/pre.ubuntu.subiquity index 92707fb716..945f89f973 100644 --- a/xCAT-server/share/xcat/install/scripts/pre.ubuntu.subiquity +++ b/xCAT-server/share/xcat/install/scripts/pre.ubuntu.subiquity @@ -5,6 +5,37 @@ fi #!/bin/sh +#--- xcat_start_installer_rsyslog +# Start the log forwarder in its own cgroup, with a memory limit. +# +# The forwarder cannot be bounded from its own configuration. Measured in the 24.04 live +# installer: rsyslogd holds 11.9G of a 16G node while its message queue is empty -- impstats +# reported "main Q: size=0 enqueued=7 maxqsize=6" beside "maxrss=11951868" -- and AppArmor +# refuses it the journal socket, so it forwards almost nothing for that memory. +# +# rsyslogd runs in snap.subiquity.subiquity-server.service's cgroup, so the kernel OOM killer +# stopped the installer: systemd started a second subiquity-server, and that server ran curtin +# partitioning while the first server's curtin still held the root partition. The install died +# with curtin.util.NotExclusiveError on /dev/sda3. +# +# In its own cgroup the kernel kills the forwarder alone. Without systemd-run there is no limit +# to put it in, and the install is worth more than its remote log. +#--- +xcat_start_installer_rsyslog() { + if ! command -v systemd-run >/dev/null 2>&1; then + echo "xcat: no systemd-run, so this install forwards no syslog" >&2 + return 0 + fi + + systemd-run --quiet --collect --unit=xcat-installer-syslog \ + --property=MemoryMax=128M --property=MemorySwapMax=0 \ + -- rsyslogd -n -f "$1" +} + +# A bats test sources this script to drive the routine above. The installer sets nothing here, +# so an install runs the whole script. +[ -n "${XCAT_PRE_SOURCE_ONLY:-}" ] && return 0 + # syslog is probably running from the syslog.socket service systemctl stop syslog.socket systemctl stop rsyslog @@ -17,7 +48,7 @@ module(load="imuxsock") module(load="imklog" permitnonkernelfacility="on") *.* @#XCATVAR:XCATMASTER# EOF -rsyslogd -f /etc/rsyslog.conf +xcat_start_installer_rsyslog /etc/rsyslog.conf log_label="xcat.deployment" logger -t $log_label -p "info" "============deployment starting============" logger -t $log_label -p "info" "Running preseeding early_command Installation script..." diff --git a/xCAT-test/bats/ubuntu_subiquity_installer_syslog.bats b/xCAT-test/bats/ubuntu_subiquity_installer_syslog.bats new file mode 100644 index 0000000000..02deaab665 --- /dev/null +++ b/xCAT-test/bats/ubuntu_subiquity_installer_syslog.bats @@ -0,0 +1,69 @@ +#!/usr/bin/env bats +# +# pre.ubuntu.subiquity starts a syslog forwarder inside the Subiquity live installer. The +# forwarder cannot be bounded from its configuration: in the 24.04 installer rsyslogd holds +# 11.9G of a 16G node while its message queue is empty. It runs in the subiquity-server +# cgroup, so the kernel OOM killer stopped the installer, systemd started a second server, and +# that server ran curtin partitioning over a disk the first curtin still held. +# +# So the forwarder must start in a cgroup of its own with a memory limit. Run the routine with +# the launcher replaced, and read the command line it asked for. + +bats_require_minimum_version 1.5.0 + +load 'helpers/shell_source' + +setup() +{ + PRE_SCRIPT="$(repo_path 'xCAT-server/share/xcat/install/scripts/pre.ubuntu.subiquity')" + [ -r "$PRE_SCRIPT" ] || skip "$PRE_SCRIPT is required" + LAUNCHED="${BATS_TEST_TMPDIR}/launched" + : >"$LAUNCHED" + + # Sourcing is safe only while the script returns at its guard. Without the guard it would + # run the install here, and that writes /etc/rsyslog.conf on the host. CI runs as root. + if ! grep -q 'XCAT_PRE_SOURCE_ONLY' "$PRE_SCRIPT"; then + echo "$PRE_SCRIPT has no source guard; refusing to run it" >&2 + return 1 + fi + + # bash resolves a function before PATH, so the routine runs as written and nothing starts a + # daemon. command -v reports a function, so the routine also finds its launcher here. + systemd-run() { printf 'systemd-run %s\n' "$*" >>"$LAUNCHED"; } + rsyslogd() { printf 'rsyslogd %s\n' "$*" >>"$LAUNCHED"; } + + XCAT_PRE_SOURCE_ONLY=1 . "$PRE_SCRIPT" +} + +@test "the forwarder starts through the launcher that can limit it" { + run xcat_start_installer_rsyslog /etc/rsyslog.conf + [ "$status" -eq 0 ] + grep -q '^systemd-run .*rsyslogd -n -f /etc/rsyslog.conf$' "$LAUNCHED" +} + +# 128M is about 0.8% of the node this was measured on. The ceiling keeps a later edit from +# raising the limit to something the installer cannot spare. +@test "the forwarder gets a memory limit the installer can spare" { + local limit + run xcat_start_installer_rsyslog /etc/rsyslog.conf + [ "$status" -eq 0 ] + limit="$(sed -n 's/.*--property=MemoryMax=\([0-9]*\)M.*/\1/p' "$LAUNCHED")" + [ -n "$limit" ] + [ "$limit" -gt 0 ] + [ "$limit" -le 256 ] +} + +@test "the limited forwarder cannot fall back to swap" { + run xcat_start_installer_rsyslog /etc/rsyslog.conf + [ "$status" -eq 0 ] + grep -q -- '--property=MemorySwapMax=0' "$LAUNCHED" +} + +@test "the forwarder never starts unlimited when it cannot be limited" { + local empty="${BATS_TEST_TMPDIR}/nopath" + mkdir -p "$empty" + unset -f systemd-run + PATH="$empty" run xcat_start_installer_rsyslog /etc/rsyslog.conf + [ "$status" -eq 0 ] + run -1 grep -q '^rsyslogd ' "$LAUNCHED" +}