-
Notifications
You must be signed in to change notification settings - Fork 787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mount,cache: internal lockfiles
must not be part of user's cache
content
#4349
mount,cache: internal lockfiles
must not be part of user's cache
content
#4349
Conversation
internal/parse/parse.go
Outdated
|
||
// create a subdirectory inside `cacheParent` just to store lockfiles | ||
buildahLockFilesDir = filepath.Join(cacheParent, buildahLockFilesDir) | ||
err = os.MkdirAll(buildahLockFilesDir, os.FileMode(0755)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this lockdir need to be shared between different users? Should it be 0700? Does it matter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rhatdan You are correct 0700
is better here.
9f87a20
to
f4b4d87
Compare
LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
internal/parse/parse.go
Outdated
@@ -33,6 +33,9 @@ const ( | |||
BuildahCacheDir = "buildah-cache" | |||
// mount=type=cache allows users to lock a cache store while its being used by another build | |||
BuildahCacheLockfile = "buildah-cache-lockfile" | |||
// All the lockfiles are stored in a seperate directory inside `BuildahCacheDir` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo in seperate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
`--mount=type=cache` must not add internal lockfiles to cache directory created by users instead store it in a different central directory with path as `/base/buildah-cache/buildah-lockfiles`. There are use-cases where users can wipe cache between the builds so lockfiles will be removed in unexpected manner and also its not okay to mix buildah's internal construct with user's cache content. Helps in: containers#4342 Signed-off-by: Aditya R <[email protected]>
Single `RUN` can contain multiple `--mount` commands so lets append into `lockedTargets` so we collect `lockfiles` from all the `--mount` instructions. Helps in: containers#4342 Signed-off-by: Aditya R <[email protected]>
f4b4d87
to
7ec6529
Compare
Use-cases as shown in below containerfile cleans cache between the builds, in previous commits we have ensured that buildah lockfiles will not be part of user's cache content hence following use-case must paas ``` FROM quay.io/centos/centos:7 ARG WIPE_CACHE RUN --mount=type=cache,target=/cache1,sharing=locked \ --mount=type=cache,target=/cache2 \ set -ex; \ ls -l /cache1; \ if [[ -v WIPE_CACHE ]]; then \ >&2 echo "Wiping cache"; \ find /cache1 -mindepth 1 -delete; \ fi; \ echo "foo" > /cache1/foo.txt; \ ls -l /cache1; \ chmod --recursive g=u /cache1; \ : ; RUN --mount=type=cache,target=/cache1,sharing=locked \ >&2 echo "Never get here" ``` Closes: containers#4342 Signed-off-by: Aditya R <[email protected]>
7ec6529
to
ffb2f27
Compare
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: flouthoc, giuseppe, rhatdan The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Following PR introduces two change
--mount=type=cache
must not add internal lockfiles to cache directorycreated by users instead store it in a different central directory with
path as
/base/buildah-cache/buildah-lockfiles
.There are use-cases where users can wipe cache between the builds so
lockfiles will be removed in unexpected manner and also its not okay to
mix buildah's internal construct with user's cache content.
run: Single
RUN
can contain multiple--mount
commands so lets append intolockedTargets
so we collectlockfiles
from all the--mount
instructions.
Tryout example
What type of PR is this?
What this PR does / why we need it:
How to verify it
Newly added
integration
test and old tests must not fail.Which issue(s) this PR fixes:
Closes: #4342
Special notes for your reviewer:
Does this PR introduce a user-facing change?