← Back to Pull requests

Add support for sharing=private cache mounts #7127

Closed
unknown closed this pull request without merging on Oct 01, 2026 22:57 UTC
View on GitHub
unknown unknown commented on Sep 21, 2026 20:35 UTC
Author

<!--
Thanks for sending a pull request!

Please make sure you've read and understood our contributing guidelines
(https://github.com/containers/buildah/blob/main/CONTRIBUTING.md) as well as ensuring
that all your commits are signed with git commit -s.
-->

What type of PR is this?

/kind feature

What this PR does / why we need it:

We reject sharing=private on cache mounts, so building Containerfiles fails on an option BuildKit has supported for a long time:

Error: unrecognized value "private" for field `sharing`: %!w(<nil>)

A cache can now have more than one directory. A sharing=private mount takes one that nothing else is holding, creates another only when they are all busy, and keeps it locked until the command it is mounted for finishes. Directories are reused once they are free, so the count settles at how many commands use that cache at the same time. sharing=shared and sharing=locked are unchanged.

How to verify it

Unit, integration, and conformance tests are added:

go test -v ./internal/volumes/ -run 'TestGetMount|TestGetCacheMountSharing'
bats tests/run.bats -f 'type=cache'
go test -v ./tests/conformance -run 'TestConformance/mount-cache'

Also manually, start one of these and then run a second while it sleeps. The second one will get its own private directory named [hash]-1:

buildah run --mount type=cache,target=/cache,sharing=private $ctr sh -c 'ls -A /cache; touch /cache/mine; sleep 30'

/var/tmp/buildah-cache-502/
├── buildah-cache-lockfiles
│   ├── d23ea00874c48053
│   │   ├── buildah-cache-lockfile
│   │   └── buildah-cache-pool-lockfile
│   └── d23ea00874c48053-1
│       └── buildah-cache-lockfile
├── d23ea00874c48053
│   └── mine
└── d23ea00874c48053-1
    └── mine

Which issue(s) this PR fixes:


<!--
Automatically closes linked issue when PR is merged.
Uncomment the following comment block and include the issue
number or None on one line.
Usage: Fixes #<issue number>, or Fixes (paste link of issue), or None.
-->
Fixes https://github.com/podman-container-tools/podman/issues/27188
Part of https://github.com/podman-container-tools/buildah/issues/6732

<!--
Fixes #
or
None
-->

Special notes for your reviewer:

Noting one pre-existing difference from BuildKit, since it carries over to sharing=private as well: sharing=shared takes no lock in buildah, so a shared mount can use the same directory as a sharing=locked command running at the same time. BuildKit's locked waits for shared usages as well.

Aligning with BuildKit would mean shared taking a read lock, which changes the default sharing mode for cache mounts and might be risky. That seemed better as its own PR if we want to address it.

Does this PR introduce a user-facing change?

``release-note
Cache mounts now accept sharing=private, which gives the command a cache directory that nothing else is using
``

Diff: 375 lines (+281 / -94) across 4 files Reviewer: ajoshua2004 Review duration: 14541m
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 375 lines diff across 4 files
0.43
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
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
Diff Size diff_size
0.355
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #7127"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% 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: 42.9% (MEDIUM) · Higher = larger blast radius
42.9%
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: 60.5% · Lower = rushed or shallow review
60.5%
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: 16.9% · Safe to merge
16.9%