cri: refuse to overwrite an existing checkpoint archive #13988
All Vouch review confidence checks passed
Residual risk 0.26 = Change Risk (0.47) × (1 − Review Confidence (0.45)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.47 · 288 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.339
Real PR Conversation Timeline
1 comments
"Review active on #13988"
general
weight: 0.35
0xff-dev
What this PR does
CheckpointContaineropens the caller-suppliedr.LocationwithO_RDWR|O_CREATEand streams the tarball into it, so an existing file isoverwritten in place rather than replaced. When the file that was already there
is larger, its tail survives past the end of the new archive.
Nothing reports this. Both GNU tar and
archive/tarstop at the end-of-archivemarker, so the export reads back as a valid checkpoint — it extracts to exactly
the right content, with matching checksums — while silently carrying the tail of
whatever was there before. The only visible symptom is that the file never
shrinks:
What changed
Refuse rather than overwrite, per review feedback. The kubelet derives a unique
name for every checkpoint request, so a name that is already taken means either
a caller reusing a path or two requests racing for the same one, and in both
cases destroying an archive that is still wanted is worse than failing the
request.
O_WRONLY|O_CREATE|O_EXCL.the remains of the attempt that failed.
Behaviour change
Direct CRI callers that reuse a fixed export path now get an error instead of a
silent overwrite. The kubelet is unaffected since it derives a unique name per
request, and
contrib/checkpoint/checkpoint-restore-cri-disable-test.shalreadydoes
rm -fbefore its one successful export, so it keeps passing. Worthkeeping in mind for the 2.2/2.1 backports.
Tests
TestWriteCheckpointArchive— writes to a fresh location, mode0600.TestWriteCheckpointArchiveRefusesExistingFile— an existing file is leftbyte-for-byte untouched and the error is
os.ErrExist.TestWriteCheckpointArchiveRefusesSymlink— a symlink at the destination isnot followed and its target is left untouched.
TestWriteCheckpointArchiveRemovesPartialArchive— a failed write leaves nofile behind, so the next attempt at the same location is not blocked.