Commit graph

639 commits

Author SHA1 Message Date
Dusty Mabe
2583e8c9be coreos-teardown-initramfs: ignore lo.nmconnection
Upstream NetworkManager now autogenerates a lo.nmconnection connection
to manage the local loopback device. Let's ignore that connection for
the purposes of our comparison and propagation here.

Closes https://github.com/coreos/fedora-coreos-tracker/issues/1385
2023-01-18 13:55:18 -05:00
Dusty Mabe
a82da64da2 coreos-teardown-initramfs: fix spelling error 2023-01-18 13:55:18 -05:00
Dusty Mabe
aeb031c7e0 overlay.d: add change/move to action for azure sriov rules
When testing out if these rules applied correctly in the initramfs
I wasn't observing the device would properly get NM_UNMANAGED=1
until I added change/move.

This is similar to what is done by NM over in
38d3834e2c/data/85-nm-unmanaged.rules (L5)
2023-01-18 10:21:36 -05:00
Dusty Mabe
8d63178369 overlay.d: create new 25-azure-udev-rules overlay
We previously had the 68-azure-sriov-nm-unmanaged.rules but we
figured out we also want those rules in the initramfs. This
commit makes a new overlay.d entry and groups together a new
dracut module along with the udev rules in that overlay.d directory.

Fixes https://github.com/coreos/fedora-coreos-tracker/issues/1383
2023-01-18 10:21:36 -05:00
Dusty Mabe
937d3295bd overlay.d: only run coreos-enable-network on first boot
I noticed recently that Azure is bringing up networking in the initramfs
on every boot [1]. This behavior was originally introduced in c1cf903. After
some discussion with @jlebon and @bgilbert we are going to convert the
coreos-enable-network.service to only be pulled in and enalbed on the
Ignition boot so that it doesn't run on subsequent boots.

[1] https://github.com/coreos/fedora-coreos-tracker/issues/1383#issuecomment-1384526420
2023-01-18 10:21:36 -05:00
Colin Walters
342a91f506 overlay/35-coreos-live: Lazily unmount /proc/cmdline
It's possible that some other process has a file descriptor open
for `/proc/cmdline`; if so our unmount will fail.  Do the unmount
lazily - it was designed for exactly this situation.

This was seen in an OCP installation on vSphere at least once.
2023-01-12 16:50:25 -05:00
Benjamin Gilbert
455ef7a603 Consistently Use Title Case for Service Descriptions
Also do some minor wording cleanups.

Fixes https://issues.redhat.com/browse/COS-1840.
2023-01-10 17:37:16 -05:00
Dusty Mabe
b38aa7ff64 Revert "overlay/15fcos: retroactively fix BLS grub_users setting (CVE-2022-3675)"
This reverts commit d7d40682de.

This is no longer needed since we have implemented a barrier on each
release stream now: https://github.com/coreos/fedora-coreos-tracker/issues/1333#issuecomment-1319168915
2022-11-18 10:22:15 -05:00
Benjamin Gilbert
d7d40682de overlay/15fcos: retroactively fix BLS grub_users setting (CVE-2022-3675)
Starting with FCOS 36.20220906.1.0, 36.20220906.2.0, and 36.20220820.3.0,
coreos-assembler inadvertently failed to configure ostree to set
`grub_users=""` in non-default BLS configs, allowing old deployments to
be booted without a GRUB password.  Add a service that fixes this setting
on the first boot after upgrade, if the aleph version corresponds to an
affected release.

This can be reverted after the next update barrier in all streams.

For https://github.com/coreos/fedora-coreos-tracker/issues/1333.
2022-11-01 21:15:04 -04:00
Timothée Ravier
f706a4f66a manifest: Exclude support for NM legacy ifcfg config format
Since Fedora 36, the ifcfg-rh plugin implementing support for reading
network configuration files in the legacy ifcfg format has been split
out into its own RPM subpackage.

We can now remove our configuration workaround and instead ensure that
we do not ship this plugin at all.

See: https://github.com/coreos/fedora-coreos-config/pull/1991
2022-09-30 09:43:20 -04:00
Colin Walters
3481a8c70b live-generator: Use a loop to work around potential races with udev on el8
This is a bigger hammer for the same issue as
170df10014

While I haven't been able to reproduce the problem in synthetic
testing with qemu, I am increasingly confident that there *are*
other udev rules running concurrently with our mounting attempt.

This was motivated by https://issues.redhat.com/browse/OCPBUGS-1505
where I specifically noticed that the ISO appears as a USB
device (which is really itself virtual and provided by the iLO),
and appears much later system bootup than I see with qemu, even
with emulated USB CD-ROM.

A possibly concrete culprit is `cdrom_id`, which on RHEL8 does
`open(O_EXCL)` on the CD-ROM device. For more information, see:

https://github.com/coreos/fedora-coreos-config/pull/1986#pullrequestreview-1120840529

Co-authored-by: Jonathan Lebon <jonathan@jlebon.com>
2022-09-27 20:51:03 -04:00
Benjamin Gilbert
dbe16a169c overlay: compress initrd with zstd -19 on FCOS and RHCOS/SCOS 9
On my system, relative to gzip -9, it roughly halves decompression time at
boot while also reducing initrd size.

RHCOS 8 can't inherit this because the RHEL 8 kernel doesn't enable
CONFIG_RD_ZSTD.

This requires coreos-installer to support decoding zstd (for
`coreos-installer pxe customize`), which is
https://github.com/coreos/coreos-installer/pull/920.

For https://github.com/coreos/fedora-coreos-tracker/issues/1247.
2022-09-16 03:20:43 -04:00
Timothée Ravier
c0aea3baa2 *: Remove whitespace at EOL 2022-09-12 07:29:51 +00:00
Dusty Mabe
8c07dcb7ad overlay.d/20platform-chrony: use generator-lib.sh for generator
In this case the generator-lib.sh handles the logging setup and
also offers a karg helper that we can use instead of the grep.
2022-09-08 09:24:09 -04:00
Dusty Mabe
22913cef0f overlay.d/35coreos-live: add workaround for stalled iso-live-login boot
We've found the system can stall waiting for run-media-iso.mount
and apparently any operation seems to be effective at reviving
the system. Let's add a workaround that will kick in after 10 seconds
and try to revive the boot.

A lot more context over in
https://github.com/coreos/fedora-coreos-tracker/issues/1233#issuecomment-1238814171

Here's an example of this working:

```
[    2.749303] systemd[1]: ignition-ostree-transposefs-restore.service - Ignition OSTree: Restore Partitions was skipped because of a failed condition check (ConditionPathIsDire
ctory=/run/ignition-ostree-transposefs).
[    2.750547] ignition[591]: disks: disks passed
[    2.750882] ignition[591]: Ignition finished successfully
[   12.645801] kauditd_printk_skb: 19 callbacks suppressed
[   12.645804] audit: type=1131 audit(1662520856.021:30): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=kernel msg='unit=workaround-stalled-media-iso-mount comm="systemd" exe=
"/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
[   12.647774] bash[564]: warn: tracker issue workaround engaged for https://github.com/coreos/fedora-coreos-tracker/issues/1233
[   12.648646] systemd[1]: workaround-stalled-media-iso-mount.service: Deactivated successfully.
[   12.649281] systemd[1]: Mounting run-media-iso.mount - /run/media/iso...
```
2022-09-07 11:46:44 -04:00
Luca BRUNO
8856624b5e manifests: drop workaround for 'tss' user/group
The `tss` user/group entries have been fixed in `tpm2-tss-3.2.0-3`,
so this drops all existing workarounds.
Both are static entries and are already covered by kola tests.
2022-09-07 10:10:24 -04:00
Nikita Dubrovskii
b9fbbfaaac s390x: fix secex workaround unit dependency
Now that we no longer use LUKS, `cryptsetup.target` is no longer
activated. We do still need some ordering here though so that we don't
run too early when e.g. `virtio_blk` isn't even loaded yet.

Run after `coreos-gpt-setup.service` which also normally needs block
device access.
2022-08-29 17:27:51 -04:00
Jonathan Lebon
78506135fa Handle dm-verity-protected filesystems in s390x secex path
Instead of shipping the rootfs and bootfs using LUKS, we're pivoting to
verifying integrity using dm-verity instead.

Add `veritysetup` to the OS. Teach `transposefs` to transfer the
filesystem over dm-verity. Delete the root and boot hash partitions.
Delete some of the bits we previously added for LUKS enablement.

