From 10a03ba8ef94c3041a16aa2a2f2030a5d7e48c97 Mon Sep 17 00:00:00 2001 From: amannocci Date: Sat, 12 Jul 2025 19:59:00 +0100 Subject: [PATCH] feat: reduce verbose messages Signed-off-by: amannocci --- src/etc/ignity/init/00-container-discover | 1 - src/etc/s6/boot/stage2 | 2 +- src/etc/s6/boot/stage2-envs | 1 - src/etc/s6/boot/stage2-init | 6 +- src/etc/s6/boot/stage3 | 8 +- src/etc/s6/boot/stage3-finalize | 4 +- src/usr/bin/container-discover | 110 ---------------------- src/usr/bin/preboot | 2 - src/usr/src/install-ignity.sh | 8 +- tests/boot/tests.bats | 5 - 10 files changed, 12 insertions(+), 135 deletions(-) delete mode 100755 src/usr/bin/container-discover diff --git a/src/etc/ignity/init/00-container-discover b/src/etc/ignity/init/00-container-discover index 8041948..0cbe5b7 100755 --- a/src/etc/ignity/init/00-container-discover +++ b/src/etc/ignity/init/00-container-discover @@ -1,4 +1,3 @@ #!/bin/execlineb -P foreground { s6-echo "Operating system info" } foreground { redirfd -r 0 /proc/version s6-cat } -foreground { container-discover } diff --git a/src/etc/s6/boot/stage2 b/src/etc/s6/boot/stage2 index a21f673..2674001 100755 --- a/src/etc/s6/boot/stage2 +++ b/src/etc/s6/boot/stage2 @@ -17,7 +17,7 @@ foreground { # option, there is no clean way to allow symlinks between user provided runcoms. if { s6-hiercopy /etc/ignity/${i} /run/ignity/${i} } } - importas -u ? ? if { s6-echo -- " exited ${?}." } + importas -u ? ? exit ${?} } diff --git a/src/etc/s6/boot/stage2-envs b/src/etc/s6/boot/stage2-envs index e1283cc..095c43c 100755 --- a/src/etc/s6/boot/stage2-envs +++ b/src/etc/s6/boot/stage2-envs @@ -12,7 +12,6 @@ if { importas -ui d d backtick -n i { s6-basename "${d}" } importas -ui file i - if { s6-echo -- "[supervisor/env] Loading environment file: ${file}..." } redirfd -r 0 /etc/ignity/envs/${file} load-envfile if { s6-dumpenv "/run/ignity/envs" } } diff --git a/src/etc/s6/boot/stage2-init b/src/etc/s6/boot/stage2-init index d562b1a..574d9da 100755 --- a/src/etc/s6/boot/stage2-init +++ b/src/etc/s6/boot/stage2-init @@ -2,20 +2,18 @@ if { if -t { eltest -d /run/ignity/init } - if { s6-echo "[supervisor/init] Executing container init scripts" } + if { s6-echo "[supervisor/init] Executing environment init scripts" } if { elglob -s -0 g "/run/ignity/init/*" forx -o 0 d { ${g} } importas -ui d d backtick -n i { s6-basename "${d}" } importas -ui i i - if { s6-echo -- "[supervisor/init] Executing init script: ${i}..." } foreground { /run/ignity/init/${i} } importas -u ? ? - if { s6-echo -- "[supervisor/init] Init script ${i} exited ${?}." } exit ${?} } - if { s6-echo -- "[supervisor/init] Init scripts executed" } + if { s6-echo -- "[supervisor/init] Environment init scripts executed" } } $@ diff --git a/src/etc/s6/boot/stage3 b/src/etc/s6/boot/stage3 index 4fe3b75..f7d3c48 100755 --- a/src/etc/s6/boot/stage3 +++ b/src/etc/s6/boot/stage3 @@ -30,20 +30,20 @@ foreground { } # Kill everything, gently. -foreground { s6-echo "[supervisor/finalize] Sending all processes the KILL signal" } -foreground { s6-nuke -th } # foreground is process 1: it survives +foreground { s6-echo "[supervisor/finalize] Sending all processes the termination signals" } +foreground { redirfd -a 2 /dev/null redirfd -a 1 /dev/null s6-nuke -th } # foreground is process 1: it survives foreground { importas -D 3000 -u IGNITY_KILL_GRACETIME IGNITY_KILL_GRACETIME s6-sleep -m -- ${IGNITY_KILL_GRACETIME} } # Last message, then close our pipes and give the logger some time. -foreground { s6-echo "[supervisor/finalize] Sending all processes the KILL signal and exiting" } +foreground { s6-echo "[supervisor/finalize] Sending all processes the kill signal and exiting" } fdclose 1 fdclose 2 s6-sleep -m 200 # Kill everything, brutally. -foreground { s6-nuke -k } # foreground is process 1: it survives again +foreground { redirfd -a 2 /dev/null redirfd -a 1 /dev/null s6-nuke -k } # foreground is process 1: it survives again # Reap all the zombies then sync, and we're done. wait { } diff --git a/src/etc/s6/boot/stage3-finalize b/src/etc/s6/boot/stage3-finalize index 6971a0f..3b10cd6 100755 --- a/src/etc/s6/boot/stage3-finalize +++ b/src/etc/s6/boot/stage3-finalize @@ -3,20 +3,18 @@ importas -D 5000 -u IGNITY_KILL_FINALIZE_MAXTIME IGNITY_KILL_FINALIZE_MAXTIME if { if -t { eltest -d /run/ignity/finalize } - if { s6-echo "[supervisor/finalize] Executing container finalize scripts..." } + if { s6-echo "[supervisor/finalize] Executing environment finalize scripts..." } if { elglob -s -0 g "/run/ignity/finalize/*" forx -o 0 d { ${g} } importas -ui d d backtick -n i { s6-basename "${d}" } importas -ui i i - if { s6-echo -- "[supervisor/finalize] Executing finalize script: ${i}... " } foreground { s6-maximumtime -k ${IGNITY_KILL_FINALIZE_MAXTIME} /run/ignity/finalize/${i} } importas -u ? ? - s6-echo -- "[supervisor/finalize] Finalize script ${i} exited ${?}." } s6-echo -- "[supervisor/finalize] Finalize scripts executed" } diff --git a/src/usr/bin/container-discover b/src/usr/bin/container-discover deleted file mode 100755 index eec8bd5..0000000 --- a/src/usr/bin/container-discover +++ /dev/null @@ -1,110 +0,0 @@ -#!/usr/bin/env bash - -# Found current script directory -readonly RELATIVE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" - -######################################## -# Compute smallest value that is greater than or equal to the argument. -# Arguments: -# Number to ceil. -# Outputs: -# Result of computation. -######################################## -function math::ceiling() { - awk -vnumber="$1" -vdiv="$2" ' - function ceiling(x){ - return x%1 ? int(x)+1 : x - } - BEGIN{ - print ceiling(number/div) - } - ' -} - -######################################## -# Discover cpu limit based on the cgroup limits. -# Figure out the max number of core we should utilize. -# Globals: -# CONTAINER_CPU_LIMIT -# Arguments: -# None. -# Outputs: -# Cpu limit discovered. -######################################## -function discover_cpu_limit() { - # Manually defined - if [[ "${CONTAINER_CPU_LIMIT}" ]]; then - echo "${CONTAINER_CPU_LIMIT}" - return 0 - fi - - # Read cgroups limit - local cpu_period_file=${SYS_CPU_PERIOD_FILE:-/sys/fs/cgroup/cpu/cpu.cfs_period_us} - local cpu_quota_file=${SYS_CPU_QUOTA_FILE:-/sys/fs/cgroup/cpu/cpu.cfs_quota_us} - local cpu_period cpu_quota - - # cfs_quota_us == -1 --> no restrictions - if { cpu_period=$(cat "$cpu_period_file") && \ - cpu_quota=$(cat "$cpu_quota_file") && \ - [[ "$cpu_quota" != -1 ]] ;} 2>/dev/null ; then - math::ceiling "$cpu_quota" "$cpu_period" - else - nproc - fi -} - -######################################## -# Discover mem limit based on the cgroup limits. -# Figure out the max number of ram we should utilize. -# Globals: -# CONTAINER_MEM_LIMIT -# Arguments: -# None. -# Outputs: -# Mem limit discovered. -######################################## -function discover_mem_limit() { - # Manually defined - if [[ "${CONTAINER_MEM_LIMIT}" ]]; then - echo "${CONTAINER_MEM_LIMIT}" - return 0 - fi - - # Max memory of host - local mem_limit - mem_limit="$(awk '/MemTotal/ {printf "%.0f", $2*1024}' /proc/meminfo)" - - # Read cgroups limit - local max_mem_unbounded_file=${SYS_MAX_MEM_UNBOUNDED_FILE:-/sys/fs/cgroup/memory/memory.memsw.limit_in_bytes} - local mem_file=${SYS_MEM_FILE:-/sys/fs/cgroup/memory/memory.limit_in_bytes} - local max_mem max_mem_unbounded - - # High number which is the max limit until which memory is supposed to be unbounded. - if { max_mem=$(cat "$mem_file") && \ - max_mem_unbounded=$(cat "$max_mem_unbounded_file") && \ - [[ "$max_mem" -le "$max_mem_unbounded" ]] ;} 2>/dev/null ; then - echo "$max_mem" - else - echo "$mem_limit" - fi -} - -######################################## -# Discover limits based on the cgroup limits. -# Globals: -# CONTAINER_CPU_LIMIT -# CONTAINER_MEM_LIMIT -# Arguments: -# None. -######################################## -function main() { - local container_cpu_limit=$(discover_cpu_limit) - echo "${container_cpu_limit}" > /run/ignity/envs/CONTAINER_CPU_LIMIT - echo "Container cpu limit: ${container_cpu_limit}" - - local container_mem_limit=$(discover_mem_limit) - echo "${container_mem_limit}" > /run/ignity/envs/CONTAINER_MEM_LIMIT - echo "Container mem limit: ${container_mem_limit}" -} - -main diff --git a/src/usr/bin/preboot b/src/usr/bin/preboot index c357d81..51ed6d2 100755 --- a/src/usr/bin/preboot +++ b/src/usr/bin/preboot @@ -33,10 +33,8 @@ if { importas -ui d d backtick -n i { s6-basename "${d}" } importas -ui i i - if { s6-echo -- "[supervisor/perm] Applying ownership & permission fixes: ${i}... " } foreground { redirfd -r 0 /etc/ignity/perms/${i} fix-perms } importas -u ? ? - if { s6-echo -- "[supervisor/perm] Ownership & permission fixes ${i} exited ${?}." } exit ${?} } if { s6-echo -- "[supervisor/perm] Ownership & permissions fixes applied" } diff --git a/src/usr/src/install-ignity.sh b/src/usr/src/install-ignity.sh index dfdbd93..a0e9c7a 100644 --- a/src/usr/src/install-ignity.sh +++ b/src/usr/src/install-ignity.sh @@ -9,10 +9,10 @@ readonly SKALIBS_URL="https://github.com/skarnet/skalibs.git" readonly EXECLINE_URL="https://github.com/skarnet/execline.git" readonly S6_URL="https://github.com/skarnet/s6.git" readonly S6_PORTABLE_UTILS_URL="https://github.com/skarnet/s6-portable-utils.git" -readonly SKALIBS_VERSION="2.14.3.0" -readonly EXECLINE_VERSION="2.9.6.1" -readonly S6_VERSION="2.13.1.0" -readonly S6_PORTABLE_UTILS_VERSION="2.3.0.4" +readonly SKALIBS_VERSION="2.14.4.0" +readonly EXECLINE_VERSION="2.9.7.0" +readonly S6_VERSION="2.13.2.0" +readonly S6_PORTABLE_UTILS_VERSION="2.3.1.0" BUILD_DEPENDENCIES="ca-certificates build-essential git" # Fine tuning diff --git a/tests/boot/tests.bats b/tests/boot/tests.bats index 2291873..c0ac066 100644 --- a/tests/boot/tests.bats +++ b/tests/boot/tests.bats @@ -10,11 +10,6 @@ export DOCKER_ARGS="-e IGNITY_KILL_GRACETIME=0 -e IGNITY_KILL_FINALIZE_MAXTIME=0 [ "$?" -eq 0 ] } -@test "check container-discover is installed" { - echo 'command -v container-discover' | podman::run - [ "$?" -eq 0 ] -} - @test "check fix-perms is installed" { echo 'command -v fix-perms' | podman::run [ "$?" -eq 0 ]