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

Add 40coreos dracut module #70

Merged
merged 1 commit into from
May 3, 2019
Merged

Conversation

jlebon
Copy link
Member

@jlebon jlebon commented Mar 21, 2019

This module is the integration point between Ignition and Fedora CoreOS.
Notably, we add two new systemd services in the initrd which mesh with
Ignition's own systemd services:

  1. coreos-mount-var.service, which finds the /var stateroot bind
    mount and mounts it under /sysroot/var before ignition-mount
    potentially adds more mounts underneath (or even shadowing /var
    itself).
  2. coreos-populate-var.service, which sets up /var on first boot
    using systemd-tmpfiles before ignition-files runs.

jlebon added a commit to jlebon/ignition-dracut that referenced this pull request Mar 21, 2019
Add support for the new Ignition `mount` and `umount` stages. The
`mount` stage runs *after* the `disks` stage and
`initrd-root-fs.target`, since we need to be able to mount under
`/sysroot`, but *before* the `files` stage, which will of course drop
files under those mounts.

Combined with coreos/fedora-coreos-config#70,
this allows us to drop all OSTree-specific bits and no longer rely on
`ostree-prepare-root.service` to mount `/var` for us.
@cgwalters
Copy link
Member

How would we handle /var as a real partition?

@jlebon
Copy link
Member Author

jlebon commented Mar 21, 2019

How would we handle /var as a real partition?

The mount stage will mount it just like any other. The bind-mount we do here is for the case where only e.g. /var/home is specified, in which case, we still want to populate all the other stuff under /var that would go in the stateroot. Instead of doing it conditionally, we just always bind-mount and always unmount to keep it simple (that's the "shadowing" part in the commit message).

Re. /var in FCOS specifically, I think the current idea is to ship that as a base config that users can override/tweak as they want.

@dustymabe dustymabe requested review from ajeddeloh and bgilbert March 25, 2019 14:45
@dustymabe
Copy link
Member

so I know we are wanting ignition-dracut repo to be mostly distro agnostic but would there be harm in having code in there that activates on one distro but is dormant on another? i.e. it would be kind of nice to just put this module in ignition-dracut and then non-ostree based distros could leave it out.

cc @ajeddeloh @bgilbert for input. It's also possible there was another conversations that I missed or forgot that led us here to begin with.

@jlebon
Copy link
Member Author

jlebon commented Mar 25, 2019

OK, this is working pretty well. Two things that bit me were https://src.fedoraproject.org/rpms/ignition/pull-request/31 and coreos/ignition#771. I played with various mounts, e.g. /var, /var/lib/containers, /var/home, as well as all three at the same time!

[root@localhost ~]# findmnt | grep /var
├─/var                    /dev/vdc1  xfs  rw,relatime,seclabel,attr2,inode64,noquota
│ ├─/var/home             /dev/vdb1  xfs  rw,relatime,seclabel,attr2,inode64,noquota
│ └─/var/lib/containers   /dev/vdd1  xfs  rw,relatime,seclabel,attr2,inode64,noquota

For anyone who wants to follow along, how I'm testing this right now is with:

diff --git a/fedora-coreos-base.yaml b/fedora-coreos-base.yaml
index fef318a..95a732a 100644
--- a/fedora-coreos-base.yaml
+++ b/fedora-coreos-base.yaml
@@ -58,6 +58,11 @@ remove-from-packages:
   # NOTE: Also remove 01_fallback_counting once we move to f30
   - [grub2-tools, /etc/grub.d/01_menu_auto_hide,
                   /usr/lib/systemd/.*]
+  # XXX
+  - [ignition, /usr/lib/dracut/modules.d/30ignition]
+
+add-files:
+  - [ignition, /usr/lib/dracut/modules.d/31ignition/ignition]


 # ⚠⚠⚠ ONLY TEMPORARY HACKS ALLOWED HERE; ALL ENTRIES NEED TRACKER LINKS ⚠⚠⚠

And rsync -al of 30ignition in coreos/ignition-dracut#47 at overlay/usr/lib/dracut/modules.d/31ignition.

(I was hitting issues packaging ignition git master with the recent git module rework, so just went with the nuclear option.)

And then a VM with an extra disk added and a config like:

    "storage": {
        "disks": [
            {
                "device": "/dev/vdb",
                "wipeTable": true,
                "partitions": [
                    {
                        "label": "VAR",
                        "number": 0,
                        "sizeMiB": 0,
                        "wipePartitionEntry": true
                    }
                ]
            }
        ],
        "filesystems": [
            {
                "device": "/dev/vdb1",
                "path": "/var",
                "format": "xfs",
                "wipeFilesystem": true,
                "label": "VAR"
            }
        ],
        "files": [
            {
                "path": "/etc/fstab",
                "append": [
                    {
                        "source": "data:,%0A/dev/vdb1%20/var%20xfs%20defaults%200%200%0A"
                    }
                ]
            },
            {
                "path": "/var/lib/hello.txt",
                "contents": {
                    "source": "data:,hello%20world"
                }
            }
        ]
    }

@jlebon jlebon changed the title WIP: Add 40coreos dracut module Add 40coreos dracut module Mar 25, 2019
@jlebon
Copy link
Member Author

jlebon commented Mar 25, 2019

I dropped WIP on this, but do note that this requires coreos/ignition-dracut#47, which is pending on FCOS switching to the new Ignition spec. So we need to hold this for now. That said, it's ready for review, and it'd be good if someone else tested this as well!

@jlebon jlebon added the hold label Mar 25, 2019
jlebon added a commit to jlebon/ignition-dracut that referenced this pull request Mar 25, 2019
Add support for the new Ignition `mount` and `umount` stages. The
`mount` stage runs *after* the `disks` stage and
`initrd-root-fs.target`, since we need to be able to mount under
`/sysroot`, but *before* the `files` stage, which will of course drop
files under those mounts.

Combined with coreos/fedora-coreos-config#70,
this allows us to drop all OSTree-specific bits and no longer rely on
`ostree-prepare-root.service` to mount `/var` for us.
Copy link
Contributor

@ajeddeloh ajeddeloh left a comment

Choose a reason for hiding this comment

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

LGTM

@jlebon
Copy link
Member Author

jlebon commented Mar 26, 2019

i.e. it would be kind of nice to just put this module in ignition-dracut and then non-ostree based distros could leave it out

Here's a question related to this: let's say we keep them separate, then couldn't we just fold the Ignition dracut module into https://github.com/coreos/ignition? Other than ignition-setup, all the services there are solely about integrating Ignition into an initrd using stable systemd targets. We could probably move off the few other stuff remaining and drop the ignition-dracut repo entirely.

@dustymabe
Copy link
Member

i.e. it would be kind of nice to just put this module in ignition-dracut and then non-ostree based distros could leave it out

Here's a question related to this: let's say we keep them separate, then couldn't we just fold the Ignition dracut module into https://github.com/coreos/ignition? Other than ignition-setup, all the services there are solely about integrating Ignition into an initrd using stable systemd targets. We could probably move off the few other stuff remaining and drop the ignition-dracut repo entirely.

Perhaps we could move ignition-dracut into ignition but probably not worth it right now. I'm cool with this as is and we can re-org in the future if it's an attractive option.

jlebon added a commit to jlebon/ignition-dracut that referenced this pull request Mar 26, 2019
This module is the integration point between Ignition and Fedora CoreOS.
Notably, we add two new systemd services in the initrd which mesh with
Ignition's own systemd services:

1. `coreos-mount-var.service`, which finds the `/var` stateroot bind
   mount and mounts it under `/sysroot/var` before `ignition-mount`
   potentially adds more mounts underneath (or even shadowing `/var`
   itself).
2. `coreos-populate-var.service`, which sets up `/var` on first boot
   using `systemd-tmpfiles` before `ignition-files` runs.

NOTE: this is a temporary holding place to make packaging easier.
Eventually, we will move this module to the FCOS overlay:
coreos/fedora-coreos-config#70
@bgilbert
Copy link
Contributor

bgilbert commented Mar 26, 2019

I'm fine having this in fedora-coreos-config for now. If we put distro-specific code in ignition-dracut, everyone will want to put distro-specific code in ignition-dracut. 😄

# Simply manually mkdir /var/lib; the tmpfiles.d entries otherwise reference
# users/groups which we don't have access to from here (though... we *could*
# import them from the sysroot, and have nss-altfiles in the initrd, but meh...
# let's just wait for systemd-sysusers which will make this way easier:
Copy link
Contributor

Choose a reason for hiding this comment

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

As a starting point, won't we want a systemd-sysusers invocation in this script?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was playing with this, but I think for now we should wait for the full sysusers switchover. The issue is that it'd require fooling systemd-sysusers into somehow being aware of the entries in /sysroot/usr/lib/{passwd,group} so that it notices entries that already exist. Alternatively, we can drop from group/passwd in this repo the entries that we expect to be created by sysusers, but that seems error-prone.

The other issue is that we'll then have some sysusers in /etc/passwd and some others in /usr/lib/passwd, and I'm not sure how well rpm-ostree layering will play with that. See e.g. https://github.com/projectatomic/rpm-ostree/blob/6b2ac5885fd1c4bdff2de90a2234d03c839f76ef/src/libpriv/rpmostree-passwd-util.c#L1183.

I think we could get this to work, but I'm not sure it's worth the investment if we'll just switch to sysusers anyway.

@jlebon jlebon removed the hold label Apr 25, 2019
@jlebon
Copy link
Member Author

jlebon commented Apr 25, 2019

OK, this is now ready for review again!
Needs to be merged together with coreos/ignition-dracut#76.

Also requires: #85

This module is the integration point between Ignition and Fedora CoreOS.
Notably, we add two new systemd services in the initrd which mesh with
Ignition's own systemd services:

1. `coreos-mount-var.service`, which finds the `/var` stateroot bind
   mount and mounts it under `/sysroot/var` before `ignition-mount`
   potentially adds more mounts underneath (or even shadowing `/var`
   itself).
2. `coreos-populate-var.service`, which sets up `/var` on first boot
   using `systemd-tmpfiles` before `ignition-files` runs.
@jlebon
Copy link
Member Author

jlebon commented Apr 29, 2019

Rebased! ⬆️

Copy link
Contributor

@ajeddeloh ajeddeloh left a comment

Choose a reason for hiding this comment

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

LGTM

@jlebon jlebon merged commit 9e94fca into coreos:master May 3, 2019
@jlebon jlebon deleted the pr/populate-var branch July 4, 2019 21:55
dustymabe added a commit to jbtrystram/fedora-coreos-config that referenced this pull request Apr 19, 2024
Small wording updates based on code review comments from coreos#70.
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.

5 participants