fix(tools-image): fall back to BusyBox ionice for minimal user images - #210
Open
dushulin wants to merge 1 commit into
Open
fix(tools-image): fall back to BusyBox ionice for minimal user images#210dushulin wants to merge 1 commit into
dushulin wants to merge 1 commit into
Conversation
envd's process wrapper hardcodes `/usr/bin/ionice -c 2 -n 4 /usr/bin/nice -n N ...`, so any user image without util-linux (Alpine/musl, distroless, FROM scratch, various slim rootfs) fails every spawn with `/usr/bin/ionice: not found` even though envd itself launches fine. Mirror the existing nice(1) fallback: when the user rootfs has no executable /usr/bin/ionice, symlink it to /agentenv/bin/busybox so the multi-call binary serves the applet. Images that already ship util-linux keep their real ionice(1) thanks to the [ ! -x ] guard. Also assert both nice and ionice applets are compiled into the shipped BusyBox at image build time. BusyBox ionice supports the -c/-n/-p/-t flags envd relies on (both call the same ioprio_set(2) syscall); the util-linux-only -P/-u flags are not used by envd.
Contributor
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 2 selected item(s). |
Collaborator
|
Thanks! We'll merge this PR once support for the tools image upgrade has been added. Otherwise, existing templates/snapshots will fail to resume. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
envd 的进程 wrapper 硬编码调用
/usr/bin/ionice -c 2 -n 4 /usr/bin/nice -n N ...(packages/envd/internal/services/process/handler/handler.go),只要用户 rootfs 里没有/usr/bin/ionice,每一次进程 spawn 都会立刻失败并报/usr/bin/ionice: not found。这在 Alpine/musl、distroless、FROM scratch、以及各类不带 util-linux 的 slim 镜像上都能稳定复现——envd 自身能起来,用户在 sandbox 里跑任何命令都会立刻挂掉。相关上游 issue / PR:
/usr/bin/ionice和/usr/bin/nice方案
复用现有
nice(1)兜底思路(tools-image/pivot-init):/usr/bin/ionice,就把它软链到/agentenv/bin/busybox。BusyBox 是 multi-call binary,通过argv[0]=ionice直接走ioniceapplet。[ ! -x /usr/bin/ionice ]guard 保证自带 util-linux 的镜像原样保留自己的ionice,不会被覆盖。nice/ionice。nice+ionice),万一以后 upstream BusyBox 改默认配置或有人重编 BusyBox,能在镜像构建阶段就报错,不至于到 guest 里才发现。与 util-linux ionice 的能力对齐
envd 调用的形式是
ionice -c 2 -n 4 <cmd>,用到的是-c/-n以及 exec 新进程的能力。BusyBox 的 ionice applet 覆盖-c/-n/-p/-t与 exec 语义,与 util-linux 落到同一个ioprio_set(2)syscall,语义完全一致。util-linux 独有的-P PGID、-u UIDenvd 用不到;如果 sandbox 内部用户脚本自己在 fallback 镜像里手动调这两个 flag 会拿到 unknown option,这跟现有nicefallback 面临的情况完全对称。兼容性
[ ! -x ]guard 短路,/usr/bin/ionice保留镜像原有实现,零回退。Test plan
docker build tools-image/通过,BusyBox applet 断言不报错ionice -c 2 -n 4 echo ok通过 envd wrapper 能正常输出okreadlink /usr/bin/ionice仍指向镜像原有二进制(不是/agentenv/bin/busybox)echo $?返回 0