← Back to Pull requests

cri: refuse to overwrite an existing checkpoint archive #13988

Open
unknown opened this pull request with 288 lines diff across 3 files
View on GitHub
unknown unknown commented on Aug 19, 2026 15:06 UTC
Author

What this PR does

CheckpointContainer opens the caller-supplied r.Location with
O_RDWR|O_CREATE and streams the tarball into it, so an existing file is
overwritten 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/tar stop at the end-of-archive
marker, 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:

$ ls -l /tmp/test.tar          # 200M placeholder
-rw------- 200000000
$ crictl checkpoint --export=/tmp/test.tar <container>
$ ls -l /tmp/test.tar          # still 200M; the archive itself is ~40M
-rw------- 200000000

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.

  • Create the destination with O_WRONLY|O_CREATE|O_EXCL.

  • Remove the partial archive when the write fails, so a retry is not blocked by

  • 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.sh already
    does rm -f before its one successful export, so it keeps passing. Worth
    keeping in mind for the 2.2/2.1 backports.

    Tests

  • TestWriteCheckpointArchive — writes to a fresh location, mode 0600.

  • TestWriteCheckpointArchiveRefusesExistingFile — an existing file is left

  • byte-for-byte untouched and the error is os.ErrExist.
  • TestWriteCheckpointArchiveRefusesSymlink — a symlink at the destination is

  • not followed and its target is left untouched.
  • TestWriteCheckpointArchiveRemovesPartialArchive — a failed write leaves no

  • file behind, so the next attempt at the same location is not blocked.

    Diff: 288 lines (+216 / -72) across 3 files Reviewer: 0xff-dev Review duration: 75030m
    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
    0.47
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    44%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 44.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 46.8% (MEDIUM) · Higher = larger blast radius
    46.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 44.7% · Lower = rushed or shallow review
    44.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 25.9% · Safe to merge
    25.9%