Repository navigation
Fix: prevent data loss in OCI spec Flush() via atomic write - #2204
Open
nextjohnp7 wants to merge 1 commit into
Open
nextjohnp7 wants to merge 1 commit into
nextjohnp7 wants to merge 1 commit into
Conversation
Write modified OCI specification to a temporary file first, then atomically replace the target file after successful write. This prevents data loss if the write operation fails mid-way (disk full, I/O error, permission denied). Fixes NVIDIA#2203 Signed-off-by: John <nextjohnp7@gmail.com>
nextjohnp7
requested review from
cdesiniotis,
henry118 and
tariq1890
as code owners
November 5, 2026 17:49
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
This PR fixes a critical data loss bug in
internal/oci/spec_file.gowhere theFlush()method truncates the OCI specification file usingos.Create()before writing new content. If the write operation fails (disk full, I/O error, permission denied), the original OCI config.json is permanently destroyed.Changes
Flush()ininternal/oci/spec_file.goto write to a temporary file first, then atomically replace the target file usingos.Rename()after successful write.path/filepathimport.Testing
go build/go testcould not be executed on this machine.Related Issue
Fixes #2203
DCO
Signed-off-by: John nextjohnp7@gmail.com