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

Handle RUN --mount with relative targets and no configured workdir #5798

Merged

Conversation

nalind
Copy link
Member

@nalind nalind commented Oct 24, 2024

What type of PR is this?

/kind bug

What this PR does / why we need it:

When the target location of a RUN --mount is specified as a relative path, we normally try to convert it to an absolute path by combining it with the currently-configured working directory. If there is no such value, though, the result is still not an absolute path. Work around this by using "/" when the configured working directory is "".

Set this field in the runMountInfo struct on FreeBSD, as we already did on Linux.

How to verify it

New integration test!

Which issue(s) this PR fixes:

Fixes #5738

Special notes for your reviewer:

Does this PR introduce a user-facing change?

RUN instructions which use the --mount flag with a relative "target" path no longer trigger an error if the current stage does not have a defined working directory.

@openshift-ci openshift-ci bot added kind/bug Categorizes issue or PR as related to a bug. approved labels Oct 24, 2024
Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code LGTM but I think the test should actually check that they get mounted correctly

tests/bud.bats Outdated
echo RUN --mount=type=bind,src=Containerfile,target=Containerfile pwd >> ${TEST_SCRATCH_DIR}/Containerfile
echo RUN --mount=type=cache,target=cachesubdir pwd >> ${TEST_SCRATCH_DIR}/Containerfile
echo RUN --mount=type=tmpfs,target=tmpfssubdir pwd >> ${TEST_SCRATCH_DIR}/Containerfile
run_buildah build ${TEST_SCRATCH_DIR}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this should actually verify that these mounts are actually mounted at the proper expected target?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

openshift-ci bot commented Oct 30, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Luap99, nalind

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

@TomSweeneyRedHat
Copy link
Member

LGTM
but it looks like a rebase is needed @nalind

When the target location of a RUN --mount is specified as a relative
path, we normally try to convert it to an absolute path by combining it
with the currently-configured working directory.  If there is no such
value, though, the result is still not an absolute path.  Work around
this by using "/" when the configured working directory is "".

Set this field in the `runMountInfo` struct on FreeBSD, as we already
did on Linux.

Signed-off-by: Nalin Dahyabhai <[email protected]>
@nalind
Copy link
Member Author

nalind commented Nov 4, 2024

Rebased.

@rhatdan
Copy link
Member

rhatdan commented Nov 4, 2024

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Nov 4, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit 0787ba6 into containers:main Nov 4, 2024
31 of 32 checks passed
@nalind nalind deleted the mounts-implicit-workdir branch November 5, 2024 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved kind/bug Categorizes issue or PR as related to a bug. lgtm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

relative mountpoints when building should use / as default if no WORKDIR is provided
4 participants