Skip to content

mounts: implement new org.osbuild.bind mount#1711

Merged
ondrejbudai merged 2 commits intoosbuild:mainfrom
mvo5:new-bind-mount
Apr 11, 2024
Merged

mounts: implement new org.osbuild.bind mount#1711
ondrejbudai merged 2 commits intoosbuild:mainfrom
mvo5:new-bind-mount

Conversation

@mvo5
Copy link
Contributor

@mvo5 mvo5 commented Apr 9, 2024

[draft: to get early feedback, I think adding a few more test cases would make sense here too but it should be okay]
[edit: the remaining issue is that org.osbuild.user may need to be able to create /var/home as useradd will not follow symlinks when creating dirs]

This adds a new org.osbuild.bind mount feature to the osbuild
mount modules. This allows to (r)bind mount parts of another mount
into the tree (or replace the default tree for a stage entirely).

The use case is the bootc install to-filesystem where we get
a populated disk and need to do customizations directly there
without going through an intermediate tree.

Note that right now only "--rbind" is supported and used but
we could trivially change that to become an option in either
direction. Given that the main use-case right now is to be
paried with org.osbuild.ostree.deployment and here the
rbind is crucial I would leave that the default.

Here is an example what this looks like:

        {
          "type": "org.osbuild.users",
          "options": {
            "users": {
              "alice": {
                "home": "/home/alice",
                "groups": [
                  "wheel"
                ],
                "password": "$6$NV3P7UzUqP3xb1ML$3qnHpWs037VRTaOc.kirQ4.RwNz4gu9dkhAhpBYVCkHw8CMhpBKnegyyqw0QfURowarZnRnQi.jo4JEzIOvPO/",
                "key": "ssh-rsa AAA ... user@email.com"
              }
            }
          },
          "devices": {
            "disk": {
              "type": "org.osbuild.loopback",
              "options": {
                "filename": "disk.raw",
                "partscan": true
              }
            }
          },
          "mounts": [
            {
              "name": "part4",
              "type": "org.osbuild.ext4",
              "source": "disk",
              "target": "/",
              "partition": 4
            },
            ...
            {
              "name": "ostree.deployment",
              "type": "org.osbuild.ostree.deployment",
              "options": {
                "source": "mount",
                "deployment": {
                  "default": true
                }
              }
            },
            {
              "name": "bind",
              "type": "org.osbuild.bind",
              "target": "tree://",
              "options": {
                "source": "mount://"
              }
            }
          ]
        },

Similar to `stages` and `sources` we need some basic infrastructure
so that we can use a `mounts_module` fixture for the coming tests
to the mount modules.
@mvo5 mvo5 requested review from achilleas-k and ondrejbudai April 9, 2024 09:54
@mvo5 mvo5 force-pushed the new-bind-mount branch from 9eb95ee to f5af84d Compare April 9, 2024 13:25
@mvo5 mvo5 marked this pull request as ready for review April 9, 2024 13:25
This adds a new `org.osbuild.bind` mount feature to the osbuild
mount modules. This allows to (r)bind mount parts of another mount
into the tree (or replace the default tree for a stage entirely).

The use case is the `bootc install to-filesystem` where we get
a populated disk and need to do customizations directly there
without going through an intermediate tree.

Note that right now only "--rbind" is supported and used but
we could trivially change that to become an option in either
direction. Given that the main use-case right now is to be
paried with `org.osbuild.ostree.deployment` and here the
`rbind` is crucial I would leave that the default.

Here is an example what this looks like:
```json
        {
          "type": "org.osbuild.users",
          "options": {
            "users": {
              "alice": {
                "home": "/home/alice",
                "groups": [
                  "wheel"
                ],
                "password": "$6$NV3P7UzUqP3xb1ML$3qnHpWs037VRTaOc.kirQ4.RwNz4gu9dkhAhpBYVCkHw8CMhpBKnegyyqw0QfURowarZnRnQi.jo4JEzIOvPO/",
                "key": "ssh-rsa AAA ... user@email.com"
              }
            }
          },
          "devices": {
            "disk": {
              "type": "org.osbuild.loopback",
              "options": {
                "filename": "disk.raw",
                "partscan": true
              }
            }
          },
          "mounts": [
            {
              "name": "part4",
              "type": "org.osbuild.ext4",
              "source": "disk",
              "target": "/",
              "partition": 4
            },
            ...
            {
              "name": "ostree.deployment",
              "type": "org.osbuild.ostree.deployment",
              "options": {
                "source": "mount",
                "deployment": {
                  "default": true
                }
              }
            },
            {
              "name": "bind",
              "type": "org.osbuild.bind",
	      "target": "tree://",
	      "options": {
		"source": "mount://"
	      }
            }
          ]
        },
```
@mvo5 mvo5 force-pushed the new-bind-mount branch from f5af84d to 1c392bf Compare April 9, 2024 16:01
@dustymabe
Copy link
Contributor

It would be cool to be able to do something like this, but rather define it at the pipeline level such that the tree:// for all stages in a pipeline is actually a mount://.

@achilleas-k
Copy link
Member

It would be cool to be able to do something like this, but rather define it at the pipeline level such that the tree:// for all stages in a pipeline is actually a mount://.

This idea did come up while we were discussing approaches for this problem. What I like about the solution in the PR though is that it requires very minimal changes (none of which are internal to osbuild's core) and fits a lot cleaner into the current flow.

There's definitely something a bit more elegant to your proposed solution though. The general principle that pipelines operate on a single tree is maintained and it makes it easier to reason about when that holds.

Copy link
Member

@ondrejbudai ondrejbudai left a comment

Choose a reason for hiding this comment

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

Looks good! :)

@ondrejbudai ondrejbudai merged commit a4dfd26 into osbuild:main Apr 11, 2024
mvo5 added a commit to mvo5/images that referenced this pull request Apr 12, 2024
mvo5 added a commit to mvo5/images that referenced this pull request Apr 12, 2024
achilleas-k pushed a commit to mvo5/images that referenced this pull request Apr 12, 2024
github-merge-queue bot pushed a commit to osbuild/images that referenced this pull request Apr 15, 2024
mvo5 added a commit to mvo5/images that referenced this pull request Apr 15, 2024
github-merge-queue bot pushed a commit to osbuild/images that referenced this pull request Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants