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

volume: add support for non-volatile upperdir,workdir for overlay volumes #12712

Merged

Conversation

flouthoc
Copy link
Collaborator

Often users want their overlayed volumes to be non-volatile in nature
that means that same upper dir can be re-used by one or more
containers but overall of nature of volumes still have to be overlay
so work done is still on a overlay not on the actual volume.

Following PR adds support for more advanced options i.e custom workdir
and upperdir for overlayed volumes. So that users can re-use workdir
and upperdir across new containers as well.

Usage

$ podman run -it -v myvol:/data:O,upperdir=/path/persistant/upper,workdir=/path/persistant/work alpine sh

This PR is draft till vendor is updated:

  • Vendor c/common
  • Vendor c/buidlah

Closes: #12150

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 28, 2021
@flouthoc flouthoc marked this pull request as draft December 28, 2021 10:41
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 28, 2021
@flouthoc flouthoc marked this pull request as ready for review December 28, 2021 10:41
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 28, 2021
@flouthoc
Copy link
Collaborator Author

/hold

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 28, 2021
@flouthoc
Copy link
Collaborator Author

@giuseppe @rhatdan I still need to move vendor to their respective repos apart from that this should be good for review for first pass.

@flouthoc
Copy link
Collaborator Author

I have also added a test to verify persistent nature of custom upperdir, workdir

@rhatdan
Copy link
Member

rhatdan commented Dec 28, 2021

Should this be done on the --mount option and not dirty up the --volume option?

@flouthoc
Copy link
Collaborator Author

Should this be done on the --mount option and not dirty up the --volume option?

@rhatdan That would be better but I don't think the :O construct is applicable with --mount , afaik the concept of overlay with named volumes only work with -v or --volumes as specified here https://docs.podman.io/en/latest/markdown/podman-run.1.html. In fact i don't see overlay at all with --mount in the docs.

But I'll confirm thanks.

@flouthoc flouthoc marked this pull request as draft December 28, 2021 10:55
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 28, 2021
overlayMount, err := overlay.Mount(contentDir, mountPoint, namedVol.Dest, c.RootUID(), c.RootGID(), c.runtime.store.GraphOptions())

overlayOpts = nil
if upperDir != "" && workDir != "" {
Copy link
Member

Choose a reason for hiding this comment

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

I think we need to check that either both upperdir and workdir are specified, or none of them.

We cannot have just one of upperdir or workdir

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed.

@@ -2781,6 +2803,7 @@ func (c *Container) copyTimezoneFile(zonePath string) (string, error) {
}

func (c *Container) cleanupOverlayMounts() error {
//overlay.CleanupContent("/tmp/exp-overlay")
Copy link
Member

Choose a reason for hiding this comment

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

should this be dropped?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed.

@rhatdan
Copy link
Member

rhatdan commented Jan 3, 2022

If the uppderdir and workdir are on different file systems, do you get a decent error, or should we be checking that?

@flouthoc
Copy link
Collaborator Author

flouthoc commented Jan 4, 2022

If the uppderdir and workdir are on different file systems, do you get a decent error, or should we be checking that?

@rhatdan We get an error from overlay with invalid argument. Its not very pretty but I guess it should work since its expected.

Error: OCI runtime error: runc create failed: unable to start container process: error during container init: error mounting "/home/flouthoc/.local/share/containers/storage/overlay-containers/07d4e523d4a83459c7ce4187dd2d563caf74e110a2ba1bc769cb55d095fade5e/userdata/overlay/969251762/merge" to rootfs at "/data": mount /home/flouthoc/.local/share/containers/storage/overlay-containers/07d4e523d4a83459c7ce4187dd2d563caf74e110a2ba1bc769cb55d095fade5e/userdata/overlay/969251762/merge:/data (via /proc/self/fd/7), data: lowerdir=/home/flouthoc/.local/share/containers/storage/volumes/myvol/_data,upperdir=/tmp/exp-overlay/upper,workdir=/home/flouthoc/tmp/work,userxattr,context="system_u:object_r:container_file_t:s0:c267,c630": invalid argument

@flouthoc flouthoc force-pushed the volume_overlay_advanced branch 2 times, most recently from 9e603f9 to 5d2652c Compare January 4, 2022 10:34
@flouthoc flouthoc mentioned this pull request Jan 7, 2022
@rhatdan
Copy link
Member

rhatdan commented Jan 10, 2022

@flouthoc Rebase so we can continue working on this.

@flouthoc
Copy link
Collaborator Author

@rhatdan Yes will do. I just need to update man pages for buildah changes and bump vendor again.

@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 11, 2022
@flouthoc
Copy link
Collaborator Author

flouthoc commented Jan 12, 2022

Upstream buildah has some breaking change so need few PR's so i can vendor buildah in: #12822

Edit: Also c/common has some regression so wait for #12821

@openshift-ci openshift-ci bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jan 12, 2022
@flouthoc
Copy link
Collaborator Author

Since we vendor-ed buildah here: #12642 I'll start re-basing this again.

if overlayFlag && strings.Contains(o, "upperdir") {
splitOpt := strings.SplitN(o, "=", 2)
if len(splitOpt) > 1 {
upperDir = splitOpt[1]
Copy link
Member

@rhatdan rhatdan Jan 27, 2022

Choose a reason for hiding this comment

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

Should you check for duplicates?

if upperDir != "" {
        return ERROR
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We ignore in underlying library if upperdir is empty. But I agree user should get early error so added here.

Expect(session).Should(Exit(0))

// volume should contain only `test` not `overlay`
session = podmanTest.Podman([]string{"run", "--volume", volName + ":/data:O," + overlayOpts, ALPINE, "sh", "-c", "ls /data"})
Copy link
Member

Choose a reason for hiding this comment

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

Can you test two volume mounts, one without overlayOpts and one without, and make sure the one without is not perment

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes added another mount with just overlay and no custom upper/workdir which tests that content is not persisted.

Copy link
Member

@TomSweeneyRedHat TomSweeneyRedHat left a comment

Choose a reason for hiding this comment

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

Any man page changes?

…umes

Often users want their overlayed volumes to be `non-volatile` in nature
that means that same `upper` dir can be re-used by one or more
containers but overall of nature of volumes still have to be `overlay`
so work done is still on a overlay not on the actual volume.

Following PR adds support for more advanced options i.e custom `workdir`
and `upperdir` for overlayed volumes. So that users can re-use `workdir`
and `upperdir` across new containers as well.

Usage
```console

$ podman run -it -v myvol:/data:O,upperdir=/path/persistant/upper,workdir=/path/persistant/work alpine sh

```

Signed-off-by: Aditya R <arajan@redhat.com>
@flouthoc
Copy link
Collaborator Author

Any man page changes?

@TomSweeneyRedHat thanks added a section to docs as well.

@rhatdan
Copy link
Member

rhatdan commented Jan 28, 2022

LGTM
@containers/podman-maintainers PTAL

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 openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jan 28, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 28, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: flouthoc, giuseppe

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

@flouthoc flouthoc removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 28, 2022
@openshift-merge-robot openshift-merge-robot merged commit 1b544b7 into containers:main Jan 28, 2022
flouthoc added a commit to flouthoc/podman that referenced this pull request Jun 3, 2022
…onymous volumes

Similar feature was added for named overlay volumes here: containers#12712
Following PR just mimics similar feature for anonymous volumes.

Often users want their anonymous overlayed volumes to be `non-volatile` in nature
that means that same `upper` dir can be re-used by one or more
containers but overall of nature of volumes still have to be overlay
so work done is still on a overlay not on the actual volume.

Following PR adds support for more advanced options i.e custom `workdir`
and `upperdir` for overlayed volumes. So that users can re-use `workdir`
and `upperdir` across new containers as well.

Usage

```console
podman run -it -v /some/path:/data:O,upperdir=/path/persistant/upper,workdir=/path/persistant/work alpine sh
```

Signed-off-by: Aditya R <arajan@redhat.com>
flouthoc added a commit to flouthoc/podman that referenced this pull request Jun 3, 2022
…onymous volumes

Similar feature was added for named overlay volumes here: containers#12712
Following PR just mimics similar feature for anonymous volumes.

Often users want their anonymous overlayed volumes to be `non-volatile` in nature
that means that same `upper` dir can be re-used by one or more
containers but overall of nature of volumes still have to be overlay
so work done is still on a overlay not on the actual volume.

Following PR adds support for more advanced options i.e custom `workdir`
and `upperdir` for overlayed volumes. So that users can re-use `workdir`
and `upperdir` across new containers as well.

Usage

```console
podman run -it -v /some/path:/data:O,upperdir=/path/persistant/upper,workdir=/path/persistant/work alpine sh
```

Signed-off-by: Aditya R <arajan@redhat.com>
flouthoc added a commit to flouthoc/podman that referenced this pull request Jun 3, 2022
…onymous volumes

Similar feature was added for named overlay volumes here: containers#12712
Following PR just mimics similar feature for anonymous volumes.

Often users want their anonymous overlayed volumes to be `non-volatile` in nature
that means that same `upper` dir can be re-used by one or more
containers but overall of nature of volumes still have to be overlay
so work done is still on a overlay not on the actual volume.

Following PR adds support for more advanced options i.e custom `workdir`
and `upperdir` for overlayed volumes. So that users can re-use `workdir`
and `upperdir` across new containers as well.

Usage

```console
podman run -it -v /some/path:/data:O,upperdir=/path/persistant/upper,workdir=/path/persistant/work alpine sh
```

Signed-off-by: Aditya R <arajan@redhat.com>
flouthoc added a commit to flouthoc/podman that referenced this pull request Jun 3, 2022
…onymous volumes

Similar feature was added for named overlay volumes here: containers#12712
Following PR just mimics similar feature for anonymous volumes.

Often users want their anonymous overlayed volumes to be `non-volatile` in nature
that means that same `upper` dir can be re-used by one or more
containers but overall of nature of volumes still have to be overlay
so work done is still on a overlay not on the actual volume.

Following PR adds support for more advanced options i.e custom `workdir`
and `upperdir` for overlayed volumes. So that users can re-use `workdir`
and `upperdir` across new containers as well.

Usage

```console
podman run -it -v /some/path:/data:O,upperdir=/path/persistant/upper,workdir=/path/persistant/work alpine sh
```

Signed-off-by: Aditya R <arajan@redhat.com>
flouthoc added a commit to flouthoc/podman that referenced this pull request Jun 3, 2022
…onymous volumes

Similar feature was added for named overlay volumes here: containers#12712
Following PR just mimics similar feature for anonymous volumes.

Often users want their anonymous overlayed volumes to be `non-volatile` in nature
that means that same `upper` dir can be re-used by one or more
containers but overall of nature of volumes still have to be overlay
so work done is still on a overlay not on the actual volume.

Following PR adds support for more advanced options i.e custom `workdir`
and `upperdir` for overlayed volumes. So that users can re-use `workdir`
and `upperdir` across new containers as well.

Usage

```console
podman run -it -v /some/path:/data:O,upperdir=/path/persistant/upper,workdir=/path/persistant/work alpine sh
```

Signed-off-by: Aditya R <arajan@redhat.com>
flouthoc added a commit to flouthoc/podman that referenced this pull request Jun 3, 2022
…onymous volumes

Similar feature was added for named overlay volumes here: containers#12712
Following PR just mimics similar feature for anonymous volumes.

Often users want their anonymous overlayed volumes to be `non-volatile` in nature
that means that same `upper` dir can be re-used by one or more
containers but overall of nature of volumes still have to be overlay
so work done is still on a overlay not on the actual volume.

Following PR adds support for more advanced options i.e custom `workdir`
and `upperdir` for overlayed volumes. So that users can re-use `workdir`
and `upperdir` across new containers as well.

Usage

```console
podman run -it -v /some/path:/data:O,upperdir=/path/persistant/upper,workdir=/path/persistant/work alpine sh
```

Signed-off-by: Aditya R <arajan@redhat.com>
flouthoc added a commit to flouthoc/podman that referenced this pull request Jun 6, 2022
…onymous volumes

Similar feature was added for named overlay volumes here: containers#12712
Following PR just mimics similar feature for anonymous volumes.

Often users want their anonymous overlayed volumes to be `non-volatile` in nature
that means that same `upper` dir can be re-used by one or more
containers but overall of nature of volumes still have to be overlay
so work done is still on a overlay not on the actual volume.

Following PR adds support for more advanced options i.e custom `workdir`
and `upperdir` for overlayed volumes. So that users can re-use `workdir`
and `upperdir` across new containers as well.

Usage

```console
podman run -it -v /some/path:/data:O,upperdir=/path/persistant/upper,workdir=/path/persistant/work alpine sh
```

Signed-off-by: Aditya R <arajan@redhat.com>
flouthoc added a commit to flouthoc/podman that referenced this pull request Jun 6, 2022
…onymous volumes

Similar feature was added for named overlay volumes here: containers#12712
Following PR just mimics similar feature for anonymous volumes.

Often users want their anonymous overlayed volumes to be `non-volatile` in nature
that means that same `upper` dir can be re-used by one or more
containers but overall of nature of volumes still have to be overlay
so work done is still on a overlay not on the actual volume.

Following PR adds support for more advanced options i.e custom `workdir`
and `upperdir` for overlayed volumes. So that users can re-use `workdir`
and `upperdir` across new containers as well.

Usage

```console
podman run -it -v /some/path:/data:O,upperdir=/path/persistant/upper,workdir=/path/persistant/work alpine sh
```

Signed-off-by: Aditya R <arajan@redhat.com>
karthikelango137 pushed a commit to karthikelango137/podman that referenced this pull request Jun 16, 2022
…onymous volumes

Similar feature was added for named overlay volumes here: containers#12712
Following PR just mimics similar feature for anonymous volumes.

Often users want their anonymous overlayed volumes to be `non-volatile` in nature
that means that same `upper` dir can be re-used by one or more
containers but overall of nature of volumes still have to be overlay
so work done is still on a overlay not on the actual volume.

Following PR adds support for more advanced options i.e custom `workdir`
and `upperdir` for overlayed volumes. So that users can re-use `workdir`
and `upperdir` across new containers as well.

Usage

```console
podman run -it -v /some/path:/data:O,upperdir=/path/persistant/upper,workdir=/path/persistant/work alpine sh
```

Signed-off-by: Aditya R <arajan@redhat.com>
gbraad pushed a commit to gbraad-redhat/podman that referenced this pull request Jul 13, 2022
…onymous volumes

Similar feature was added for named overlay volumes here: containers#12712
Following PR just mimics similar feature for anonymous volumes.

Often users want their anonymous overlayed volumes to be `non-volatile` in nature
that means that same `upper` dir can be re-used by one or more
containers but overall of nature of volumes still have to be overlay
so work done is still on a overlay not on the actual volume.

Following PR adds support for more advanced options i.e custom `workdir`
and `upperdir` for overlayed volumes. So that users can re-use `workdir`
and `upperdir` across new containers as well.

Usage

```console
podman run -it -v /some/path:/data:O,upperdir=/path/persistant/upper,workdir=/path/persistant/work alpine sh
```

Signed-off-by: Aditya R <arajan@redhat.com>
@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 21, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 21, 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.

Nonvolatile Upper Overlay Mount
5 participants