rootless: fix getCurrentOOMScoreAdj (fix rootless docker in kubernetes)#42189
rootless: fix getCurrentOOMScoreAdj (fix rootless docker in kubernetes)#42189tiborvass merged 1 commit intomoby:masterfrom
Conversation
thaJeztah
left a comment
There was a problem hiding this comment.
Wondering; if the issue is that we're trying to set an OOM score that's out of range; should we check limits in toRootless, and clip to max / min (-1000 .... 1000)?
moby/rootless/specconv/specconv_linux.go
Lines 70 to 72 in 46cdcd2
There was a problem hiding this comment.
Do we know under what circumstances this fails? Would it be an os.IsNotExist()? (in that case, should we just ignore?)
There was a problem hiding this comment.
Should we log the value before trimming? (also simplifies the code a bit)
| s := string(b) | |
| i, err := strconv.Atoi(strings.TrimSpace(s)) | |
| if err != nil { | |
| logrus.WithError(err).Warn("failed to parse /proc/self/oom_score_adj (%q)", s) | |
| i, err := strconv.Atoi(strings.TrimSpace(string(b))) | |
| if err != nil { | |
| logrus.WithError(err).Warn("failed to parse /proc/self/oom_score_adj (%q)", b) |
There was a problem hiding this comment.
Already logging untrimmed string
There was a problem hiding this comment.
oh! 🤦 yes, it's just the extra variable to convert []byte to string
|
No, not out of range. Docker always attempts to launch a container with oomScoreAdj=0, but the daemon's oomScoreAdj is set to 1000 by Kube, so we need to adjust the oomScoreAdj of the container being created from 0 to 1000. |
`getCurrentOOMScoreAdj()` was broken because `strconv.Atoi()` was called without trimming "\n". Fix issue 40068: `rootless docker in kubernetes: "getting the final child's pid from pipe caused \"EOF\": unknown" Signed-off-by: Akihiro Suda <[email protected]>
da44f09 to
d6ddfb6
Compare
I recall changing the daemon itself to not adjust if no custom oom-score is set (#41527); in this case, the daemon runs inside a container with an OOM-score "X", but the daemon itself does not have an |
|
I think that's possible by changing moby/api/types/container/host_config.go Line 415 in dea989e But that doesn't work with existing client implementations. So I suggest merging this PR, and looking into possibility of the API change in a separate PR. |
Yes, we can fix that in a follow-up; I went looking for the original commit that added |
|
@cpuguy83 PTAL |
- What I did
Fix #40068:
rootless docker in kubernetes: "getting the final child's pid from pipe caused \"EOF\": unknown"- How I did it
Fixed
getCurrentOOMScoreAdj()to trim "\n" before callingstrconv.Atoi.- How to verify it
rootless.yaml:- Description for the changelog
Fix `rootless docker in kubernetes: "getting the final child's pid from pipe caused "EOF": unknown"
- A picture of a cute animal (not mandatory but encouraged)
🐧