For more information, see:
https://github.com/coreos/coreos-assembler/pull/3039
2022-08-29 17:27:51 -04:00
Jonathan Lebon
d0414dcd65 35coreos-ignition: swap order of luks and filesystems keys
Conceptually, I find it clearer to follow the Ignition config if the
`luks` section comes before the `filesystems` section since the latter
refers to things from the former and that's the order in which the
operations are carried out in practice (and in turn the block device
hierarchy).
2022-08-24 12:35:56 -04:00
Jonathan Lebon
dd8325025e 35coreos-ignition: fix LUKS device paths
Using `BOOTDEV` like this here will not be valid once we're able to
switch to relying on the boot link and drop
`ignition-ostree-secex-config.sh`. It's cleaner to just use the
`by-label/` symlink instead.
2022-08-24 12:35:56 -04:00
Jonathan Lebon
4c85cb0639 transposefs: use stricter find ... -exec ... {} + variant
Unlike the default `\;` variant, this variant will actually cause `find`
to exit nonzero if the executed command failed. (Its main purpose is
actually to pass multiple items to the command rather than one at a
time, but we're more interested in the cleaner error-handling semantic.)
2022-08-24 12:35:56 -04:00
Jonathan Lebon
7d0952769d transposefs: factor out function to save filesystems
Just like we have `mount_and_restore_filesystem_by_label`, add a
`mount_and_save_filesystem_by_label` that can be used to save both the
rootfs and bootfs.
2022-08-24 12:35:56 -04:00
Jonathan Lebon
aa8d9e8e58 transposefs: mount filesystems read-only by default
We should always default to mounting filesystemd read-only unless we
actually need write access.
2022-08-24 12:35:56 -04:00
Luca BRUNO
fd31e96b40 overlay/sysusers: rename fragments containing both groups and users 2022-08-22 16:27:30 +00:00
Luca BRUNO
df5f5fd5a2 overlay/sysusers: add user entries 2022-08-22 16:27:30 +00:00
Luca BRUNO
865908fd0b overlay/sysusers: add description comments to each fragment 2022-08-22 16:27:30 +00:00
Benjamin Gilbert
8ee60ace21 overlay: add 06el9 overlay
Add overlay for content shared between FCOS and RHCOS/SCOS 9.

Discussion in https://github.com/coreos/fedora-coreos-config/issues/1878.
2022-08-16 13:35:33 -04:00
Benjamin Gilbert
8e3a07ee13 16disable-zincati: add stub statoverride file
We generally include this in every overlay to demonstrate that it can be
used.
2022-08-16 13:35:33 -04:00
Luca BRUNO
8d6b9d6b27 overlay/sysusers: add fragments for all FCOS system groups
This translates all Fedora CoreOS system groups (i.e. those coming
from group manifest) into equivalent sysusers.d fragments.

We currently ship four kinds of system groups:
 * basic groups coming from the `/etc/group` file in the `setup`
   package (10-groups-basic.conf)
 * the legacy GID for the `nobody` group (00-group-nobody.conf)
 * extra groups with static GIDs that adhere to the Fedora
   allocation table (10-groups-static-extra.conf)
 * extra groups with static GIDs that are specific to CoreOS
   (00-groups-coreos-static.conf)

These sysusers.d fragments are meant as a transitory measure to
help migrate the existing group entries from the current nss-altfiles
setup to a plain sysusers.d world.
2022-08-09 19:21:25 +00:00
Benjamin Gilbert
29e17afee6 05core: add Before= to some Dracut services
If initrd services don't sequence themselves Before anything, it's
possible that they won't be started before initrd-cleanup.service isolates
to initrd-switch-root.target and kills them off.  Add at least
Before=initrd.target to avoid this.
2022-08-03 13:58:00 -04:00
Benjamin Gilbert
651846ef11 05core: fix coreos-boot-edit.service race with switch-root
coreos-boot-edit.service wasn't sequenced Before anything, so under heavy
I/O contention it could race with services being terminated prior to
switching to the real root.  Before=initrd.target should fix this, so we
specify it, but it isn't enough for the same unknown reason as in
8b804863c6.  Also specify Before=initrd-parse-etc.service to avoid that
problem.

Fixes occasional multipath.day1 flakes in
https://github.com/coreos/fedora-coreos-tracker/issues/1105, which became
more frequent after https://github.com/coreos/coreos-ci-lib/pull/112
landed.

Fixes https://github.com/coreos/fedora-coreos-tracker/issues/1105.
2022-08-02 08:55:19 -04:00
Benjamin Gilbert
ebe2edb780 05core: fix permissions of /etc/sudoers.d/coreos-sudo-group
sudo wants them to be 440, not 600.

Also update the kola test to run "visudo -c" rather than checking the
perms ourselves.  This not only checks perms, but also ensures that the
files are syntactically valid.

Fixes https://github.com/coreos/fedora-coreos-config/issues/1872.
2022-07-27 15:25:34 -04:00
Jonathan Lebon
f0077efe0a 40ignition-ostree: fix minor secex-related nits
Follow-up to #1819.

Tweak the description of `ignition-ostree-secex-config.service` for
consistency and drop an unnecessary conditional in the associated
script.
2022-07-20 17:03:17 -04:00
Jonathan Lebon
804365b333 overlay: rename dracut.conf.d dropins
These will be shared with RHCOS since they're in `05core`. Let's give
them more generic names.

See discussions in #1856.
2022-07-20 13:21:08 -04:00
Jonathan Lebon
27e0a8d46a overlay: disable dracut stripping
While looking at the boot space issue[1], I tested whether stripping
binaries saved anything. Currently, dracut tries to strip binaries if
`strip` (or `eu-strip`) are available, which isn't the case in FCOS.

Adding it as a test, it turns out stripping barely saves anything
because we've already split out debug symbols into separate RPMs, and
the remaining symbols don't take much space.

So let's just tell dracut to stop trying to opportunistically strip
anything to be consistent. This then squashes a message emitted about
`strip` not being found.

[1] https://github.com/coreos/fedora-coreos-tracker/issues/1247
2022-07-20 11:33:55 -04:00
Nikita Dubrovskii
eee0d71111 s390x: workaround broken 'coreos-boot-disk' in 01-secex.ign config for RHCOS
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=2075085
RHCOS may have (and has now) kernel with a known issue, which makes not
possible to use 'coreos-boot-disk' symlink in the config. Once we have
kernel >= 4.18.0-387.el8.s390x we should revert this commit

Signed-off-by: Nikita Dubrovskii <nikita@linux.ibm.com>
2022-07-20 10:53:17 -04:00
Nikita Dubrovskii
6774eef660 s390x: reencrypt boot- and rootfs if SecureExecution is enabled
Only for systems running with Secure Execution. During firstboot this reencryptes filesystems
labeled 'boot' and 'root'.

Co-authored-by: Jonathan Lebon <jonathan@jlebon.com>
2022-07-20 10:53:17 -04:00
Jonathan Lebon
07b906dc1c overlay: omit bluetooth dracut module
We don't ship Bluetooth support. Should squash:

    dracut: 62bluetooth: Could not find any command of
    '/usr/lib/bluetooth/bluetoothd /usr/libexec/bluetooth/bluetoothd'!

Follow-up to #1838.
2022-07-20 09:14:13 -04:00
Colin Walters
14c2dc3631 overlay: Omit many more dracut modules explicitly
We're not actually shipping any of these today; the way dracut
works is it looks for them and emits a loud warning if they're not
found.

This is purely to quiet build time warnings.
2022-07-19 13:10:46 -04:00
Saqib Ali
4a29c8fc32 35coreos-ignition: verify grub password directives
GRUB password directives should not be present in
/boot/grub2/user.cfg if the system is not using GRUB.
Let's add a check to verify this.
2022-07-19 12:07:01 -04:00
Colin Walters
57395c7dd9 coreos-printk-quiet.service: Lower kernel log level to 4
Closes: https://github.com/coreos/fedora-coreos-tracker/issues/1244

A lot going on for this simple service.  See the tracker issue above
for more info, but briefly:

Anaconda has historically injected `quiet` into the kernel command
line in many cases, and this suppresses *both* kernel and systemd
output.  On computers in general, but particularly many bare metal
servers, the serial console can be slow.  This can cause reliability
issues.

However for servers, we usually *do* want to see informational
output when they boot.  For example, today the kernel "mitigations"
information for hardware vulnerabilities is output.

This change is a compromise; we boot up at the kernel's default
verbosity level (which for Fedora and derivatives is the upstream 7),
but switch to 4 very early on in the real root.  At that point, we've
gotten most of the boot time output, and our initramfs is not
extremely performance sensitive right now.

Also, we explicitly only *lower* the output log level, and only if
there isn't explicitly `debug` on the kernel command line.
2022-07-15 10:57:28 -04:00
Jonathan Lebon
55c8d7ce9f 35coreos-multipath: propagate after Ignition files stage
We didn't have a strong ordering between the propagation service and the
Ignition `files` stage. We need to run after it so that we only
propagate the multipath config if the Ignition config didn't create one.

In practice currently the propagation service runs before, which didn't
cause any issues because Ignition can still just clobber what we
propagated. But it could become racier in the future, and it's confusing
because the logic we run and messages we log assume the `files` stage
ran.
2022-07-12 09:25:45 -04:00
Jonathan Lebon
f5ec625825 35coreos-multipath: stop creating incorrect dropin dir
The path used there is incorrect. The dropins dir is
`/etc/multipath/conf.d`:

686797b7d0/Makefile.inc (L100)

But anyway, we don't actually need to create that directory; it's
already in the base image. So just drop it.
2022-07-12 09:25:45 -04:00
Colin Walters
9997df7bb9 Move from initramfs-args in manifest to dracut.conf.d files
See https://github.com/coreos/rpm-ostree/issues/3799

This way when we run dracut in a container build, we naturally
pick up the same config we used for server side builds.
2022-07-11 14:48:56 -04:00
Micah Abbott
70ab19c8e2 coreos-gpt-setup: fix DM_MPATH variable spelling
This was mis-spelled as part of e3309ad07c

I believe this is the root cause for the CI failure in
openshift/os#874
2022-07-07 17:35:52 -04:00
Jonathan Lebon
11d8b17f12 35coreos-multipath: improve config propagation logging
We were saying "no initramfs automatic multipath configuration to
propagate" even when there was an initramfs config but the file already
existed in the real root. Let's split out those no op conditions more
and log clearer explicit messages.

This should be a purely cosmetic change. Prompted by looking at logging
from this service to debug a multipath-related issue.
2022-07-06 16:43:38 -04:00
Nikita Dubrovskii
b4c81c4b6e overlay.d: add service to check for unique-boot after ignition
After ignition's stages partition table could be modified, and therefore
kernel may have an old picture of disks and partitions. During verification
we force kernel to reread the partition table for each disk and call udevsettle,
which in turn leads to modification of "/dev/disk/by-*/*" symlinks and systemd
may send SIGTERM to services with "Require=dev-disk-by\x2dlabel-boot.device".
To avoid that this checks for the unique fs labeled 'boot' after ignition's
disks stage was finished but before mounting stage.

Issue: https://github.com/coreos/fedora-coreos-tracker/issues/1105

Signed-off-by: Nikita Dubrovskii <nikita@linux.ibm.com>
2022-06-28 14:20:25 -04:00
Nikita Dubrovskii
ecc9497d61 coreos-ignition-firstboot-complete: call 'rdcore zipl' instead of 'zipl'
This brings Secure Execution support.

Signed-off-by: Nikita Dubrovskii <nikita@linux.ibm.com>
2022-06-27 11:26:27 -04:00
Nikita Dubrovskii
073d525285 s390x: ignition-ostree-growfs: resize LUKS encrypted rootfs
Signed-off-by: Nikita Dubrovskii <nikita@linux.ibm.com>
2022-06-27 11:26:27 -04:00
Nikita Dubrovskii
e3309ad07c s390x: coreos-gpt-setup: add suport for LUKS encrypted 'boot' partition 2022-06-27 11:26:27 -04:00
Benjamin Gilbert
0b03cef07d Drop fedora-coreos-pinger
It's a stub service that only parses a config file, and we never
adequately documented the config file.  We have no current plans to
finish implementing the service, so let's drop it.

Fixes https://github.com/coreos/fedora-coreos-tracker/issues/770.
2022-06-22 16:15:22 -04:00
Jonathan Lebon
4a2140b51a overlay/coreos-diskful-generator: make symlink creation idempotent
A generator can be run multiple times. This symlink is a bit of an abuse
of systemd generators because it writes things outside of the expected
output directories. So we need to make sure that we're idempotent.
2022-06-17 23:57:10 -04:00
Nikita Dubrovskii
662aac5688 udev: don't create 'coreos-boot-disk' symlink on subsequent boots
Signed-off-by: Nikita Dubrovskii <nikita@linux.ibm.com>
2022-06-03 13:02:38 -04:00
Dusty Mabe
7615672ca1 05core: print warnings to secondary consoles
This allows us to print the helpful messages that we have added
for our users before they enter dracut's emergency shell to all
configured consoles on the machine.

Closes https://github.com/coreos/fedora-coreos-tracker/issues/954
2022-06-02 22:27:48 -04:00
Dusty Mabe
33ec2eb3e5 coreos-teardown-initramfs: handle new .txt file in ifcfg dir
Upstream NM started adding a readme-ifcfg-rh.txt file to explain
and encourage people to use keyfiles instead. This file doesn't
do anything, but breaks our logic that tries to determine if the
user provided networking config to the machine.

This file was added upstream in
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/commit/96d7362
2022-06-02 11:32:45 -04:00
Benjamin Gilbert
8e08f7bb3d 05core: add coreos-ignition-delete-config.service for upgrade boots
Ignition 2.14.0 adds ignition-delete-config.service, which deletes
Ignition configs from VMware and VirtualBox on first boot.  Add
coreos-ignition-delete-config.service to do the same thing on existing
machines on upgrade, using a stamp file in /var/lib to avoid multiple
runs.

Add a drop-in for ignition-delete-config.service that creates a stamp
file in /run, and then chain from that stamp to the long-term stamp in
/var/lib, ensuring that we don't delete configs twice on newly-
provisioned machines.  The upstream service can't create the stamp
directly in /var/lib because it runs before /var is mounted.

Prevent coreos-ignition-delete-config.service from running if
ignition-delete-config.service is masked, ensuring that the mask operation
documented upstream prevents the config from ever being deleted, as
intended.

We can remove this after the next barrier release in FCOS and barrier
equivalent in RHCOS.
2022-05-18 00:45:25 -04:00
Dusty Mabe
513d60ed03 manifests: drop service for staying on iptables-legacy
This service was used for people who wanted to stay on
iptables-legacy. Now that there has been a barrier release
it is no longer needed.

Also move the iptables-nft enablement into fedora-coreos-base
and delete related tests.
2022-05-11 14:48:15 -04:00
Dusty Mabe
8d4d1ec198 Revert "15fcos: add coreos-fix-systemd-journald.service"
This is no longer needed because the fix from upstream [1]
has made it into systemd-249.12-3.fc35. See [2]

This reverts commit a456f26a3f.

[1] https://github.com/systemd/systemd/pull/22861
[2] https://github.com/coreos/fedora-coreos-tracker/issues/1108
2022-04-29 15:01:32 -04:00
Benjamin Gilbert
96241aec21 05core: add ignition-delete-config.service to default preset
For https://github.com/coreos/ignition/pull/1350.
2022-04-27 13:57:24 -04:00
Dusty Mabe
e83eaa9763 Revert "overlay: add new module for installing Azure udev rules"
The WALinuxAgent-udev rpm now installs the udev rules into the
initramfs [1] so we can drop this glue code.

This reverts commit 8c07b73914.

[1] 521b67bc85
2022-04-22 17:17:32 -04:00
Steven Presti
c3f518549f 05core: remove automatic reboot after timeout
The reboot and consequently the timeout masked valuable debug
information. The reboot also caused some cascading errors due to the
fact that the system would try and run as if all required dependencies
were satisfied during the first boot.

Closes https://github.com/coreos/fedora-coreos-tracker/issues/928.
2022-04-22 11:57:30 -04:00
Benjamin Gilbert
13106a6f49 05user: report ENOSPC in initrd when entering e-shell
When a user tries to boot a live system with an appended rootfs without
enough RAM, the kernel will unpack the initramfs and rootfs until it
runs out of memory, and then continue booting with a partial OS image.
This causes random confusing boot errors, such as a service failing
because its binary is missing, or the rootfs squashfs failing to mount
with some error that looks like filesystem corruption.

Make this failure less confusing by having timeout.sh try to write a small
file, and if that fails, tell the user that they need more RAM.  Suppress
reporting of unit failures in this case, since the unit logs will just
muddy the issue.

This works reliably when the rootfs image can't be unpacked, i.e. when
the system has a moderate amount of RAM.  It doesn't work reliably when
we're so low on RAM that the initramfs image can't be unpacked (because
the compressed initramfs and rootfs images have used up our RAM); in that
case we might be missing important binaries/libraries and boot can fail
at any point.  It would be possible to construct a more robust detection
mechanism, e.g. by running a statically-linked program that's unpacked
first.  But this can't be completely robust (/sbin/init might not have
been unpacked, so we might not boot at all) and doesn't seem worth it for
now.

