Repository navigation
Conversation
ContainerEdits.Apply() calls fillMissingInfo() on the *DeviceNode pointers it was given. Cache.InjectDevices() hands it the device nodes of the cached Spec, so the host path, type, major/minor and file mode read from the host were written into the cache itself. After the first injection the cached node therefore counted as minimally specified, later injections skipped the host check and reused the stored values until the next spec refresh, and concurrent injections of the same device raced on the shared fields. Fill in the missing information on a copy of the device node and leave the cached Spec untouched. Add a regression test that injects a device backed by a FIFO, checks the cache is unchanged, replaces the host node with a regular file and expects the next injection to notice. Signed-off-by: Dean Ruina <dean.ruina@csc.fi> Signed-off-by: Dean Ruina <ruinadd@gmail.com>
DeRuina
force-pushed
the
fix-cache-mutation
branch
from
October 6, 2026 10:50
c417688 to
b4533bb
Compare
elezar
reviewed
Oct 12, 2026
Address review: the copy made before fillMissingInfo() duplicated only FileMode. UID and GID are pointers too, and toOCI() hands them to the generated OCI device, so the OCI spec still shared them with the cached Spec. Add deepCopyDeviceNode(), which copies FileMode, UID and GID, and use it in Apply(). There is no existing deep-copy helper for specs.DeviceNode to reuse. Signed-off-by: Dean Ruina <dean.ruina@csc.fi>
Author
|
@elezar The lint failure is unrelated to this change. |
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.
ContainerEdits.Apply()callsfillMissingInfo()on the*DeviceNodepointers it is given.Cache.InjectDevices()passes the device nodes of the cached Spec, so the host path, type, major/minor and file mode read from the host end up stored in the cache.Effects:
and reuse the stored values until the next spec refresh;
FileModepointers are shared between the cache and every generated OCI spec.This change fills in the missing information on a copy of the device node and leaves the cached Spec untouched. The new
TestInjectDevicesDoesNotMutateCacheinjects a FIFO-backed device, checks the cache is unchanged, replaces the host node with a regular file and expects the next injection to fail. The test fails onmainand passes with this change;go test ./...,-raceon the cache tests,go vetandgofmtare clean.Related: #322 already clones the collected edits before resolving device nodes for the new
ResolveEdits()API, for the same reason. This change covers the existingInjectDevices()path and any directApply()caller, and should rebase cleanly on either #322 or #367.