Repository navigation
fix(envd): run the command when oom_score_adj cannot be set - #3820
Open
luyuzhe111 wants to merge 1 commit into
Open
luyuzhe111 wants to merge 1 commit into
luyuzhe111 wants to merge 1 commit into
Conversation
The process wrapper chained exec to the oom_score_adj write with &&. Lowering oom_score_adj needs CAP_SYS_RESOURCE, so in a container that starts above 100 without that capability every write fails with EACCES (dash: "echo: I/O error") and no command can run. Make the write best effort, like the ionice/nice helpers, and keep its error off the user's stderr.
luyuzhe111
requested review from
ValentaTomas,
dobrac and
jakubno
as code owners
November 12, 2026 09:18
|
We require contributors to sign our Contributor License Agreement, and we don't have @luyuzhe111 on file. You can sign our CLA at https://e2b.dev/docs/cla . Once you've signed, post a comment here that says '@cla-bot check' |
Author
|
@cla-bot check |
|
The cla-bot has been summoned, and re-checked this pull request! |
This branch has not been deployed
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.
Summary
envd wraps every process in
/bin/sh -c 'echo 100 > /proc/$$/oom_score_adj && exec ... "$@"'. Loweringoom_score_adjbelow its current value needsCAP_SYS_RESOURCE. So in a container that starts with a score above 100 and has noCAP_SYS_RESOURCE, the write fails withEACCES(dash prints--: 1: echo: echo: I/O error), the&&skips theexec, and no command can run at all.We hit this running envd in Amazon Bedrock AgentCore Runtime containers. There, one platform generation starts the container at
oom_score_adj1000 withCapBnd: 00000000a82425fb(noCAP_SYS_RESOURCE), so every write below 1000 is refused, even as root. The other generation starts at -998, and envd works there.This PR makes the write best effort, like the
ionice/nicehelpers in the same wrapper:Where the write succeeds (Firecracker, or any container that is allowed to set 100), behavior is unchanged. Where it is refused, the command runs with the score it inherited from envd instead of failing. The
2>/dev/nullcomes before the target so that a failed open does not print to the user's stderr either.Testing
TestOomWrapperruns the wrapper through/bin/sh:nobodyso it lacksCAP_SYS_RESOURCE.&&script, the second case fails with theI/O errorabove.debian:bookworm-slim(dash) andalpine:3.20(busybox ash), each in five setups: as root with default capabilities, withCAP_SYS_RESOURCE, withCAP_SYS_RESOURCEand--oom-score-adj -998, and with--oom-score-adj 1000and noCAP_SYS_RESOURCE; and asnobodywith--oom-score-adj 1000.go test -race ./internal/services/process/...,go vet, andgolangci-lint run/fmtall pass.