This code will also trigger if we run out of RAM in the
coreos.live.rootfs_url case, which is nice but less important, since that
case produces a clear error during rootfs fetch.

Closes https://github.com/coreos/fedora-coreos-tracker/issues/1055.
2022-04-21 14:51:15 -04:00
Sohan Kunkerkar
03c5d9ba25 05core/usr/libexec: avoid displaying duplicated Ignition warnings
In Ignition, we've two config validation checks, the one after
fetching a config and the second after merging configs. Sometimes,
a warning goes away after merging, however, it's possible that a
warning appears in case merging creates a contradiction between two
fields. So this workflow eventually sends duplicate warnings in journal
entries. Hence, we need to avoid displaying duplicate Ignition warnings
on the console. Also, Ignition warnings are highlighted with yelllow.
2022-04-13 20:49:13 -04:00
Sohan Kunkerkar
6dc91d213b 05core/*: display Ignition warnings on the console
Fixes https://github.com/coreos/fedora-coreos-tracker/issues/1125

This change displays all Ignition warnings on the console. Also, renamed
the existing Ignition service to make it more generalized for handling
status information about the Ignition run.
2022-04-06 13:33:23 -04:00
Jonathan Lebon
e8ff8522b3 overlay/05core: ship by-id/coreos-boot-disk udev rule in initrd only
The associated script only exists in the initrd. But also, we only need
the symlink in the initrd anyway.

Fixes 6d7b9ad5 ("overlay.d: add udev rule for creating stable symlink to
boot disk").

Fixes https://github.com/openshift/os/issues/755.
2022-03-23 09:14:43 -04:00
Nikita Dubrovskii
163e8987aa Revert "overlay: verify filesystem labeled 'boot' is unique after ignition"
Issue: https://github.com/coreos/fedora-coreos-tracker/issues/1105
This reverts commit bd7a5c7891.
2022-03-22 13:35:14 -04:00
Dusty Mabe
f67dec624b overlay: 40ignition-ostree: make ignition-ostree-transposefs tolerant to debug kernels
It appears that on debug kernels the "/dev/disk/by-label/$label" device *can* not
appear at all (some sort of race condition) and thus calling `realpath` on it will
fail. Let's just make the call to `realpath` not be fatal so we can workaround this
issue that has been around in the kernel for some time.

Closes https://github.com/coreos/fedora-coreos-tracker/issues/1092
2022-03-21 17:15:24 -04:00
Jonathan Lebon
b2a95e3562 manifests: move zincati/pinger disablement to overlay.d
Add a new `prod` variable and use a conditional include to include the
new OSTree layer. (So then on e.g. `stable`, `prod` would be `true`.)
2022-03-07 11:26:43 -05:00
Dusty Mabe
b001ff75d5 coreos-teardown-initramfs: add space to bootif_kargs append
I missed this in 7bb4d6e.
2022-03-03 15:57:59 -05:00
Dusty Mabe
7bb4d6e9d4 coreos-teardown-initramfs: account for BOOTIF kernel argument
`nm-initrd-generator` will take into account the `BOOTIF=` kernel
argument. Let's account for that in our `propagate_initramfs_networking()`
code so don't propagate networking config if `BOOTIF` is the only
networking config.

Fixes https://github.com/coreos/fedora-coreos-tracker/issues/1048
2022-03-03 13:50:51 -05:00
Dusty Mabe
a456f26a3f 15fcos: add coreos-fix-systemd-journald.service
This service will detect when systemd-journald has been leaked from the
initramfs and kill it so the system can recover. This is a workaround
for https://github.com/coreos/fedora-coreos-tracker/issues/1108
2022-02-25 17:30:12 -05:00
Jonathan Lebon
53b41b51ee overlay.d: delete cosa-no-autolayer knob file
It's the default behaviour now:
https://github.com/coreos/coreos-assembler/pull/2665
2022-02-25 15:09:27 -05:00
Benjamin Gilbert
0a84651cb7 35coreos-live: support coreos.live.rootfs_url=tftp://
As discussed in
https://github.com/coreos/fedora-coreos-tracker/issues/1055, the
rootfs_url karg is preferred over initrd concatenation due to its lower
memory footprint and generally better performance.  We originally chose to
disallow its use with TFTP to reduce the feature matrix, but that forces
users without HTTP servers to fall back to concatenation.  Enable TFTP
so rootfs_url can be used in all environments.
2022-02-23 20:17:29 -05:00
Jonathan Lebon
0ff74bb229 overlay.d: add 35coreos-iptables
From `overlay.d/README.md`:

Contains systemd service and script for remaining on iptables-nft after
the migration to nft.

Split out because (1) it will roll out to next first, and (2) it can
more easily be deleted after the barrier release.

For more details, see:
https://github.com/coreos/fedora-coreos-tracker/issues/676
https://github.com/coreos/fedora-coreos-config/pull/1324
2022-02-16 17:44:31 -05:00
Nikita Dubrovskii
bd7a5c7891 overlay: verify filesystem labeled 'boot' is unique after ignition
Signed-off-by: Nikita Dubrovskii <nikita@linux.ibm.com>
2022-02-14 12:49:44 -05:00
Nikita Dubrovskii
4f7064ae70 overlay: add coreos-unique-boot.service
Aborts firstboot when system has several filesystems labeled `boot`

Fix for https://github.com/coreos/fedora-coreos-tracker/issues/976

Signed-off-by: Nikita Dubrovskii <nikita@linux.ibm.com>
2022-02-14 12:49:44 -05:00
Jonathan Lebon
a43c15ddea 35coreos-multipath: propagate config on first boot
In #829, we changed multipath config propagation to happen on subsequent
boots to handle upgrading nodes. Back then, we didn't yet support first
boot multipath, so not propagating on first boot didn't matter anyway.

But with #1011 we now support multipath on first boot. So we need to
adapt this so we always propagate, including on first boot.
2022-02-04 12:22:41 -05:00
Nikita Dubrovskii
6d7b9ad5c6 overlay.d: add udev rule for creating stable symlink to boot disk
Creates '/dev/disk/coreos-boot-disk' symlink to boot disk for
use by Ignition config, therefore 'storage.disks' section
could be defined without hardcoding /dev/sda, /dev/vda, etc.

Issue: https://github.com/coreos/fedora-coreos-tracker/issues/759

Signed-off-by: Nikita Dubrovskii <nikita@linux.ibm.com>
2022-02-02 11:34:15 -05:00
Jonathan Lebon
eed579f045 coreos-boot-edit: run rdcore bind-boot
This binds the bootloader to the bootfs and the bootfs to the rootfs.

Part of https://github.com/coreos/fedora-coreos-tracker/issues/976.
2022-01-27 15:36:47 -05:00
Jonathan Lebon
01a6e3e5e4 Use new overlay.d/cosa-no-autolayer option
Tell coreos-assembler to not automatically add the overlays to the final
manifest. Add references to the auto-generated OSTree layers in our
lower-level manifests where most appropriate.

Prep for using this to make an overlay only active on the `next-devel`
stream.

Requires: https://github.com/coreos/coreos-assembler/pull/2641
2022-01-24 10:14:36 -05:00
Dusty Mabe
03e6a53e03 overlay: update link to discussion forum
See:
- https://discussion.fedoraproject.org/t/fedora-discussion-2022-whats-new/35558
- https://github.com/coreos/fedora-coreos-tracker/pull/1063
2022-01-06 09:47:17 -05:00
François Rigault
d9531441a7 chrony: use /dev/ptp_hyperv on AzureStack
As implemented on Azure (d0ad4c8d78)
/dev/ptp_hyperv should be used as well on AzureStack.

See: https://github.com/coreos/fedora-coreos-tracker/issues/1053
2021-12-22 12:42:49 -05:00
Aashish Radhakrishnan
af7bcc8671 overlay/15fcos: coreos-check-ssh-keys: limit search to current boot
On re-provisioning a FCOS instance, Ignition will append notices like
"wrote ssh authorized keys file for user: %s"
to "/etc/issue.d/30_ssh_authorized_keys.issue".

The problem is that the journal from the previous install remains available
and multiple entries are displayed when the journal is searched.
The problem is fixed by limiting the journal output to the most recent boot.

Fixes https://github.com/coreos/fedora-coreos-tracker/issues/1033
2021-12-16 22:44:05 -05:00
Jonathan Lebon
3edd2f2889 coreos-copy-firstboot-network: support /etc/coreos-firstboot-network
This adds support for copying NetworkManager keyfiles from
`/etc/coreos-firstboot-network`. It's similar in functionality to the
existing support for `/boot/coreos-firstboot-network`, but is intended
for the live path (ISO or PXE boot) where there is no boot partition.

Users won't interact directly with this; instead, it's expected that
`coreos-installer` will provide high-level commands to customize the ISO
or PXE artifacts to embed keyfiles via the existing layered initrd
mechanisms.

Closes: https://github.com/coreos/fedora-coreos-tracker/issues/841
2021-12-14 17:45:41 -05:00
Jonathan Lebon
249f4ce624 coreos-copy-firstboot-network: enable in live images
Mostly consists of swapping out `ignition-diskful.target` for
`ignition-complete.target` and making the boot partition logic
conditional on `! is-live-image`.

Prep for supporting an alternate source directory in the live case.
2021-12-14 17:45:41 -05:00
Jonathan Lebon
d7031787f9 coreos-copy-firstboot-network: mkdir just before mount
That way, the script prelude purely consists of variable declarations.
2021-12-14 17:45:41 -05:00
Jonathan Lebon
dfd8fd7630 coreos-copy-firstboot-network: drop redundant Requires/After
We already run after `coreos-gpt-setup.service` which has those same
requirements. It was good to be explicit and specify it again, but in
the future this unit will also support running in live images, where we
can't require `/dev/disk/by-label/boot` to exist.
2021-12-14 17:45:41 -05:00
Jonathan Lebon
1bc55c4cab coreos-copy-firstboot-network: factor out keyfile copying
Prep for adding another callsite.
2021-12-14 17:45:41 -05:00
Jonathan Lebon
66f0120d69 coreos-copy-firstboot-network: rename variable
Rename `initramfs_firstboot_network_dir` to `boot_firstboot_network_dir`
as prep for supporting another firstboot network dir.
2021-12-14 17:45:41 -05:00
Jonathan Lebon
329e432f92 coreos-copy-firstboot-network: drop unused variable
Fixes: 277f8416af ("coreos-copy-firstboot-network.sh: Place stamp file if copied")
2021-12-14 17:45:41 -05:00
Jonathan Lebon
d0ad4c8d78 chrony: use /dev/ptp_hyperv instead of /dev/ptp0
From the last paragraph in:

https://docs.microsoft.com/en-us/azure/virtual-machines/linux/time-sync#check-for-ptp-clock-source

> In Linux VMs with Accelerated Networking enabled, you may see multiple
> PTP devices listed because the Mellanox mlx5 driver also creates a
> /dev/ptp device. Because the initialization order can be different
> each time Linux boots, the PTP device corresponding to the Azure host
> might be /dev/ptp0 or it might be /dev/ptp1, which makes it difficult
> to configure chronyd with the correct clock source. To solve this
> problem, the most recent Linux images have a udev rule that creates
> the symlink /dev/ptp_hyperv to whichever /dev/ptp entry corresponds to
> the Azure host. Chrony should be configured to use this symlink
> instead of /dev/ptp0 or /dev/ptp1.

See: https://github.com/coreos/fedora-coreos-tracker/issues/1031
2021-12-10 08:49:43 -05:00
Jonathan Lebon
11a11bcd53 ignition-ostree-uuid-root.service: add stricter ordering
In the multipath case, we're mounting
`/dev/disk/by-label/dm-mpath-root`, not `by-label/root`.

Also order against `sysroot.mount` because in the general case, there's
actually nothing that prevents the restamping to run at the same time as
the mount AFAICT if the `root` karg points to some other device path we
didn't predict.

See: https://github.com/openshift/os/issues/683 (which hopefully this
fixes).
2021-12-01 09:10:05 -05:00
Benjamin Gilbert
c832e4e7eb Revert "overlay: remove /boot/ignition on upgrade if present"
This was a fixup for existing nodes on upgrade.  Now that we've passed
through the F35 barrier release, drop the fixup.

Fixes https://github.com/coreos/fedora-coreos-config/issues/1094.

This reverts commit 6e178e717e.
2021-11-23 15:02:11 -05:00
Benjamin Gilbert
75109f5cf3 35coreos-ignition: allow setting kargs in live system if it's a no-op
In a live system, we can't set kargs in an Ignition config because we
don't control the bootloader settings.  If the config specifies kargs
anyway, we currently fail with "/dev/disk/by-label/boot: not a block
device", which isn't very clear.

In the live case, use the new rdcore kargs --current option to perform a
dry run on /proc/cmdline, and if it doesn't create the stamp file, we
don't need to do anything and can succeed anyway.  Otherwise, fail with a
clearer error message.

Fixes https://github.com/coreos/fedora-coreos-tracker/issues/917.
2021-11-18 21:39:51 -05:00
Dusty Mabe
05cc793162 coreos-teardown-initramfs: pick up default net cfg from afterburn dropin
This way we can only define it in one place.
2021-11-04 16:01:10 -04:00
Dusty Mabe
59ebaba9a9 switch default networking config to ip=auto
Upstream NM changed the behavior of `ip=dhcp,dhcp6` to also wait
20 seconds for DHCPv6. We don't want to require all users by default
to wait for DHCPv6 especially when it's doubtful most users even have
a ipv6 DHCP server. We can stick with our current behavior by utilizing
`ip=auto` instead.

Fixes https://github.com/coreos/fedora-coreos-tracker/issues/1000
2021-11-04 16:01:10 -04:00
Jonathan Lebon
6b385ce287 coreos-boot-edit: persist boot UUID in /run
The new `boot` karg will only show up on the second boot and onwards. So
for the first boot, let's persist it in `/run` to tell
`coreos-boot-mount-generator` the UUID to use.
2021-10-26 18:09:56 -04:00
Jonathan Lebon
13fa14b360 coreos-boot-edit: inject boot= karg on first boot
This ensures that the rootfs will always mount the correct boot
filesystem in the future (see previous patch).

Part of: https://github.com/coreos/fedora-coreos-tracker/issues/976
2021-10-26 18:09:56 -04:00
Jonathan Lebon
c9b5438781 coreos-boot-mount-generator: support boot= karg
This is analogous to `systemd-fstab-generator` parsing `root=` kargs.
There is a precedent for this in the FIPS module. In fact, we lift code
from there to make sure we're API compatible.

The goal of supporting a `boot` karg is to eliminate possible races for
the `by-label/boot` symlink in the real root if multiple exist.

Part of: https://github.com/coreos/fedora-coreos-tracker/issues/976
2021-10-26 18:09:56 -04:00
Jonathan Lebon
117429c9ed coreos-boot-edit: assume rdcore is in PATH
There are already other places which assume that `rdcore` is in `PATH`
so drop the full path to be more generic.
2021-10-26 18:09:56 -04:00
Jonathan Lebon
1a4cec5767 coreos-boot-mount-generator: handle rd.multipath=0
With the new `karg` helper, this is trivial to do now.
2021-10-26 18:09:56 -04:00
Jonathan Lebon
d42e52eb33 generator-lib.sh: add karg helper
Lifted from `coreos-boot-edit.sh`.

Prep for future patch.
2021-10-26 18:09:56 -04:00
Joseph Marrero
06ae4e521c Fix: coreos-livepxe-rootfs to print rootfs_url 2021-10-25 16:37:44 -04:00
Renata Ravanelli
572bbffeed Bug 1990506: Add dracut module for scsi rules
These rules will create the /dev/disk/by-id/scsi-* symlinks in the initramfs.

Signed-off-by: Renata Ravanelli <rravanel@redhat.com>
2021-10-20 16:21:45 -04:00
Timothée Ravier
bbd51c001c overlay: Remove workaround keeping /boot RW for kdump
kdump now writes the temporary initrd in `/var/lib/kdump` and the
SELinux policy changes have landed in Fedora 34. Thus remove the
workaround keeping `/boot` read write when kdump support is requested.

This reverts commit 3167d834e1.
2021-10-18 17:34:02 +02:00
Jonathan Lebon
8706b8b90b Move coreos-check-ignition-config from 15fcos to 05core
There's nothing FCOS specific and we want this functionality in RHCOS
too (see https://bugzilla.redhat.com/show_bug.cgi?id=1977949).
2021-10-15 11:36:43 -04:00
John Allberg
d3191e1c19 #975: bootup: ostree-remount may race with systemd-backlight and fail 2021-10-14 15:15:00 +00:00
Sohan Kunkerkar
0090bc6090 15fcos: change the location of Ignition report
Fixes coreos/fedora-coreos-tracker#977

This change helps to address the problem of displaying a warning
about running Ignition twice while reprovisioning a bare metal
CoreOS instance with a persistent /var partition.
2021-10-14 09:09:44 -04:00
Dusty Mabe
f8be4030d4 move multipathd.service workaround from overlay to manifest postprocess
This will allow us to conditionalize it based on the major Fedora
version when the fix starts landing in Fedora Linux (starting with
Rawhide). This also moves the workaround into a new dracut module
(36coreos-multipath-fix) and out of the old module (35coreos-multipath)
to make it easier to add from postprocess.
2021-10-12 16:40:54 -04:00
Dusty Mabe
65c9ccc46f move multipathd.socket workaround from overlay to manifest postprocess
This will allow us to conditionalize it based on the major Fedora
version. The fix has currently landed in rawhide but not F35 and
we want to continue to execute the check everywhere.
2021-10-12 16:40:54 -04:00
Jonathan Lebon
51194e0aac initramfs: ignore udevadm settle errors
We do `udevadm settle` in a few places to e.g. wait for symlinks to
update based on whatever operation we just did. But if `udevadm settle`
fails, we shouldn't fail the boot for it. It could be failing on some
completely unrelated thing (since it waits for all events).

Ideally in those scripts, we'd wait only for the specific events that we
care about. But even so, we should just opportunistically keep booting.
As a plus, even if we end up failing further down, we'll get a clearer
error.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=2009662
2021-10-01 15:42:26 -04:00
Luca BRUNO
2063c864e2 multipathd.socket: add start conditions via dropin
This adds a dropin for 'multipathd.socket' adding the same start
conditions that are present on the service unit. It is a temporary
workaround that can be removed once the packaged one is fixed.

Ref: https://bugzilla.redhat.com/show_bug.cgi?id=2008098
2021-09-28 15:33:54 -04:00
Timothée Ravier
02302b97c9 Revert "overaly/preset: Enable Count Me by default"
This is now enabled via the `90-default.preset` from fedora-release
(included since commit 83f5e12010).

See:
  - https://src.fedoraproject.org/rpms/fedora-release/pull-request/203
  - https://bugzilla.redhat.com/show_bug.cgi?id=1995495

This reverts commit 12ba5c2922.
2021-09-27 16:34:44 -04:00
Luca BRUNO
bdb1f57b5b overlay/dracut/multipath: remove problematic stop command
This is a temporary workaround to remove a problematic stop command
from `multipathd.service`, until the already-merged proper fix gets
released in dracut.
2021-09-24 15:48:52 -04:00
Benjamin Gilbert
a2aef3ee61 05core/coreos-liveiso-success: fix hang with systemd 239
RHEL 8 has systemd 239, which has
https://github.com/systemd/systemd/issues/9374.  As a result,
"journalctl -f ... | head -1" hangs because journalctl doesn't properly
exit.  Rewrite the check to call loginctl once per second until it finds
a session.  This approach is uglier, but the service only runs in the live
ISO, on QEMU, when there's no Ignition config, and when kola's virtio port
is open, so the minimal extra overhead shouldn't affect production
systems.

Fixes the kola testiso iso-live-login scenario in RHCOS.
2021-09-10 06:48:33 -04:00
Timothée Ravier
12ba5c2922 overaly/preset: Enable Count Me by default
Enable rpm-ostree Count Me timer by default for existing and new
installs.

See: https://github.com/coreos/fedora-coreos-tracker/issues/717
2021-08-18 13:59:02 -04:00
Sohan Kunkerkar
d429795257 15fcos: print warning If Ignition is run more than once
This change adds a warning on the serial console if Ignition
is run more than once. This is related to https://github.com/coreos/ignition/issues/1214
2021-08-06 17:50:57 -04:00
Benjamin Gilbert
7760720eda overlay: use Ignition result.json
As of https://github.com/coreos/ignition/pull/1250, Ignition produces
its own report similar to ignition.info.json, so use that instead of
making our own.
2021-08-06 13:10:15 -04:00
Timothée Ravier
b687264542 15fcos: Order coreos-check-ssh-keys before systemd-user-sessions
Run before user sessions to avoid reloading agetty.

See also: 386b6fedfd
2021-07-28 14:47:54 -04:00
Benjamin Gilbert
7d3c177f43 coreos-kargs-reboot: rename flag file
The RHCOS FIPS code is going to create the same flag file, so let's name
it something more generic.
2021-07-23 15:06:04 -04:00
Benjamin Gilbert
b944ebcd22 35coreos-ignition: perform kargs reboot with --force
Without --force, the boot process races with service shutdown, leaving
enough time for the disks stage to start.  With --force, systemd
immediately kills processes, unmounts filesystems, and reboots.

Fixes https://github.com/coreos/fedora-coreos-tracker/issues/896.
2021-07-23 14:52:48 -04:00
Jonathan Lebon
333d5068f0 15fcos: remember when Ignition ran and print on console
Some users sometimes may not realize that they're using a pre-booted
version of a CoreOS image. This makes things confusing because they then
don't understand why the Ignition config wasn't applied.

There's no way to consistently detect this, but at least we can print an
informational message about (1) when Ignition ran, and (2) how many
boots ago that was.

This enhances the Ignition issue we already write for whether a
user config was provided rather than creating a separate one.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=1977949
Related: https://github.com/coreos/ignition/issues/1214
2021-07-19 15:32:50 -04:00
Jonathan Lebon
386b6fedfd 15fcos: order coreos-check-ignition-config.service before systemd-user-sessions.service
That way we can avoid the `agetty --reload`.
2021-07-19 15:32:50 -04:00
Timothée Ravier
a1ab210d4d Revert "overlay.d/09misc: Fix mode for some files in /etc"
This is now safe to revert as this has been included in a testing
release with a barrier and will thus also be in the next stable release:
https://github.com/coreos/fedora-coreos-streams/pull/328

This reverts commit 73145e08b8.
2021-07-16 09:04:40 -04:00
Benjamin Gilbert
67a70afe3c overlay: chmod 600 /etc/sudoers.d/coreos-sudo-group
Apparently there are security scanners that object to mode 644.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1981979.
2021-07-15 16:15:52 -04:00
Benjamin Gilbert
54cacec493 overlay: add empty statoverride files in all overlays
This is a no-op, but helps document the functionality.

Part of https://github.com/coreos/coreos-assembler/pull/2293.
2021-07-15 16:15:52 -04:00
Dusty Mabe
0ba5d82eea 35coreos-live: add requirement on loop kmod
For some reason in rawhide this is no longer getting pulled in to the
initramfs. Since we require the use of it here then let's be explicit
and pull it in.
2021-07-13 18:07:31 -04:00
Jonathan Lebon
8b804863c6 35coreos-multipath: add Before=initrd-parse-etc.service in coreos-propagate-multipath-conf.service
Otherwise, we'll end up racing with `initrd-cleanup.service` which wants
to kill everything. It has `After=initrd.target` and we do have
`Before=initrd.target`, but that's not being respected, we think because
`initrd-parse-etc.service` does an explicit `systemctl start` on it.

Anyway, we need to dig more into this, but for now this will unblock us.
2021-07-09 17:16:00 -04:00
Dusty Mabe
876fda14ab 35coreos-network: order coreos-copy-firstboot-network before ignition-kargs
We've seen races with ignition-kargs.service, which accesses /boot rw.
Let's introduce some ordering here. Need to use `Before` because otherwise
we get a systemd ordering cycle.

Fixes: https://github.com/coreos/fedora-coreos-tracker/issues/883
2021-07-09 17:16:00 -04:00
Dusty Mabe
1aa60d962c unfreeze dracut, adapt for NM via systemd in initrd
Upstream dracut updated NM to run as a systemd service
(with full dbus support) in the initrd in [1]. Adapt our
systemd units to handle this case.

This should still work fine for RHCOS because we still have
`Before=dracut-initqueue.service`, which can be dropped when
everyone is on dracut 0.54+.

Fixes: https://github.com/coreos/fedora-coreos-tracker/issues/842
2021-07-09 17:16:00 -04:00
Benjamin Gilbert
f124289fc9 40ignition-ostree: update an ignition-fetch dep to fetch-offline
The fetch-offline stage now exists and runs before fetch, so update the
dep.  This shouldn't be a functional change.
2021-07-09 13:11:07 -04:00
Benjamin Gilbert
0414646748 35coreos-ignition: update ignition-setup-user for this repo 2021-07-09 13:11:07 -04:00
Benjamin Gilbert
6a624277d2 35coreos-ignition: add ignition-setup-user.service from Ignition repo
The service contains distro-specific assumptions, so move it out of the
upstream Ignition repo.  This commit is a straight `cp`.
2021-07-09 13:11:07 -04:00
Benjamin Gilbert
c2dd8ebd6f 35coreos-ignition: depend on coreos-live; assume is-live-image exists
Upstream Ignition can't assume is-live-image exists, because the distro
may not have provided it.  But we know the coreos-live module is providing
it, so drop the check.
2021-07-09 13:11:07 -04:00
Jonathan Lebon
dd54e8cb1a 35coreos-live: stop overriding NetworkManager-wait-online timeout to 5s
We originally did this in #326 because we wanted to support booting the
live ISO without networking. This was solved on the initramfs side by
the conditional networking work (#426). But for the real root, this was
still useful because if booting the ISO interactively on a system
without any network, or a non-DHCP network, we didn't want the user to
have to wait until the service timed out before getting a shell.

The core issue however is that we're requesting `network-online.target`
at all. It's an "active unit" which means that it's only pulled in the
transaction, possibly delaying boot, if another systemd unit needs it.
And ideally, no service would need it as per:

https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/

In our case, this unit was fedora-coreos-pinger. We drop that
requirement here:

https://github.com/coreos/fedora-coreos-pinger/pull/41

With that, we no longer pull in `network-online.target` and so no longer
delay reaching the console even if NetworkManager isn't able to get an
active connection for whatever reason. This matches how it works on
traditional Fedora as well.

Having a short timeout actually also had a counterproductive effect in
the automated install case. There, `coreos-installer.service` does pull
in `network-online.target` (which with
https://github.com/coreos/coreos-installer/pull/565 we could consider
dropping as advised by systemd, though we probably should bump the
number of retries some more in that case), but because of the short
timeout, we genuinely may not yet have the network fully up before we
run (see https://bugzilla.redhat.com/show_bug.cgi?id=1967483).
2021-07-08 16:34:42 -04:00
Jonathan Lebon
4719415a47 05core/firstboot-complete: also delete /boot/ignition if it exists
Once we're done provisioning, nuke any baked Ignition config since it
may contain secrets. We nuke the whole dir in the name of keeping
`/boot` neat and tidy.

Part of https://github.com/coreos/fedora-coreos-tracker/issues/889.
2021-07-08 15:06:46 -04:00
Jonathan Lebon
11595c2da9 overlay.d: drop .sh extensions on /usr/libexec shell scripts
I personally don't like including the .sh extension on installed
executable scripts because it "leaks" that it's a shell script, whereas
all we should care about is that it's an executable.
2021-07-08 15:06:46 -04:00
Jonathan Lebon
596e95b83e 05core: move coreos-ignition-firstboot-complete logic to separate script
We want to expand on it and it's awkward to do it in a systemd unit.
No change to the logic itself.
2021-07-08 15:06:46 -04:00
Jonathan Lebon
b380c97082 15fcos: make "ssh" all caps
The SSH host keys are also being printed in the issue, and there it's
all caps, so let's be consistent with that.
2021-07-08 15:06:46 -04:00
Jonathan Lebon
aaa09be009 15fcos: add missing dash in "user provided" 2021-07-08 15:06:46 -04:00
Benjamin Gilbert
6e178e717e overlay: remove /boot/ignition on upgrade if present
On subsequent boots, if /boot/ignition is present, remove it.  This fixes
up old nodes with a world-readable Ignition config in /boot.

https://github.com/coreos/fedora-coreos-tracker/issues/889
2021-07-08 14:24:09 -04:00
Benjamin Gilbert
d682520dd6 dracut: drop references to ignition-setup-base.service
It was dropped in Ignition 2.8.0 (e2d3fa3a61b3).
2021-07-08 12:54:54 -04:00
Jonathan Lebon
4b896a4110 05core: add coreos-ignition-firstboot-complete.service
This is mostly a mechanical move of ignition-firstboot-complete.service
to this repo. The only differences are tweaking the service unit name
and the Description and Documentation keys.

Prompted by tweaks we'd like to do here, and possibly eventually moving
it to the initramfs fully (merging it with coreos-boot-edit.service).

The renaming also allows us to loosen the order of operation in which
this is done, so that we can get this in to enable the new unit, while
keeping the old unit disabled, without necessarily waiting for the
original unit file itself to drop out of the `ignition` package.

For background, see: https://github.com/coreos/ignition/issues/1125
2021-07-07 14:40:22 -04:00
Jonathan Lebon
1fe884335b 40ignition-ostree: explicitly add zram kmod in initrd
We were relying on the zram kmod already being in the initramfs so far,
though that assumption for whatever reason is now incorrect in rawhide,
causing rootfs reprovisioning related tests to fail.

Anyway, we should be more explicit here about what our requirements are.
2021-07-06 11:14:40 -04:00
Jonathan Lebon
1c0ca68427 coreos-propagate-multipath-conf: run After=initrd-root-fs.target
We should only copy to the sysroot's `/etc` after we're sure it's all
set up. This is marked by `initrd-root-fs.target`.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=1974411
2021-06-29 09:08:28 -04:00
Jonathan Lebon
4d96eaaaff coreos-propagate-multipath-conf: trigger emergency.target on failure
We have this in all our units right now we consider critical. This is
one of them.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=1974411
2021-06-29 09:08:28 -04:00
Jonathan Lebon
fffae203a8 35coreos-ignition: use cp instead of mv
We can't `mv` out of the module directory since `/usr` is mounted
read-only in the dracut container when rpm-ostree runs it.

Follow up to #938.

Reported-by: Luca BRUNO <luca.bruno@coreos.com>
2021-06-28 09:32:05 -04:00
Dusty Mabe
da83a0aa8d overlay: ignition-ostree-firstboot-uuid: add workaround for FS without metadata_csum_seed
It will be some time before we can support metadata_csum_seed in grub
on all our target platforms. This commit adds a workaround for the case
where grub doesn't support it yet. We specifically workaround the
behavior of tune2fs that isn't sensitive to timing inconsistencies.

See https://github.com/coreos/fedora-coreos-tracker/issues/735#issuecomment-859605953

Fixes: https://github.com/coreos/fedora-coreos-tracker/issues/735
2021-06-15 13:36:33 -04:00
Dusty Mabe
dd186ad498 overlay: ignition-ostree-firstboot-uuid: use metadata_csum_seed fs feature
We're hitting issues in some cases where users are seeing the
`tune2fs -U random` on the /boot filesystem fail even though it's
ran directly after an `e2fsck`. To prevent needing a filesystem
check at all let's store the metadata checksum seed in the superblock
which will allow us to change the UUID without needing any filesystem
checks.

This was not possible before but we recently got a grub fix so that
having this filesystem feature enabled wouldn't cause grub2 to throw
an error.

- https://lists.gnu.org/archive/html/grub-devel/2021-06/msg00031.html

Fixes: https://github.com/coreos/fedora-coreos-tracker/issues/735
2021-06-15 13:36:33 -04:00
Timothée Ravier
73145e08b8 overlay.d/09misc: Fix mode for some files in /etc
Fix mode for existing system on bootup via a tmpfiles config. This is a
nop for new systems.

Workaround for https://github.com/coreos/fedora-coreos-tracker/issues/829
2021-06-08 14:14:51 -04:00
Timothée Ravier
b38d597102 overlay.d/README: Remove duplicated 20platform-chrony entry 2021-06-08 14:14:51 -04:00
Dusty Mabe
0488b7aef8 overlay: initramfs teardown: add support for coreos.force_persist_ip karg
This karg will override the check to see if Networking Configuration is
in the real root (i.e. written by Ignition most likely) and force
propagation of initramfs networking anyway. It should only be used in
cases where you know exactly what you are doing. For example, in the
problem described in https://bugzilla.redhat.com/show_bug.cgi?id=1958930
the networking configs didn't conflict at all, thus this could be used
safely. This option will help users who get stuck like they were in that
bug to get unstuck easily and then change their strategy later.

Fixes: https://github.com/coreos/fedora-coreos-tracker/issues/853
2021-06-07 19:08:12 -04:00
Dusty Mabe
2020aa459a overlay: initramfs teardown: delete compat code for hostname propagation
Everything is now newer than the minimimum requirement of NetworkManager 1.26.0.
2021-06-07 19:08:12 -04:00
Jonathan Lebon
0d85ee2d94 udev/90-coreos-device-mapper: ignore DM_ACTIVATION
We shouldn't conditionalize on `DM_ACTIVATION` here. It's used by device
mapper to differentiate between different types of events, but it
doesn't mean the device isn't active.

For example, in a multipath "reload" event, `DM_ACTIVATION` will be 0,
and the symlinks shouldn't flicker through this.

This fixes udev CHANGE events (e.g. from a partition table reread)
sometimes causing our multipath symlinks to go away even if the
multipath devices themselves are completely fine.

See: https://sourceware.org/git/?p=lvm2.git;a=blob;f=udev/10-dm.rules.in;h=b4fa52ab766effb04fc198fd52e6181ad5758eef;hb=HEAD#l91
See: 23a01fa679/multipath/11-dm-mpath.rules (L49)
2021-05-27 16:10:22 -04:00
Jonathan Lebon
8796041ac8 ignition-ostree-growfs: add support for multipath
We need special handling here to grow multipathed devices. The `sfdisk`
line is the same as was added in #392.
2021-05-27 16:10:22 -04:00
Jonathan Lebon
4664e64f1e coreos-gpt-setup: add support for multipath
`lsblk` doesn't know how to query the `PKNAME` and `PTUUID` on multipath
devices, so handle that case.
2021-05-27 16:10:22 -04:00
Jonathan Lebon
39c9e73f92 Add support for multipath on firstboot
As we've learned in https://bugzilla.redhat.com/show_bug.cgi?id=1954025,
we can't assume that we can use any individual path before multipathd
unifies them. This means that it's not correct to turn it on from the
second boot onwards only, which is the current approach.

So we need to support multipath at first boot, and further, we need to
delay all I/O to the boot disk to *after* multipathd takes ownership.

This patch does this by introducing a generator and a target. We need to
use a target because `After=multipathd.service` is not enough to ensure
that multipathd finished setting up the devices. The target explicitly
waits for the multipathed boot device to appear. (Note though that we
*can't* assume that root is also directly on top of the multipath device
because of LUKS-on-root.)

This creates an awkward UX, which is that multipath is the only root
setup option which is *not* driven by Ignition but instead set up behind
its back.

This will be somewhat better once Ignition supports kernel arguments,
because the `rd.multipath` karg can be fed that way. But long-term, we
should consider teaching Ignition to configure multipath devices. This
would fix the configuration problem (right now, we only support
first-booting with default configs), and would free users from adding
the necessary kargs, which would be done by the rootmap code as usual.

But still, even in that world, there's a gap where the Ignition config
could be on the boot device, in which case multipathd would need to be
turned on beforehand.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1954025
2021-05-27 16:10:22 -04:00
Micah Abbott
c9be4ca5cc overlay: helper service for warning about cgroupsv1
This will check if a system is still using cgroupsv1 and generate a
message to be printed as part of CLHM.

Co-authored-by: Dusty Mabe <dusty@dustymabe.com>
2021-05-26 09:36:46 -04:00
Colin Walters
1fc7cd93ef overlay/05core: Add a new /usr/lib/coreos/generator-lib.sh
Hopefully in the future we'll create a nice `rdcore` like Rust
place for our generators.

For now let's factor out a little helper library.
2021-05-20 13:55:32 -04:00
Colin Walters
508afe35dc coreos-boot-mount-generator: Always use mpath for /boot if rd.multipath
If root is on multipath (which is today for CoreOS always `rd.multipath=default`)
then we *know* we must use it for `/boot`.  We're not going to
support "tearing" where `/boot` is on a non-mpath device but
`/` is on mpath.

The current code is I believe racy because at the time the generator
runs (and systemd generators run *early*), we're querying the
"current" properties of the device at
`/dev/disk/by-label/boot`.  But multipathd could still be in
the process of setting up and replacing the target of that
symlink.  This can cause systemd to tear down and reinitialize
the mount, causing races.

https://bugzilla.redhat.com/show_bug.cgi?id=1944660
2021-05-19 14:52:25 -04:00
Colin Walters
78b5cd7532 udev/90-coreos-device-mapper: Create label links in real root too
We're currently gating on `ENV{DM_SUSPENDED}=="Active"` but
`10-dm.rules` does:

```
ENV{DM_SUSPENDED}=="Active", ENV{DM_SUSPENDED}="0"
ENV{DM_SUSPENDED}=="Suspended", ENV{DM_SUSPENDED}="1"
```

So what I think is happening here is that our rule happens to
run before that kicks in, so we make the links once, but not
thereafter.

Change the condition to match what `13-dm-disk.rules` from
LVM is doing.

Also slightly reorder the code and add some comments for extra clarity.
2021-05-19 14:52:25 -04:00
Jonathan Lebon
3f19340ab9 live-generator: don't call man bootup
Even though it's on a comment line, because it's in a heredoc, bash does
try to execute this. This fails on FCOS thankfully because there is no
`man` on FCOS, but it still logs an error message. (And... any derived
system which does ship `man`, I think this actually would dump the
manpage into the unit.)
2021-05-18 13:40:39 -04:00
Colin Walters
47cc852b50 coreos-boot-mount-generator: Move all "exit 0" checks to early on
This way it's a lot clearer under which conditions the generator
runs.
2021-05-18 12:08:49 -04:00
Jonathan Lebon
5b96230305 ignition-ostree-uuid-root: also run if root= is provided
We want it to run in the multipath case, in which users may provide a
`root=` karg. So drop that condition.

This service is already queued against `ignition-diskful.target` so it
only runs on first boot. It also already correctly does nothing if
somehow the UUID was already changed.
2021-05-18 11:03:12 -04:00
Jonathan Lebon
be9e9ecef1 coreos-gpt-setup: log whether sgdisk was called
Helpful for debugging.
2021-05-18 11:03:12 -04:00
Jonathan Lebon
2b22dcb626 overlay: convert more unit descriptions to Title Case
This is the convention in systemd and in most of our other units.
2021-05-18 11:03:12 -04:00
Jonathan Lebon
caa586a5f7 ignition-ostree-growfs: fix dependency to sysroot mount
In the case of multipath,
`ignition-ostree-mount-firstboot-sysroot.service` won't kick in because
the `root=` karg is already present on first boot. But we still need to
grow the partition and filesystem in that case.

What we really mean here is that the sysroot should already be mounted
before we growfs. Drop the `Requires=` and add `sysroot.mount` to the
list of `After=` so that we cover the case where the sysroot is mounted
via the mount unit generated via systemd-fstab-generator from the
`root=` karg.
2021-05-18 11:03:12 -04:00
Jonathan Lebon
3fc2e10fc0 ignition-ostree-growfs: don't conditionalize on root= karg
Anaconda is long gone now. We do want this service to always run on
first boot, regardless of whether there's a `root=` karg or not. In the
case of multipath, a `root=` karg is expected on first boot.
2021-05-18 11:03:12 -04:00
Stephen Lowrie
c7d25b5632 35coreos-ignition: add coreos-kargs
Co-authored-by: Jonathan Lebon <jonathan@jlebon.com>
2021-05-14 16:59:51 -04:00
Dusty Mabe
9dada2ff05 overlay: update reminder for f35 cycle
Since I'm going through all of the TODO f34 items now
let's update this one to remind us in the f35 cycle if
we haven't already removed it before then.
2021-04-30 16:35:37 -04:00
Dusty Mabe
1054c6b6ee overlay: don't ship seq in initrd
This was added in ad5eb32 for clevis, but clevis has been
changed to no longer need `seq` [1] so we can drop it.

[1] https://github.com/latchset/clevis/pull/295
2021-04-30 16:35:37 -04:00
Dusty Mabe
474c87bddd overlay: remove coreos-reset-stub-resolv-selinux-context units
This was added in 4356928. It's no longer needed because the contexts
are correct in F34+ and don't need to be "fixed".
2021-04-30 16:35:37 -04:00
Jonathan Lebon
af44cb3673 Add temporary workaround for agetty --reload SELinux denial
In f34+, we're hitting an SELinux denial from c-l-h-m trying to do
`agetty --reload` and causing `/run/agetty.reload` to be created with
the wrong label. This then prevents agetty from adding an inotify watch
to know when to reload the prompt to display new information. For more
details, see:

https://github.com/coreos/fedora-coreos-config/pull/859#issuecomment-783713383

This is tracked at https://bugzilla.redhat.com/show_bug.cgi?id=1932053.

With this workaround, we create the file up front in the initrd so that
it gets relabeled by systemd on switchroot and thus will already exists
with the right label well before c-l-h-m or anything else tries to
`agetty --reload`.
2021-04-29 15:02:36 -04:00
Dusty Mabe
f799123fb8 Revert "overlay.d/35coreos-network: don't bring up NM if not needed"
This reverts commit 2747e11aa0.
Now that we have a dracut build in f34 with the fixes, we don't
need these workarounds any longer.
2021-04-22 14:30:19 -04:00
Andy McCrae
3969ff9024 Move comments in systemd services to own line
Comments in systemd services at the end of lines cause unnecessary
warning messges:

Failed to add dependency on on, ignoring: Invalid argument
Failed to add dependency on dracut, ignoring: Invalid argument
Failed to add dependency on 053+, ignoring: Invalid argument

The services would still start so this is a cosmetic change only.
2021-04-22 09:40:16 -04:00
Jonathan Lebon
d2776ed618 35coreos-live/coreos-livepxe-rootfs: retry fetching rootfs forever
We don't know how long it will take for networking to come up, so let's
match Ignition's semantic of retrying to fetch remote resources forever.

`curl` doesn't natively have support for this, so wrap it in a `while`
loop. This also works around the fact that el8's `curl` doesn't support
`--retry-all-errors`.

This was previously added in #929.
2021-04-16 11:31:36 -04:00
Dusty Mabe
2747e11aa0 overlay.d/35coreos-network: don't bring up NM if not needed
In dracut 053+ dracut starting running NetworkManager from a systemd
unit if systemd was used to start the system [1]. That systemd unit
will always get started if there is any NM configuration. Let's make
it only get started if we actually need the network. This is a
simplified version of the more complicated proposed fix upstream [2].

[1] https://github.com/dracutdevs/dracut/commit/c17c5b7
[2] https://github.com/dracutdevs/dracut/pull/1347

Fixes: https://github.com/coreos/fedora-coreos-tracker/issues/782
2021-04-16 11:17:12 -04:00
Dusty Mabe
843255067e overlay.d/35coreos-network: handle new nm-run.service in initramfs
In dracut 053+ dracut starting running NetworkManager from a systemd
unit if systemd was used to start the system [1]. Let's adapt for that
by ordering our units before `nm-run.service`. We'll also keep the
ordering on dracut-initqueue.service for now for backwards compatibility
and it's harmless to keep around.

[1] https://github.com/dracutdevs/dracut/commit/c17c5b7
2021-04-16 11:17:12 -04:00
Miroslav Lichvar
1c4ee02549 overlay.d/20platform-chrony: Fix misconfiguration with leap-smearing servers
NTP servers provided by AWS and GCP implement a "leap smear" to
hide leap seconds from clients. When chronyd is configured with
leap-smearing servers, the leapsectz directive must be disabled to
avoid the kernel making a wrong correction of the clock at the time of
the leap second.

Disable any leapsectz directives coming from the default configuration
and enable it only in the Azure case (the PTP clock doesn't provide
information about leap seconds).
2021-04-14 09:24:10 +00:00
Jonathan Lebon
66d0a8d672 presets: enable clevis-luks-askpass.path
This is required for *non-root* Clevis LUKS devices to be unlocked
successfully on subsequent boots. We could enable it at runtime when we
detect Clevis being used, but path units are normally lightweight, and
having it enabled by default matches the configuration in the initrd.

Closes: https://github.com/coreos/fedora-coreos-tracker/issues/687
Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1947490
2021-04-12 10:23:54 -04:00
Kelvin Fan
3167d834e1 12kdump: Remount /boot rw before kdump.service
Right now, `kdump` fails to generate its initramfs because
it cannot place it next to our default initramfs in
`/boot/ostree`, which is read-only.
This is a workaround to get `kdump` working again until
it gains the ability to place its generated initramfs
in a different location (e.g. `/var/lib/kdump`).

xref: https://bugzilla.redhat.com/show_bug.cgi?id=1918493
2021-04-08 16:37:45 -04:00
Jonathan Lebon
67f5a40785 35coreos-network: enable initrd networking on azurestack
Just like on Azure, Afterburn needs networking for hostname fetching and
boot check-in. Ideally, Afterburn would request it itself but this is
where that logic lives for now (see [1]).

[1] https://github.com/coreos/fedora-coreos-tracker/blob/master/internals/README-initramfs.md#networking
2021-04-08 13:34:11 -04:00
Dusty Mabe
b4a65864ef 35coreos-live/coreos-livepxe-rootfs: add in connectivity check before downloading
This should help us get around some race conditions on startup
where we've seen curl exit with "No route to host" errors. This
most likely happens because the Networking in the kernel is still
being brought up (seen more in complex networking scenarios) and
curl hits that error the first time it tries. Since "No route to
host" isn't considered retryable, curl exits.

Instead let's just verify we can get to the remote at all in an
initial `curl --head` call. In this one we'll use --retry-all-errors
so that we will retry all errors. Once the connectivity to the remote
is verified then it should be safe to start downloading.
2021-04-06 15:58:03 -04:00
Jonathan Lebon
ef7c4b9055 overlay: propagate rootfs mountOptions to rootflags karg
Right now, specifying `mountOptions` for the rootfs in the Ignition
config is ignored. To fix that, we simply need to have
`coreos-rootflags` inspect the Ignition config if the rootfs was
reprovisioned and extract the field.

This then takes effect on first boot (via
`ignition-ostree-mount-sysroot.sh` calling out to it) and subsequent
boots (via `rdcore rootmap` calling out to `coreos-rootflags`).

Closes: https://github.com/coreos/fedora-coreos-config/issues/805
2021-03-24 09:13:09 -04:00
Jonathan Lebon
a57a999c4f overlay: always use prjquota for XFS rootfs
By default, we use `prjquota` for the rootfs for container orchestrators
to monitor and set drive space limits.

However, with the added support for rootfs reprovisioning, we made this
conditional on the rootfs not being reprovisioned, with the assumption
that you can just set whatever options you'd like instead. Though
actually doing that is really awkward right now, and it requires
surfacing prjquota in user documentations (see
https://bugzilla.redhat.com/show_bug.cgi?id=1940704#c2).

Since AFAICT `prjquota` doesn't actually have any significant overhead,
let's just simplify the messaging to: we *always* enable prjquota on XFS
root filesystems. Users who want to override this can fallback to
`rpm-ostree kargs` (and eventually once we have
https://github.com/coreos/fedora-coreos-config/issues/805, to
`mountOptions: []`).

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1940704
2021-03-19 14:21:52 -04:00
Jonathan Lebon
5228316f76 overlay/growfs: handle broken lsblk in el8
Sometimes `lsblk` returns devices in the wrong order, so we can't rely
on it to iterate over the devices in hierarchical order. Instead, use
the `holders/` directory ourselves directly and use `--nodeps` when
calling `lsblk`.

See: https://bugzilla.redhat.com/show_bug.cgi?id=1934174#c4
See: https://bugzilla.redhat.com/show_bug.cgi?id=1940607
See: https://github.com/coreos/coreos-installer/pull/453
2021-03-19 12:47:27 -04:00
Jonathan Lebon
195ae1fc4b overlay: don't restamp rootfs UUID if reprovisioning
Since we've created a new filesystem anyway.

This implicitly also works around the service racing against the
`by-label/root` symlink not being up to date after reprovisioning (which
`ignition-ostree-transposefs-restore.service` now intercepts and fixes).
2021-03-19 12:47:27 -04:00
Luca BRUNO
570fb45df7 fedora-coreos-base: add nm-cloud-setup, forward platform variables
This adds nm-cloud-setup package to fedora-coreos-base set,
and configures the relevant environment variable for AWS, Azure,
and GCP.
2021-03-17 12:40:16 -04:00
Jonathan Lebon
c2d88f0282 overlay/growfs: support growing LUKS containers
We need to support in-place LUKS root reprovisioning. This is pretty
straightforward, modulo the terrible clevis hack used to resize the
container. We'll want to circle back and clean this up once there's a
better interface to do this (but at least until then, we have tests
which cover this).

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1934174
2021-03-10 09:57:15 -05:00
Jonathan Lebon
43437b494d overlay/growfs: fix in-place root reprovisioning detection
The semantic we want to capture for auto-growing the rootfs is that we
want it to kick in as long as either no rootfs reprovisioning happened,
or it was in-place (i.e. reused the same partition).

We detected this by checking that the block device (i.e. partition)
backing the rootfs and its size didn't change. But this breaks with
in-place LUKS reprovisioning because the immediate block device does
change (to the LUKS container), even though it's ultimately still backed
by the same untouched partition.

Fix this by (1) verifying that the rootfs is still ultimately backed by
the same partition, and (2) that partition has not been resized.

This doesn't actually add support for growing LUKS containers yet, but
it's prep for that.
2021-03-10 09:57:15 -05:00
Jonathan Lebon
544085a8a7 overlay/growfs: rename variable
There's lots of `eval`s going on here. Let's copy the rootfs format name
to a dedicated variable instead of re-using the same `eval`'ed name.
2021-03-09 15:59:14 -05:00
Jonathan Lebon
eaca26086e overlay: rename coreos-growpart to ignition-ostree-growfs
Now that coreos-growpart is only in the initramfs, its scope is
essentially reduced to handling the `/sysroot`. Let's formalize this by
renaming the script to match the service which calls it and dropping
support for passing the target path as an argument.

Also freshen up the comments at the top of the file.
2021-03-09 15:59:14 -05:00
Jonathan Lebon
cdcb78f3ad overlay: nuke obsolete coreos-growpart.service preset
That service no longer runs in the real root. The preset should've been
removed as part of the move to the initramfs way back when.
2021-03-09 15:59:14 -05:00
Jonathan Lebon
ad5eb32f8b overlay: temporarily ship seq in initrd
Previously we pinned clevis to v15 in order to work around
https://github.com/latchset/clevis/pull/295.

But overrides are not set up in the tagger for mechanical streams, so we
can't easily pin in `branched` and `rawhide`. Let's just unpin and
temporarily ship `seq` ourselves to work around this. Put that temporary
hack in `40ignition-ostree` since that's the closest module conceptually
to clevis.
2021-03-09 15:04:51 -05:00
Jonathan Lebon
0899d3cad1 overlay: add warning if rootfs < 8G
We've recently had our first case of a "trapped" rootfs running out of
space for upgrades:

https://github.com/coreos/fedora-coreos-tracker/issues/731

Until we actually implement stronger behaviour for this, let's
explicitly check for this case and emit a warning if we detect it. In
the future, we'll look at making this a hard error by default (with an
escape hatch).

For more information, see:

https://github.com/coreos/fedora-coreos-tracker/issues/586#issuecomment-777220000
2021-03-04 20:10:47 -05:00
Jonathan Lebon
2fcf25092e transposefs: error out cleanly if less than 1G of RAM available
I commonly do `cosa run` to test something related to rootfs
reprovisioning and forget to allocate more RAM. The failure mode is a
massive spam of "Input/output error" messages from `cp` unable to copy
more files into RAM (and there doesn't seem to be a way to have it fail
on first error; yet another reason we should rewrite this into !shell).

Instead, just sanity-check that we have at least 1G of RAM and error out
with a nice and clear message if not.
2021-03-04 09:08:08 -05:00
Colin Walters
bc2e5963f0 overlay/40-coreos-systemd:: Add systemd-firstboot disablement here too
This way we're moving closer to having our systemd overrides in one place.
2021-02-23 12:01:05 -05:00
Colin Walters
2fef5a5dfc 40-coreos-systemd.preset: Disable systemd-sysext.service
I was just reading the pre-release notes: https://lists.freedesktop.org/archives/systemd-devel/2021-February/046147.html

This hasn't been tested with ostree/rpm-ostree and heavily overlaps
with the latter.  Preemptively disable the service; it will hopefully
be subpackaged though for Fedora.
2021-02-23 12:01:05 -05:00
Colin Walters
b287a6a529 overlay: create 40-coreos-systemd.preset
Let's keep 40-coreos.preset to be only `enable` stanzas for
"our stuff" overall.

Create a separate `40-coreos-systemd.preset` which only
relates to systemd things because it really is a distinct
problem domain.
2021-02-23 12:01:05 -05:00
Jonathan Lebon
01d59373c0 presets: disable systemd-oomd.service
It requires swap, which we don't turn on by default. (It also requires
cgroups v2, which we currently don't turn on by default but are aiming
to in the near future.)
2021-02-19 09:31:25 -05:00
Kelvin Fan
1e3253538d overlay.d/05core: Remove CLHM-{issuegen,motdgen} units
These units no longer exist after CLHM v0.21.
2021-02-18 14:57:57 -05:00
Timothée Ravier
75c4b1049e overlay.d/20platform-chrony: Exit early if already run
Make sure we exit early if:
  * the config is not the default one and as been modified
  * this script already generated a configuration for chrony

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1924869
2021-02-17 08:45:57 -05:00
Timothée Ravier
02bda433f7 overlay.d/20platform-chrony: Minor whitespace fix 2021-02-17 08:45:57 -05:00
Jonathan Lebon
eb9d88e95c overlay: propagate multipath config post-firstboot
Because multipath support now works on the second boot, the propagation
code in `coreos-teardown-network.service` didn't work. Split that code
out into a separate dracut module and have it run on subsequent boots.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1920571
2021-01-29 09:13:21 -05:00
Jonathan Lebon
12bb577750 overlay/teardown: assume coreos-relabel exists
We can assume now that we always have coreos-relabel and drop the
fallback to relabeling via tmpfiles. This dates back from when this code
lived in ignition-dracut and it felt odd to rely on coreos-relabel.
2021-01-29 09:13:21 -05:00
Colin Walters
efc6d79515 overlay: Disable systemd-firstboot even if installed
I'm trying to hack on systemd using `cosa build-fast`, which
doesn't run through the `remove-from-packages` path which we
use to disable systemd-firstboot.

Let's also add this cheap mechanism to disable it even if it's
installed.
2021-01-25 13:36:51 -05:00
Jonathan Lebon
8aa57b012c 40ignition-ostree: make transposefs-related errors hard
Noticed that `ignition-ostree-transposefs-save.service` didn't break the
boot immediately after an error while debugging logs with @mike-nguyen.
Let's cargo-cult the `OnFailure` bits into those services too.

I think we may still be suffering from
https://github.com/systemd/systemd/issues/14142 in RHEL systemd.
2021-01-21 04:00:29 -05:00
Jonathan Lebon
3e3fdd3cdd coreos-teardown-initramfs: make Description use Title Case
That's the convention for systemd unit descriptions.
2021-01-20 09:33:31 -05:00
Jonathan Lebon
505ed511a4 coreos-growpart: drop support for growing multipathed disks
The model we're moving towards is one where multipath enablement is
configured via Ignition and so only takes effect on the next boot:

https://github.com/openshift/os/pull/484#issuecomment-760454177

Therefore, we don't need to worry here about support for growing a
multipathed root partition. This simplifies a big chunk of the script.
2021-01-20 09:33:31 -05:00
Colin Walters
1de21ffa98 overlay/boot-mount-generator: Mount /boot read-only,nodev,nosuid
ostree has had support for leaving `/boot` mounted read-only
for a long time: https://github.com/ostreedev/ostree/pull/1767
(And then later extended to `/sysroot`)

Particularly for CoreOS, only a few things should be touching
`/boot`, and we control all of them.  Those projects should
create a new mount namespace and remount these partitions
writable just while they need it.

The main thing we're accomplishing here is making the system
more resilient against accidental damage from a sysadmin
root shell as well as configuration management tools like
Puppet/Ansible.  None of those should be directly manipulating
files on these partitions, they should go through the API
of one of our projects (e.g. `rpm-ostree kargs`, `bootupctl`) etc.

While we're here, also add `nodev,nosuid` because some
OS hardening scanners like to see this.  IMO it's of minimal
value, but hey, might as well.
2021-01-06 21:28:15 -05:00
Micah Abbott
8c07b73914 overlay: add new module for installing Azure udev rules
We want the Azure udev rules present in the initrd, so that Ignition
is able to detect the disks and act on them.

If the udev rules end up being installed into the initramfs as part of
the WALinuxAgent-udev package, the dracut module should be removed.

See https://bugzilla.redhat.com/show_bug.cgi?id=1909287
2021-01-06 09:12:08 -05:00
Micah Abbott
b30c72bc80 use WALinuxAgent-udev package for Azure udev rules
BZ#1748432 was filed while working on #159 and the udev rules were
split out into a separate package as part of F32.  Let's stop carrying
the rules in the overlay and use the provided package now.
2021-01-06 09:12:08 -05:00
Jonathan Lebon
bdcebad9c0 05core: add || exit 1 to systemctl add-{requires,wants} calls
Because dracut directly sources `module-setup.sh` scripts and isn't
compatible with `set -e`, we can't just turn it on in our modules.
Instead, let's just manually add `|| exit 1` in all the calls to
`systemctl add-{requires,wants}` so that we catch regressions like
https://github.com/coreos/fedora-coreos-config/issues/799 at build time
in the future.
2021-01-04 17:15:06 -05:00
Jonathan Lebon
94c435f03e 05core: re-order and rename some dracut modules
Unlike `ln -sf`, `systemctl add-{requires,wants}` wants to verify that
the target and member units all exist. Because we had some dracut
modules which ran earlier than the `30ignition` module, we would lose
the service enablements which hook into e.g. `ignition-complete.target`
and related units.

Let's simply rename our modules so that they're ordered after
`30ignition`. While we're here, let's consistently prefix them by
`coreos-`. So overall, the changes are:
- `30ignition-coreos` -> `35coreos-ignition`
- `20live` -> `35coreos-live`
- `15coreos-network` -> `35coreos-network`

I've verified that there are now no "Failed to add dependency on unit"
error messages at build-time. (The next patch enforces this more
strictly.)

Fixes: #778
Closes: #799
2021-01-04 17:15:06 -05:00
Benjamin Gilbert
16591e9fb7 40ignition-ostree: copy ESP contents as independent filesystems
If the firmware writes to an individual replica, the RAID will
desynchronize.  Linux md will return reads from either replica, and then
any dependent writes could corrupt the filesystem.  To prevent this,
fcct will no longer put the ESP on a RAID; instead we create multiple
independent filesystems and copy the contents to each.  This is okay
because bootupd and fwupd should be the only things that care about the
contents of the ESP.

Don't worry too much about backward compatibility because we're making
this change soon after the functionality landed, and before it was
documented.  For the record, old configs will fail on new systems
(because the partitions will be RAID members) but new configs will
skip copying /boot on old systems (because there's no filesystem labeled
"EFI-SYSTEM").
2020-12-22 16:51:51 -05:00
Benjamin Gilbert
dd848b8943 40ignition-ostree: add get_partlabels_for_parttype helper 2020-12-22 16:51:51 -05:00
Benjamin Gilbert
b7b7eefa80 40ignition-ostree: create mountpoint in mount_verbose 2020-12-22 16:51:51 -05:00
Benjamin Gilbert
2b371eb1ce 40ignition-ostree: rename mount_and_restore_filesystem
Make it clear that mount_and_restore_filesystem locates the filesystem
by FS label.
2020-12-22 16:51:51 -05:00
Benjamin Gilbert
33a7393a51 coreos-boot-mount-generator: stop mounting /boot/efi
On RAID systems we're now going to have multiple ESPs, no one of which is
the "canonical ESP", so there's nothing we can mount here.  Drop the
mount unit.

Fixes: https://github.com/coreos/fedora-coreos-tracker/issues/694
2020-12-22 16:51:51 -05:00
Benjamin Gilbert
9f6896a8e0 40ignition-ostree: silence mkfs.xfs
Avoid a bunch of incidental mkfs output in the journal for
ignition-ostree-transposefs-detect.service.
2020-12-22 16:51:51 -05:00
Kelvin Fan
a0ca59e97b overlay.d/15fcos: Stop utilizing c-l-h-m private dir
Drop issue file snippets directly into `/etc/issue.d`, which
is ready by `agetty`.

Following https://github.com/coreos/console-login-helper-messages/pull/91,
new versions of console-login-helper-messages will no longer
support users dropping files into its private directories
(e.g. `/run/console-login-helper-messages/issue.d`).
2020-12-18 14:18:26 -05:00
Jonathan Lebon
cff8813cf9 40ignition-ostree/transposefs: load zram with num_devices=0
By default, upon inserting the zram module, it'll automatically create
one zram device. Because we don't know if we're the first ones or not,
it's not safe to make use of that device.

Instead, tell it to not do that so that if we *are* the first ones to
load the module, we don't end up with an extra zram device. If we
aren't, it's a no-op.
2020-12-18 09:06:36 -05:00
Jonathan Lebon
66d15b6152 40ignition-ostree/transposefs: relabel the root of reprovisioned filesystems
When we do `mv -t $mountpoint`, everything we move *into* the
mountpoints gets its SELinux label preserved, but the root of the
filesystem itself (i.e. `$mountpoint`) doesn't get relabeled.

This is something that `rsync` would've done for us if we had used that
instead of `mv`. (Though I recall using `rsync` was also slower than
`mv` in my tests.) Anyway, I think eventually we want to rewrite some of
this stuff into rdcore.
2020-12-18 09:06:16 -05:00
Jonathan Lebon
e44969f6ab 40ignition-ostree/transposefs: factor out function to restore fs
We're doing this three times now; let's just factor it out. That way
it's obvious that we're following the exact same pattern each time.
2020-12-18 09:06:16 -05:00
Jonathan Lebon
e6f06327a0 40ignition-ostree/transposefs: also trigger udev on by-label link mismatch for ESP
Just saw the same issue described in 6c9f15c88 happen for
`/dev/disk/by-label/EFI-SYSTEM` locally.
2020-12-18 09:06:16 -05:00
Jonathan Lebon
6c9f15c885 40ignition-ostree: trigger udev on by-label link mismatch
Sometimes, the `/dev/disk/by-label/root` symlink still points to the
original block device rather than the latest one. This then leads to
e.g. us mounting the wrong device and get errors like:

```
[   54.814061] ignition-ostree-transposefs[938]: mount: /sysroot: unknown filesystem type 'crypto_LUKS'.
```

It's not that we're not waiting long enough for udev to update them.
It's more like udev misses those events entirely. Filed:

https://bugzilla.redhat.com/show_bug.cgi?id=1908780

Since we know what the underlying device should be (from the Ignition
config), let's just detect those cases and do a `udevadm trigger`.
2020-12-17 12:54:43 -05:00
Sohan Kunkerkar
8ef32d7435 overlay.d: remove 21dhcp-chrony
Now that the upstream patch for chrony change has merged (https://src.fedoraproject.org/rpms/chrony/pull-request/3)
and available in F-33, we can safely remove this code, which was a temporary fix to allow chrony propagate NTP servers
via DHCP.
2020-12-16 19:20:18 -05:00
Scott Edlund
e026dcb375 overlay.d: 40ignition-ostree: use zram instead of tmpfs for switching root
Reduces memory used for switching the root filesystem layout by
about 40%, allowing smaller memory machines to do so.
2020-12-16 13:45:25 -05:00
Dusty Mabe
b9a2c39e44 overlay.d: 15fcos: run selinux fixup once on startup
This is so we can order it before NetworkManager starts up to prevent
a few denials that happen because NM and the path unit are racing.
2020-12-15 15:03:07 -05:00
Dusty Mabe
435692838e overlay: 15fcos: service to fix SELinux context on stub-resolv.conf
The way systemd renames this symlink means the context of the file
is wrong. Discussion on how to fix this is ongoing in
https://github.com/systemd/systemd/pull/17976
2020-12-15 15:03:07 -05:00
Kelvin Fan
5af0a19219 overlay.d: Use systemctl {add-wants, add-requires}
Use `systemctl`'s built-in way of adding `Wants=` and `Requires=`
dependencies, since this is the recommended way of adding dependencies
and we can do so with a single command.
2020-12-15 11:17:50 -05:00
Dusty Mabe
ff09e91ca0 coreos-teardown-initramfs: don't propagate purely default network configs
If the config we are going to copy into the real root is just the
defaults let's just not copy any configuration in because
NetworkManager's "unconfigured" behavior is good enough.

This has side benefits of making the coreos-installer --copy-network
workflow slightly more intuitive.

Fixes: https://github.com/coreos/fedora-coreos-tracker/issues/696
2020-12-10 17:55:33 -05:00
Benjamin Gilbert
a3c7203397 40ignition-ostree: fix possible transposefs-restore race
Serialize transposefs-restore and firstboot-uuid, since they both want
to mutate the root filesystem.  Also have firstboot-uuid wait for udev to
settle, since closing a device node for write can cause udevd to recreate
/dev/disk links.
2020-12-09 09:13:01 -05:00
Benjamin Gilbert
07b3a639e0 40ignition-ostree: drop obsolete comment
The comment seems to have been obsolete when the code was merged in
fdadae1f83.
2020-12-09 09:13:01 -05:00
Jonathan Lebon
976a2249cf 40ignition-ostree: consistently echo msg before mounting
Some did this already, but most didn't. That way it's easier to tell
from the logs in what section it died if an error occurs.
2020-12-07 17:28:18 -05:00
Jonathan Lebon
7d1164d119 40ignition-ostree: be verbose about what we're mounting
We're sometimes hitting a flake in the RHCOS CI for LUKS-related tests:

    ignition-ostree-dracut-rootfs[909]: mount: /sysroot: unknown filesystem type 'crypto_LUKS'.
    systemd[1]: Failed to start Ignition OSTree: restore rootfs.

I think what may be happening here is that the `/dev/disk/by-label/root`
symlink is still pointing at the original partition which now hosts the
LUKS device and didn't actually get updated to point to the newly
created filesystem on top of it.

The `disks` stage does do a `udevadm trigger` on exit, though I'm not
sure how foolproof that is.

What we could do eventually to work around this is get the `device` from
the Ignition config and just mount that instead. Though to confirm first
this is what's happening, let's make the mount operations explicitly
call out what devices they're mounting.
2020-12-07 17:28:18 -05:00
Benjamin Gilbert
d8f4ea8757 99emergency-timeout: fix log display from failed units
timeout.sh was getting confused by systemctl output that looked like this:

    ● ignition-disks.service loaded failed failed Ignition (disks)

The result was output like this:

    Displaying logs from failed units: ●
    Invalid unit name "●" escaped as "\xe2\x97\x8f" (maybe you should use systemd-escape?).
    -- Logs begin at Fri 2020-12-04 04:09:20 UTC, end at Fri 2020-12-04 04:09:33 UTC. --
    -- No entries --
    Press Enter for emergency shell or wait 5 minutes for reboot.
2020-12-04 13:39:38 -05:00
Benjamin Gilbert
3a2d52cfaf 40ignition-ostree: copy PReP partition
If the Ignition config creates any PowerPC PReP partitions, save the
existing PReP contents before ignition-disks (in case the partition is
overwritten) and copy them to the new partitions afterward.  We don't
require the config to create a PReP RAID array because the OS doesn't
use or modify the PReP partition at runtime.
2020-12-04 13:36:58 -05:00
Benjamin Gilbert
fc4d970066 40ignition-ostree: copy BIOS-BOOT partition and boot sector
If the Ignition config creates any BIOS Boot partitions, save the
existing BIOS-BOOT contents and the corresponding boot sector before
ignition-disks (in case the partition is overwritten) and copy them to
the new partitions (and corresponding disks) afterward.  Also verify that
the offset of the new BIOS-BOOT partitions matches the old one, since
otherwise GRUB will fail when it tries to use them.  We don't require the
config to create a BIOS-BOOT RAID array because the OS doesn't use or
modify the BIOS-BOOT partition at runtime.
2020-12-04 13:36:58 -05:00
Benjamin Gilbert
d263654932 40ignition-ostree: support saving/restoring ESP 2020-12-04 13:36:58 -05:00
Benjamin Gilbert
cb38d2be30 40ignition-ostree: support saving/restoring boot partition 2020-12-04 13:36:58 -05:00
Benjamin Gilbert
d20f2d8e7f 40ignition-ostree: add helper function for querying filesystems
Add function to generate a partial jq query string to find wiped
filesystems.
2020-12-04 13:36:58 -05:00
Benjamin Gilbert
fbaecc0085 40ignition-ostree: rename variable 2020-12-04 13:36:58 -05:00
Benjamin Gilbert
d4c6231b0f 40ignition-ostree: generalize rootfs naming to transposefs
We'll be generalizing the rootfs save/restore code to support saving
and restoring other partitions.  Generalize the name to "transposefs"
and move the saved rootfs data to /run/ignition-ostree-transposefs/root.
2020-12-04 13:36:58 -05:00
Luca BRUNO
c1cf903a34 dracut/15coreos-network: enable initramfs networking on Azure
This enables networking in initramfs on Azure, via a platform
condition.
While the Ignition configuration may be self-contained locally
on the config-drive, other bits referenced by the provisioning
flow (e.g. Afterburn hostname and boot check-in) always require
reaching remote endpoints.
2020-12-03 09:20:07 -05:00
Benjamin Gilbert
0e432bd7ea 20live: log rootfs fetch errors
When rootfs fetch fails, ensure we have some useful logging for tracking
down the problem.
2020-12-03 09:14:03 -05:00
Dusty Mabe
eea33a33db Revert "overlay: 15fcos: add systemd unit to migrate to systemd-resolved"
This reverts commit 56b0ceba8b.

The intention was to remove this service once the streams all had it and
barriers had been created in the update graph. It should be safe to
remove now.
2020-11-30 15:54:12 -05:00
Sohan Kunkerkar
f081f1c67e 40ignition-conf: remove legacy base config
Now the new release of Ignition has the support for base config fragments (coreos/ignition#1108),
we can safely remove the legacy base config and revert https://github.com/coreos/fedora-coreos-config/pull/626
2020-11-30 11:34:57 -05:00
Kelvin Fan
49e6fd8b53 05core: Merge coreos-inject-rootmap.service into coreos-boot-edit.service
So we don't mount `/boot` more times than we need to.
2020-11-25 18:49:05 -05:00
Kelvin Fan
e0bc64c8ce 15coreos-network/coreos-copy-firstboot-network.sh: No stamp file
For simplicity, stop dropping stamp file since it is very rare that
we would benefit from it. coreos-boot-edit.service will not
use the existence of the stamp file as a triggering condition and
will always be started.
2020-11-25 18:49:05 -05:00