-
Notifications
You must be signed in to change notification settings - Fork 0
fix(k3s): keep reserve setup best effort #2127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,10 +35,11 @@ require_sudo() { | |
| echo "Warning: sudo not found, skipping k3s system setup" >&2 | ||
| return 1 | ||
| fi | ||
| return 0 | ||
| } | ||
|
|
||
| configure_root_ext4_reserve() { | ||
| local root_source root_fs_type block_count reserved_blocks target_reserved_blocks | ||
| local root_source root_fs_type filesystem_info block_count reserved_blocks target_reserved_blocks | ||
| local target_reserved_percent=1 | ||
|
|
||
| root_source="$(@findmnt@ --noheadings --output SOURCE --target /)" | ||
|
|
@@ -53,10 +54,14 @@ configure_root_ext4_reserve() { | |
| fi | ||
|
|
||
| require_sudo || return 0 | ||
| if ! filesystem_info="$(run_sudo @tune2fs@ -l "$root_source")"; then | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3: The new best-effort behavior is unverified: a future change could make an inspection or mutation failure abort activation again without CI detecting it. A focused shellspec fixture that stubs Prompt for AI agents |
||
| echo "Warning: unable to inspect ext4 reserve on $root_source" >&2 | ||
| return 0 | ||
| fi | ||
| # shellcheck disable=SC2016 | ||
| block_count="$(run_sudo @tune2fs@ -l "$root_source" 2>/dev/null | @awk@ -F: '/^Block count:/ { gsub(/[[:space:]]/, "", $2); print $2 }')" | ||
| block_count="$(@awk@ -F: '/^Block count:/ { gsub(/[[:space:]]/, "", $2); print $2 }' <<<"$filesystem_info")" | ||
| # shellcheck disable=SC2016 | ||
| reserved_blocks="$(run_sudo @tune2fs@ -l "$root_source" 2>/dev/null | @awk@ -F: '/^Reserved block count:/ { gsub(/[[:space:]]/, "", $2); print $2 }')" | ||
| reserved_blocks="$(@awk@ -F: '/^Reserved block count:/ { gsub(/[[:space:]]/, "", $2); print $2 }' <<<"$filesystem_info")" | ||
| if [ -z "$block_count" ] || [ -z "$reserved_blocks" ]; then | ||
| echo "Warning: unable to inspect ext4 reserve on $root_source" >&2 | ||
| return 0 | ||
|
|
@@ -67,7 +72,10 @@ configure_root_ext4_reserve() { | |
| return 0 | ||
| fi | ||
|
|
||
| run_sudo @tune2fs@ -m "$target_reserved_percent" "$root_source" | ||
| if ! run_sudo @tune2fs@ -m "$target_reserved_percent" "$root_source"; then | ||
| echo "Warning: unable to configure ext4 reserve on $root_source" >&2 | ||
| return 0 | ||
| fi | ||
| echo "Configured $root_source ext4 reserved blocks to ${target_reserved_percent}%" | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a critical bug in the
require_sudofunction (defined on lines 33-38) that prevents this entire block (and other sudo-dependent parts of the script) from executing whensudois available.In Bash, if a function does not end with an explicit
returnstatement, its exit status is that of the last command executed. Inrequire_sudo:When
sudois available, theifcondition[ "${#sudo_cmd[@]}" -eq 0 ]evaluates to false (exit status1), the body is skipped, and the function exits. Since the[test was the last command executed, the function returns1.As a result,
require_sudo || return 0on line 55 will always evaluate to true and return early, skipping the filesystem inspection entirely. Similarly,require_sudo || exit 0on lines 84 and 92 will cause the script to exit prematurely.To fix this, please add an explicit
return 0at the end ofrequire_sudo.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 83bfbfb with an explicit success return and a focused regression assertion; the native Kyber activation-package build also succeeds.