Skip to content

Conversation

jmarrero
Copy link
Member

@jmarrero jmarrero commented Jun 5, 2025

coreos/coreos-assembler#4119 surfaced that this service would fail on soft-reboots, it's non fatal but would make the Kola tests fail. It looks like originally this was set to fail instead of risking not running it:

Copy link
Member

@cgwalters cgwalters left a comment

Choose a reason for hiding this comment

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

LGTM (but I suggested this so I won't officially approve)

Copy link
Member

@jlebon jlebon left a comment

Choose a reason for hiding this comment

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

I presume ConditionFirstBoot=true units do not run again in a soft reboot on the first boot since /etc/machine-id is now present. Correct?

@jmarrero jmarrero force-pushed the prepare-soft-reboot branch 2 times, most recently from 31079c6 to 787b3dc Compare June 6, 2025 13:57
@jmarrero
Copy link
Member Author

jmarrero commented Jun 6, 2025

I presume ConditionFirstBoot=true units do not run again in a soft reboot on the first boot since /etc/machine-id is now present. Correct?

/etc/machine-id is there:

$ cosa run
Fedora CoreOS 42.20250606.dev.0
Tracker: https://github.com/coreos/fedora-coreos-tracker
Discuss: https://discussion.fedoraproject.org/tag/coreos

Last login: Fri Jun  6 13:51:17 2025
core@cosa-devsh:~$ cat /etc/machine-id 
a77f9d521de9495585ba4c92ee22dcfb
core@cosa-devsh:~$ sudo systemctl soft-reboot 
Broadcast message from root@localhost on pts/1 (Fri 2025-06-06 13:51:51 UTC):
The system will reboot now!

[EVENT | QEMU guest is ready for SSH] [ [0;32m  OK   [0m] Started  [0;1;39mzincati.service [0m - Zincati Update Agent.Fedora CoreOS 42.20250606.dev.0
Tracker: https://github.com/coreos/fedora-coreos-tracker
Discuss: https://discussion.fedoraproject.org/tag/coreos

Last login: Fri Jun  6 13:51:54 2025
core@cosa-devsh:~$ cat /etc/machine-id 
a77f9d521de9495585ba4c92ee22dcfb

However, I don't see anything in the code or service that mentions /etc/machine-id... Not sure if you mean that it should not run because /etc/machine-id means that is not longer the first boot.

Copy link
Member

@jlebon jlebon left a comment

Choose a reason for hiding this comment

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

One comment, but looks fine overall. That said, one could imagine other systemd units that use ignition.firstboot out there instead of ConditionFirstBoot that will also hit this.

For this specific unit, I think the current conditionals here are more appropriate than ConditionFirstBoot=, but everything else should probably use that.

OK and we have one actually in this very repo:

. Can you adapt that one?

@jmarrero jmarrero force-pushed the prepare-soft-reboot branch 2 times, most recently from 89f8cfb to caa29cb Compare June 6, 2025 14:43
@jmarrero jmarrero changed the title coreos-ignition-firstboot-complete: prepare for soft-reboots overlay.d: Update ignition.firstboot services for soft-reboots Jun 6, 2025
# This condition is required for cases where a soft-reboot is issued on the
# firstboot. Soft reboot do not change the kernel or its command-line arguments,
# which would cause this service to fail after the soft-reboot completes.
ConditionPathExists=/boot/ignition.firstboot
Copy link
Member

Choose a reason for hiding this comment

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

Not quite. What I mean is that this unit should use ConditionFirstBoot=true instead of ConditionKernelCommandLine= + ConditionPathExists=.

Copy link
Member

Choose a reason for hiding this comment

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

Hum. Looking there are some other uses of ConditionFirstBoot=true but not many

$ podman run --rm -ti quay.io/fedora/fedora-coreos:stable grep -r ConditionFirstBoot /usr/lib/systemd/system
/usr/lib/systemd/system/systemd-homed-firstboot.service:ConditionFirstBoot=yes
/usr/lib/systemd/system/coreos-update-ca-trust.service:ConditionFirstBoot=true
/usr/lib/systemd/system/coreos-update-ca-trust.service:# All services which use ConditionFirstBoot=yes should use
/usr/lib/systemd/system/ignition-delete-config.service:ConditionFirstBoot=true
/usr/lib/systemd/system/first-boot-complete.target:ConditionFirstBoot=yes
/usr/lib/systemd/system/zincati.service:# created so that we don't cause ConditionFirstBoot=true units to run twice
/usr/lib/systemd/system/systemd-firstboot.service:ConditionFirstBoot=yes
/usr/lib/systemd/system/afterburn-firstboot-checkin.service:ConditionFirstBoot=yes
$

I think I agree with you it'd be better to do so, however a general issue with ConditionFirstBoot is it doesn't handle the case where the system is interrupted (poweroff/crash) during first boot. Those services will then later fail to reconcile.

Dunno that it matters though in practice.

Copy link
Member

Choose a reason for hiding this comment

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

A lot of background on that topic. See discussions in e.g. systemd/systemd#4511. This is why we do this here for example:

# All services which use ConditionFirstBoot=yes should use
# Before=first-boot-complete.target, which is a target that
# was introduced in https://github.com/systemd/systemd/issues/4511
# and hasn't propagated everywhere yet. Once the target propagates
# everywhere, we can drop the systemd-machine-id-commit.service
# from the Before= line.
Before=first-boot-complete.target systemd-machine-id-commit.service
Wants=first-boot-complete.target

Copy link
Member

Choose a reason for hiding this comment

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

Which, presumably we should also do for coreos-check-ssh-keys.service, but yeah I'm not too worried about it.

coreos/coreos-assembler#4119 surfaced that
this services using ConditionKernelCommandLine=ignition.firstboot
would fail on soft-reboots, it's non fatal but would make the Kola
tests fail.

Co-authored-by: Jonathan Lebon <[email protected]>
Co-authored-by: Colin Walters <[email protected]>
@jmarrero jmarrero force-pushed the prepare-soft-reboot branch from caa29cb to bc3c368 Compare June 9, 2025 12:51
@jlebon jlebon merged commit e305450 into coreos:testing-devel Jun 10, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants