-
Notifications
You must be signed in to change notification settings - Fork 27
Add ConditionPathExists=/etc/initrd-release to targets #140
Conversation
Oh wow. That's... scary. It's weird though, that unit should only be running in the initrd itself (from
Seems like a systemd regression put in in the real root by mistake? |
I think there's some kind of racy thing going on. If I boot the FCOS I just built locally normally:
If I stop the boot using
So I think this might be systemd getting confused somehow. |
Ohhh, I think this might just be the journal getting confused. Notice the pid is the same here:
And it's the same in other tests that I've run. So I don't think |
And
It's getting logged twice, once via journald, and once via the kernel buffer I think because of:
|
Hmm...this might explain why we're seeing "Missed [x] kernel messages" in the journal too - if we're in some cases logging recursively, maybe journald tries to suppress this type of cycle but can't always do it? |
So I think what's happening there is that it depends when switch root happens vs the journal reads input from the kernel buffer. If we switch root fast enough, the new journald instance which doesn't have that knob will be reading the data that the pre-switch-root journald left while forwarding. |
I noticed that several of our units appeared to run twice, including `ignition-files.service` (!) and `ignition-ostree-mount-firstboot-sysroot.service`. [Later investigation revealed this was actually a double-logging issue.] Looking deeper into this, I discovered a bit of the initrd that I didn't even know existed, which is `initrd-parse-etc.service` that actually runs `ExecStart=-/usr/bin/systemctl --no-block start initrd-fs.target` *post* switch root, after services that are part of that target have already run (and then been shut down). This adds a big wrinkle to my understanding of system bootup. Then I noticed that `initrd-fs.target` has: `ConditionPathExists=/etc/initrd-release` which will be false post-switchroot. The semantics here are...strange. It seems like the goal is to ensure that the rootfs is definitely still mounted, perhaps in very complex rootfs scenarios? In our case it will still be mounted, we definitely don't want to rerun any of our Ignition units. [We discovered the units aren't actually being rerun, but this still seems like a best practice]
c457e2a
to
8800e42
Compare
Wow, thanks for that investigation. Trying this some more, it does seem like you're right, and I was just lucky with the race when I was testing out this patch. But...hum. Then I guess my question is why isn't that unit re-running our services? [Going to add some sanity checking that it really isn't happening] Is the reason that I updated the commit message with the new findings, but basically I'd argue for merging anyways since this seems like a best practice. |
I think I agree, though... let's just plaster it in all our units?
This is a pure guess, but I think it's simply because the build system puts all the service files indiscriminately in the real root and the One nice bonus of doing this is I'm pretty sure it's what allows e.g. |
(I can investigate this and do that switch as a follow-up if folks agree. I think it'd be a nice tiny QOL improvement.) |
Yeah. |
This is standard practice for units that are only meant to run in the initrd. It matches what e.g. `systemd` does for its initrd units. See also: coreos#140. I also snuck in `Documentation=` lines in there.
This is standard practice for units that are only meant to run in the initrd. It matches what e.g. `systemd` does for its initrd units. See also: #140. I also snuck in `Documentation=` lines in there.
I noticed that several of our units actually run twice, including
ignition-files.service
(!) andignition-ostree-mount-firstboot-sysroot.service
.Looking deeper into this, I discovered a bit of the initrd that
I didn't even know existed, which is
initrd-parse-etc.service
that actually runs
ExecStart=-/usr/bin/systemctl --no-block start initrd-fs.target
post switch root, after services that are part of that target
have already run (and then been shut down).
This adds a big wrinkle to my understanding of system bootup.
Then I noticed that
initrd-fs.target
has:ConditionPathExists=/etc/initrd-release
which will be false post-switchroot.
The semantics here are...strange. It seems like the goal is to ensure
that the rootfs is definitely still mounted, perhaps in
very complex rootfs scenarios? In our case it will still be
mounted, we definitely don't want to rerun any of our Ignition
units.
Adding the same condition to our targets ensures that they
aren't re-run post switchroot.