Repository navigation
Conversation
This was referenced Sep 26, 2026
kubelet: cAdvisor GetVfsStats data race in a race-enabled DRA presubmit
kubernetes/kubernetes#142439
Open
thc1006
force-pushed
the
vfs-stats-timeout-race
branch
from
September 26, 2026 15:52
92e3dfb to
21ad720
Compare
GetVfsStats assigns its named results from the goroutine that calls statfs, and the timeout branch writes the same variables on its way out. When the timeout path returns without receiving the worker's result, those writes are not synchronized. The Kubernetes kubelet, built with -race, reports this as six write/write races at stats.go:59 whenever the timeout path is taken before the worker has finished. Fill a local result in the goroutine and send only that over the channel. Make the syscall and the timeout package variables so that tests can stub statfs with known values and run the timeout case under testing/synctest, where the worker finishes after the caller has returned without depending on wall-clock scheduling. Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
thc1006
force-pushed
the
vfs-stats-timeout-race
branch
from
September 26, 2026 16:00
21ad720 to
8162e14
Compare
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.
GetVfsStatsrunsstatfsin a goroutine and gives up after two seconds. The goroutine assigns the function's named results, and the timeout branch writes zero values into the same variables on its way out. When the timeout path returns without receiving the worker's result, those writes are not synchronized.Kubernetes runs its kubelet with the race detector in the
pull-kubernetes-kind-dra-alljob, and that job has reported it in eight runs between September 21 and 26 as write/write races betweenstats.go:59and the goroutine's assignments, one per result, most recently in this run withlib v0.60.6.The goroutine now fills a local
resultand hands it over on the channel. It no longer touches the caller's variables.The syscall and the timeout become package variables. The tests stub
statfswith known values, and the timeout case runs undertesting/synctestwith fake time, where the worker finishes after the caller has returned and must exit without touching the results. That test fails with-raceon the current code and passes with this change. The normal path is unchanged, including the zero values that come back together with astatfserror.A hung
statfsstill blocks its goroutine until the syscall returns, as before. This change removes the race, not that.This PR was written in part with the assistance of generative AI.
Fixes #3937.