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

Fix handling of working dir #7239

Merged
merged 1 commit into from
Aug 11, 2020
Merged

Conversation

rhatdan
Copy link
Member

@rhatdan rhatdan commented Aug 5, 2020

Buildah and podman build can create images without a working dir.

FROM fedora
WORKDIR /test

If you build this image with caching twice, the second time the image
will not have a working dir.

Similarly if you execute

podman run --workdir /foobar fedora

It blows up since the workingdir is not created automatically.

Finally there was duplicated code for getting the workingdir
out of an image, that this PR removes.

Signed-off-by: Daniel J Walsh [email protected]

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 5, 2020
@TomSweeneyRedHat
Copy link
Member

LGTM
assuming happy tests

@rhatdan
Copy link
Member Author

rhatdan commented Aug 5, 2020

Fixes containers/buildah#2402

if s.WorkDir == "" {
s.WorkDir = "/"
} else {
options = append(options, libpod.WithCreateWorkingDir())
Copy link
Member

Choose a reason for hiding this comment

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

I thought we decided to only do this for entrypoint specified by the image - if the user specifies /ect accidentally we would still error on that?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok then I need to remove the test.

if newWD != "" {
options = append(options, libpod.WithCreateWorkingDir())
}
s.WorkDir = newWD
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should be modifying the specgen here - maybe in CreateContainer, not createContainerOptions?

Copy link
Member Author

Choose a reason for hiding this comment

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

The problem is WithCreateWorkingDir works off of that field. Or we have to do the check twice.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok reworked it placing the WorkDir check into CreateContainer.

@rhatdan rhatdan force-pushed the working branch 2 times, most recently from 999e81c to a35a9ed Compare August 6, 2020 10:46
@rhatdan
Copy link
Member Author

rhatdan commented Aug 6, 2020

Mitigates: containers/buildah#2475

@rhatdan
Copy link
Member Author

rhatdan commented Aug 6, 2020

@ashley-cui FYI

@rhatdan
Copy link
Member Author

rhatdan commented Aug 6, 2020

@mheon Turns out runc will create workingdir on the image, if it does not exist, while crun will not. Changed test to only run on crun systems.

@mheon
Copy link
Member

mheon commented Aug 6, 2020

Yeah, it's a lovely difference.

Buildah and podman build can create images without a working dir.

FROM fedora
WORKDIR /test

If you build this image with caching twice, the second time the image
will not have a working dir.

Similarly if you execute

podman run --workdir /foobar fedora

It blows up since the workingdir is not created automatically.

Finally there was duplicated code for getting the workingdir
out of an image, that this PR removes.

Signed-off-by: Daniel J Walsh <[email protected]>
Copy link
Member

@vrothberg vrothberg 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
Member

@giuseppe giuseppe left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 11, 2020
@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

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

@openshift-merge-robot openshift-merge-robot merged commit 68c67d2 into containers:master Aug 11, 2020
@vrothberg vrothberg mentioned this pull request Aug 11, 2020
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 24, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants