pkg/cdi: fix, and cleanup some locks, and use RWMutex - #345
Open
thaJeztah wants to merge 4 commits into
Open
Conversation
1 task
thaJeztah
force-pushed
the
cdi_locking_cleanups
branch
from
August 21, 2026 09:39
b2ac94e to
19a854e
Compare
2 tasks
InjectDevices only needs to hold the lock while refreshing the cache and capturing the current devices map. Release the lock before resolving devices to reduce lock contention while applying the container edits on the passed-in OCI spec. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This is a constructor, working on a freshly created `Cache`, so there should be no concurrency to account for. While updating, also set the default specDirs directly from a clone of `DefaultSpecDirs`, instead of applying through `WithSpecDirs` to avoid the extra indirect. Paths are still cleaned, to account for the `DefaultSpecDirs` being a mutable, package-level variable (but generally not recommended to update). Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Rename vars that shadowed imports, and make sure that the returned errors are properly dereferenced. Also append directory errors instead of overwriting existing errors for the same path. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
thaJeztah
force-pushed
the
cdi_locking_cleanups
branch
from
August 24, 2026 12:32
19a854e to
e2744b6
Compare
Contributor
Author
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.
pkg/cdi: reduce lock scope in InjectDevices
InjectDevices only needs to hold the lock while refreshing the cache and
capturing the current devices map. Release the lock before resolving devices
to reduce lock contention while applying the container edits on the passed-in
OCI spec.
pkg/cdi: newCache: remove redundant locking and simplify
This is a constructor, working on a freshly created
Cache, so thereshould be no concurrency to account for. While updating, also set the
default specDirs directly from a clone of
DefaultSpecDirs, instead ofapplying through
WithSpecDirsto avoid the extra indirect.Paths are still cleaned, to account for the
DefaultSpecDirsbeinga mutable, package-level variable (but generally not recommended to
update).
pkg/cdi: fix error collection in device cache
Rename vars that shadowed imports, and make sure that the returned errors
are properly dereferenced. Also append directory errors instead of overwriting
existing errors for the same path.
pkg/cdi: Cache: use RWMutex