fix(install): robust kernel-version parser in AF_XDP runtime probe#86
Conversation
probe_afxdp_runtime_available reported "kernel <5.10 or libxdp.so missing" on c6in.metal Debian 13 + kernel 6.12.74 even though both prerequisites were satisfied. The previous parameter-expansion parser silently mishandled some 3-component release shapes; the failure mode reported in PR #65 issuecomment-4339242358 (anygpt-52) was a generic "false" with no indication of which check fired, leaving the operator to guess. Fix: - New parse_kernel_major_minor() helper uses awk -F'[.-]' so 3- component releases like 6.12.74-cloud-amd64, 5.10.0-13-amd64, 6.12.74+deb13+1-amd64, and 5.4.282-rt all parse cleanly. Returns "MAJOR MINOR" on stdout, "0 0" on parse failure. - probe_afxdp_runtime_available emits a one-line stderr explanation whenever it returns "false" so the operator can immediately see which check fired ("kernel 4.19 < 5.10", "libxdp.so not in ldconfig -p", "could not parse kernel version"). Quiet on success. - apply_afxdp_availability captures the probe stderr and includes the reason in its summary log line — replaces the previous hardcoded "kernel <5.10 or libxdp.so missing" that was wrong half the time. - ANYSCAN_INSTALL_LOAD_ONLY=1 hook lets unit tests source the script for hermetic helper testing without triggering main(). Test (new tools/test-install-worker-bundle-afxdp-probe.sh, 21 cases): - parse_kernel_major_minor across 8 release shapes (clean 3-component, +deb13 suffix, -cloud-amd64 suffix, -rt suffix, 4.x, 2-component, 1-component, empty). - probe_afxdp_runtime_available with stubbed uname + ldconfig: c6in.metal 6.12.74 + libxdp → true (the bug 5 repro). Kernel 4.19 too old → false + stderr names the version. Kernel 5.9 vs 5.10 vs 5.11 boundary correctness. libxdp.so missing → false + stderr names the missing library. Empty/non-numeric uname → false + stderr names parse failure. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d2cffa8eb4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if [ "${ANYSCAN_INSTALL_LOAD_ONLY:-0}" = "1" ]; then | ||
| return 0 2>/dev/null || exit 0 |
There was a problem hiding this comment.
Restrict test load-only hook to sourced usage
ANYSCAN_INSTALL_LOAD_ONLY=1 now causes the installer to return/exit before main even when the script is executed normally, so a leaked environment variable (for example from a parent shell, CI job, or service environment) turns installation/update into a silent no-op with exit code 0. This hook should only short-circuit when the file is being sourced for tests, otherwise production invocations can skip all install steps.
Useful? React with 👍 / 👎.
Summary
probe_afxdp_runtime_availablereported "kernel <5.10 or libxdp.so missing" on c6in.metal Debian 13 + kernel 6.12.74 even though both prerequisites were satisfied. The previous parameter-expansion parser silently mishandled some 3-component release shapes (e.g.6.12.74+deb13+1-amd64); the failure mode reported in PR #65 issuecomment-4339242358 (anygpt-52) was a genericfalsewith no indication of which check fired, leaving the operator to guess.Fix
parse_kernel_major_minor()usesawk -F'[.-]'so 3-component releases like6.12.74-cloud-amd64,5.10.0-13-amd64,6.12.74+deb13+1-amd64, and5.4.282-rtall parse cleanly. Returns"MAJOR MINOR"on stdout;"0 0"on parse failure.probe_afxdp_runtime_availableemits a one-line stderr explanation whenever it returnsfalseso operators can see which check fired ("kernel 4.19 < 5.10","libxdp.so not in ldconfig -p","could not parse kernel version"). Quiet on success.apply_afxdp_availabilitycaptures the probe stderr and includes the reason in its summary log — replaces the hardcoded "kernel <5.10 or libxdp.so missing" line that was wrong half the time.ANYSCAN_INSTALL_LOAD_ONLY=1hook lets the unit test source the script without triggeringmain().Test plan
bash tools/test-install-worker-bundle-afxdp-probe.sh— 21/21 passbash tools/test-install-worker-bundle-eni-discovery.sh— existing test still green (regression check)parse_kernel_major_minoracross 8 release shapes (clean 3-component, +deb13, -cloud-amd64, -rt, 4.x, 2-component, 1-component, empty)probe_afxdp_runtime_availablewith stubbed uname + ldconfig: c6in.metal 6.12.74 + libxdp →true(the bug 5 repro)false+ stderr names the missing libraryfalse+ stderr names parse failure🤖 Generated with Claude Code