Skip to content
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

Ensure the mount type is always BindMount by default #5067

Merged

Conversation

BenjaminSchubert
Copy link
Contributor

What type of PR is this?

/kind bug

What this PR does / why we need it:

Previously, when mounting multiple mounts, if any mount had a type specified, it would override the default type for subsequent mounts.

This meant, for example, that having a RUN step like:

RUN --mount=type=cache,target=/cache --mount=source=.,target=/src

would incorrectly mount the second source as a cache, instead of a bind-mount.

This fix ensures the default is reset between each iteration of the loop, ensuring we get the right mount type.

How to verify it

Try to build the provided Dockerfile without the patch applied. This will fail, complaining that /test/input_file is a directory.

Now apply the patch and see that it correctly outputs hello.

Any variation of mounts before one not specifying type would also work.

Which issue(s) this PR fixes:

None, I can create one if required.

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Technically, this is a breaking change for users using buildah, as their mounts might change types. I am unsure what to write here, can someone please provide guidance, or update the release notes?


@openshift-ci openshift-ci bot added the kind/bug Categorizes issue or PR as related to a bug. label Sep 30, 2023
@BenjaminSchubert BenjaminSchubert changed the title bug: Ensure the mount type is always BindMount by default Ensure the mount type is always BindMount by default Sep 30, 2023

Unverified

This user has not yet uploaded their public signing key.
Previously, when mounting multiple mounts, if any mount had a `type`
specified, it would override the default type for subsequent mounts.

This meant, for example, that having a RUN step like:

```
RUN --mount=type=cache,target=/cache --mount=source=.,target=/src
```

would incorrectly mount the second source as a cache, instead of a
bind-mount.

This fix ensures the default is reset between each iteration of the
loop, ensuring we get the right mount type.

Signed-off-by: Benjamin Schubert <contact@benschubert.me>
@BenjaminSchubert BenjaminSchubert force-pushed the bschubert/fix-cache-type-default branch from 7e09fd2 to 249e30c Compare September 30, 2023 16:26
@nalind
Copy link
Member

nalind commented Oct 2, 2023

Nice catch, thanks! LGTM

@rhatdan
Copy link
Member

rhatdan commented Oct 2, 2023

/approve
/lgtm
Thanks @BenjaminSchubert

@openshift-ci openshift-ci bot added the lgtm label Oct 2, 2023
@rhatdan rhatdan merged commit 6621000 into containers:main Oct 2, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 2, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: BenjaminSchubert, 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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved label Oct 2, 2023
@BenjaminSchubert BenjaminSchubert deleted the bschubert/fix-cache-type-default branch October 2, 2023 20:05
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved kind/bug Categorizes issue or PR as related to a bug. lgtm locked - please file new issue/PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants