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 general ignition-ostree module with rootfs replacement #184

Closed

Conversation

cgwalters
Copy link
Member

Previously the 40coreos-var module was "special /var
handling for Ignition + OSTree".

This new module takes over that, renaming it to ignition-ostree,
and extends it with support for replacing the root filesystem.

@cgwalters
Copy link
Member Author

This is work for coreos/fedora-coreos-tracker#94

@ajeddeloh
Copy link
Contributor

This is blocked by the rootfs mount options issue, right?

@cgwalters
Copy link
Member Author

This is blocked by the rootfs mount options issue, right?

Working on that!

Copy link
Contributor

@darkmuggle darkmuggle left a comment

Choose a reason for hiding this comment

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

I like the direction. My only question is whether reading it to an in-ram location (tar -cf ...) might be faster since you avoid the overhead of the delete process. For some cloud-based network attach storage, there's going to be a cost and avoiding that could make it marginally faster.

@cgwalters
Copy link
Member Author

Will rebase on #187

@cgwalters
Copy link
Member Author

My only question is whether reading it to an in-ram location (tar -cf ...) might be faster since you avoid the overhead of the delete process.

Yeah I started with that, but hit tar+SELinux issues. My plan is to put this in rpm-ostree, see coreos/rpm-ostree#1911

@cgwalters cgwalters force-pushed the ignition-ostree-rootfs branch from 90f3db1 to 9540b70 Compare September 27, 2019 17:49
fi
echo "Restoring rootfs from RAM..."
for x in boot ostree; do
mv -Tn ${tmproot}/${x} ${rootmnt}/${x}
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the impact of this and hardlinks? Should we be doing ostree operations instead of just mv/cp?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I plan to move this portion into rpm-ostree.

@cgwalters cgwalters force-pushed the ignition-ostree-rootfs branch 2 times, most recently from fbc96e6 to a5dc2eb Compare December 2, 2019 15:15
cgwalters and others added 2 commits May 23, 2020 16:00
This adds basic infrastructure units for "re-provisioning"
the root filesystem.  See:
coreos/fedora-coreos-tracker#94

A unit first detects if the Ignition configuration has a filesystem
with the label `root` - if so, we save the rootfs into RAM, let
`ignition-disks.service` run, then restore it from RAM.

Earlier attempts copied the files into `tmpfs`; this instead
uses the `brd` kernel module which is a RAM-backed block
device so we can just `dd`.  This a faster and more reliable way
to save the rootfs.  However, `brd` doesn't support discards,
so we require at minimum $rootfs_size RAM (e.g. 3G) until reprovisioning
is complete.  In the future I might investigate trying a `tmpfs`
again as that better integrates with the page cache and doesn't
have the discard issue.  But it requires more work to save the rootfs.

Future work here will likely more the `restore` phase into
`rpm-ostree`.
- add check for `wipeFilesystem == true` in jq query
- use `modprobe --first-time` instead of `lsmod` to avoid race condition
- use `rsync` instead of `mv`; they're mostly equivalent in this
  context, but rsync is more tuned for this sort of massive operation
  and does things slightly more correctly (specifically, it correctly
  labels the root inode of the rootfs itself)
@jlebon jlebon force-pushed the ignition-ostree-rootfs branch from a5dc2eb to f1cd51b Compare May 23, 2020 21:57
@jlebon
Copy link
Member

jlebon commented May 23, 2020

As mentioned in coreos/fedora-coreos-tracker#94 (comment), I've now sent the patch upstream to be able to read labels from the initrd. In order to be confident it worked, I rebased this on top of the latest testing-devel. With the kernel patch + this PR, I can boot up FCOS on ext4 with SELinux on and the following Ignition config:

"storage": {
    "filesystems": [
        {
            "device": "/dev/disk/by-partlabel/root",
            "format": "ext4",
            "wipeFilesystem": true,
            "label": "root"
        }
    ]
}

Anyway, took the liberty to force-push the rebase to this PR. I also added a follow-up commit with some tweaks. We can squash that in if you approve.

echo "Moved rootfs to RAM, pending redeployment: ${memdev}"
;;
restore)
mount "$rootdisk" $rootmnt
Copy link
Member Author

Choose a reason for hiding this comment

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

Aside: I am still leaning towards "rootfs reprovisioning must add a root= kernel argument" (UUID is a sane default, but it doesn't have to be that). That way we avoid all races with changing the meaning of /dev/disk/by-label/root.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I think I agree with this. I feel like we should spend some time to write up some of the complex root device options we want to support (e.g. at least starting with multipath, RAID, and LUKS) and see how it fits into one cohesive picture.

Copy link
Member

Choose a reason for hiding this comment

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

This is done in #503.

@jlebon
Copy link
Member

jlebon commented Jun 29, 2020

So circling back, once we unblock the SELinux patch (I have an RHBZ pending for that), this is the next crucial piece in the puzzle for coreos/fedora-coreos-tracker#94. On its own, it will allow e.g. reconfiguring /dev/sda4 from xfs to ext4 or moving it to another disk entirely. #503 builds on it to support targeting complex devices.

It's been pretty solid for me while hacking on coreos/fedora-coreos-tracker#94. Though we should get some fresh eyes on it too.

@jlebon
Copy link
Member

jlebon commented Jul 2, 2020

This is now part of #503.

@jlebon jlebon closed this Jul 2, 2020
dustymabe pushed a commit to jbtrystram/fedora-coreos-config that referenced this pull request Apr 19, 2024
* nav: Add link to Afterburn docs

* nav: Improve projects docs naming and link names
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