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

overlay, mount: add support for non-volatile upperdir, workdir for overlay volumes #3715

Merged
merged 3 commits into from Jan 21, 2022

Conversation

flouthoc
Copy link
Collaborator

@flouthoc flouthoc commented Jan 17, 2022

Expose MountWithOptions for overlay which allows users to pass more
verbose configuration for overlay mounts.

For instance upperdir, workerdir and in future volatile.

Allow users to specify non-volatile upper and workdir with overlay
mounts.

Usage

buildah from alpine
buildah run -v /something/lower:/test:z,O,upperdir=/somewhere/upperdir,workdir=/somwhere/workdir alpine-working-container cat /test/hello

Needed for: containers/podman#12712

@flouthoc
Copy link
Collaborator Author

pkg/overlay/overlay.go Outdated Show resolved Hide resolved
pkg/overlay/overlay.go Show resolved Hide resolved
pkg/overlay/overlay.go Outdated Show resolved Hide resolved
@nalind
Copy link
Member

nalind commented Jan 17, 2022

Please elaborate on the use case, and add tests.

Copy link
Collaborator

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

Warning: I know nothing about overlay (I don’t think I have ever manually mounted one) except what I just read in the documentation, and I know even less about how c/storage uses it.

Comment on lines 69 to 81
// MountWithOptions creates a subdir of the contentDir based on the source directory
// from the source system. It then mounts up the source directory on to the
// generated mount point and returns the mount point to the caller.
// But allows api to set custom workdir, upperdir and other overlay options
Copy link
Collaborator

Choose a reason for hiding this comment

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

FWIW – this is preexisting, and maybe I’m just ignorant. This documentation, even with the context of the overlay section of mount(8), is completely unintelligible to me. I have no idea how source/contentDir relate.

(Reading the code, apparently contentDir has a specific structure that’s not documented in this package.)

The other options are also undocumented.

Copy link
Collaborator

Choose a reason for hiding this comment

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

… and the behavior of readonly, affecting whether $contentDir/lower is used, is completely non-obvious to me as a newcomer to the code.

pkg/overlay/overlay.go Outdated Show resolved Hide resolved
pkg/overlay/overlay.go Outdated Show resolved Hide resolved
pkg/overlay/overlay.go Outdated Show resolved Hide resolved
pkg/overlay/overlay.go Show resolved Hide resolved
@flouthoc flouthoc force-pushed the overlay-extend-api branch 3 times, most recently from b4364a9 to d4d3cda Compare January 18, 2022 12:06
pkg/overlay/overlay.go Outdated Show resolved Hide resolved
pkg/overlay/overlay.go Show resolved Hide resolved
pkg/overlay/overlay.go Outdated Show resolved Hide resolved
pkg/overlay/overlay.go Show resolved Hide resolved
pkg/overlay/overlay.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@mtrmac mtrmac 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, just documentation nits.


[NO NEW TESTS NEEDED]

Is this appropriate here?

@flouthoc
Copy link
Collaborator Author

Code LGTM, just documentation nits.

[NO NEW TESTS NEEDED]

Is this appropriate here?

Updated Docs.

Please elaborate on the use case, and add tests.

@nalind @mtrmac Following API is only used by podman and its much easier to test there -> containers/podman#12712 . We don't have flat tests for overlay in buildah hence i'm not entirely sure how to rig a test for this on buildah repo.

But if it does not breaks any existing buildah tests then should this be fine ?

@TomSweeneyRedHat
Copy link
Member

Changes LGTM
Would like a final head nod from @nalind and @mtrmac , especially given the test status

@flouthoc
Copy link
Collaborator Author

flouthoc commented Jan 20, 2022

@TomSweeneyRedHat I am also extending feature to buildah so we can test here as well.

Edit: @nalind @mtrmac extended buildah to support this feature to buildah as well and added a test for this.

@flouthoc flouthoc changed the title overlay: add MountWithOptions to API which extends support for advanced overlay users. overlay, mount: add support for non-volatile upperdir, workdir for overlay volumes Jan 20, 2022
…ed overlay

Expose `MountWithOptions` for overlay which allows users to pass more
verbose configuration for overlay mounts.

For instance `upperdir, workerdir` and in future `volatile`.

Signed-off-by: Aditya R <arajan@redhat.com>
@flouthoc flouthoc force-pushed the overlay-extend-api branch 3 times, most recently from 440ee51 to 57b01d4 Compare January 20, 2022 09:34
Copy link
Collaborator

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

Thanks for the tests!

Note that I’m just reading the diff.. I don’t know anything about the testing infrastructure, and I’ll defer to repo owners on the introduced UI.

run_linux.go Outdated Show resolved Hide resolved
run_linux.go Outdated Show resolved Hide resolved
run_linux.go Outdated Show resolved Hide resolved
Copy link
Member

@nalind nalind left a comment

Choose a reason for hiding this comment

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

Code looks reasonable. Some nits about field names and some typos.

run_linux.go Outdated Show resolved Hide resolved
run_linux.go Outdated Show resolved Hide resolved
run_linux.go Outdated Show resolved Hide resolved
tests/run.bats Outdated Show resolved Hide resolved
tests/run.bats Outdated Show resolved Hide resolved
pkg/overlay/overlay.go Outdated Show resolved Hide resolved
pkg/overlay/overlay.go Outdated Show resolved Hide resolved
pkg/overlay/overlay.go Outdated Show resolved Hide resolved
// See discussion here for more context: https://github.com/containers/buildah/pull/3715#discussion_r786036959
// TODO: Should we address above comment and handle escaping of metacharacters like
// `comma`, `backslash` ,`colon` and any other specical characters
UpperDirOptionFragment string
Copy link
Member

Choose a reason for hiding this comment

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

Nit: the OptionFragment suffix sounds redundant.
Should probably note that if this field is set, WorkDirOptionFragment should also be set.

Copy link
Collaborator Author

@flouthoc flouthoc Jan 20, 2022

Choose a reason for hiding this comment

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

@nalind I decided to name both of them as fragment as they are still just fragments to overlay's options as discussed here #3715 (comment) . I named both of them in same manner as it describes the similar nature of field to the reader of the API

Copy link
Collaborator

Choose a reason for hiding this comment

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

@nalind See that discussion, but I’m completely happy to leave naming/API design to you.

// See discussion here for more context: https://github.com/containers/buildah/pull/3715#discussion_r786036959
// TODO: Should we address above comment and handle escaping of metacharacters like
// `comma`, `backslash` ,`colon` and any other specical characters
WorkDirOptionFragment string
Copy link
Member

Choose a reason for hiding this comment

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

Nit: the OptionFragment suffix sounds redundant. Should probably note that if this field is set, UpperDirOptionFragment should also be set.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Reasoning for this is same as #3715 (comment)

Allow users to specify non-volatile `upper` and `workdir` with overlay
mounts.

Usage

```console
buildah from alpine
buildah run -v /something/lower:/test:z,O,upperdir=/somewhere/upperdir,workdir=/somwhere/workdir alpine-working-container cat /test/hello
```

Signed-off-by: Aditya R <arajan@redhat.com>
Signed-off-by: Aditya R <arajan@redhat.com>
@rhatdan
Copy link
Member

rhatdan commented Jan 21, 2022

/approve
/lgtm

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 21, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: flouthoc, 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 b6f6306 into containers:main Jan 21, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants