-
Notifications
You must be signed in to change notification settings - Fork 305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bin/admin-upgrade: add kexec support #3362
base: main
Are you sure you want to change the base?
Conversation
Hi @Mstrodl. Thanks for your PR. I'm waiting for a ostreedev member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
/ok-to-test Thanks for working on this! It's worth noting the intersection with e.g. I think this would be best as something like Then |
BTW just to emphasize again, thanks for hacking on this! A wonderful thing about working on FOSS is when people appear out of the blue with nice contributions, and this is one of those! |
I didn't do a ton of research into systemd's own automatic detection, but I got some weird errors that seemed like there was more going on with it than it not liking my BLS entries:
Sure. I may add a new
I've been working on getting my employer's debian-based appliances using ostree for immutability. The only issue is that the hardware doesn't always reboot correctly (especially if it's got a lot of uptime, which makes it extra-hard to reproduce) which means I've had a lot of embarrassing "hey can you powercycle your box?" phonecalls :) |
Makes sense! Can I ask you the same question asked here - have you investigated bootc? I'd love to help enable this use case there if the container-native approach is of interest to you! There's a lot of new feature work happening in bootc and that's where most of my time is going. What bootloader stack are you using? Regardless just a side note at some point we should have |
It would probably not be an insane amount of work for us to move to bootc; Our images right now are generated by building a docker image, exporting it, and committing that to the ostree repository. The big thing we'd need to figure out is migrating our existing ostree-based systems and our existing ordinary debian-based systems to bootc. Right now I have a scary bash script that migrates our existing debian installs to the new ostree-managed stuff, so I'd need to figure out how to do that with bootc. |
27f8347
to
33c412d
Compare
Okay, here's a new version that does it how you suggested. I haven't done much testing yet, so I guess consider this as a "draft" for now :) |
Adds a new `--kexec` flag to `ostree admin upgrade` which will cause the deployment to be loaded into kexec after the upgrade completes. It is particularly useful in conjunction with the `--reboot` flag to perform a reboot into the new deployment without waiting for the (often slow) firmware initialization to take place. (And in my case, allows me to avoid a normal reboot, which can be unreliable on my hardware). After an image has been loaded (using the `kexec_file_load` syscall), the `systemctl-reboot` command (which is called when the existing `-r` flag is included) will trigger a kexec on the loaded image rather than a normal reboot. From `systemctl(1)`: If a new kernel has been loaded via kexec --load, a kexec will be performed instead of a reboot, unless "SYSTEMCTL_SKIP_AUTO_KEXEC=1" has been set. If a new root file system has been set up on "/run/nextroot/", a soft-reboot will be performed instead of a reboot, unless "SYSTEMCTL_SKIP_AUTO_SOFT_REBOOT=1" has been set. A good in-depth technical explanation of kexec can be found here: https://web.archive.org/web/20090505132901/http://www.ibm.com/developerworks/linux/library/l-kexec.html My implementation uses the `kexec_file_load` syscall rather than the older `kexec_load` syscall, which allows the kernel to verify the signatures of the new kernel. It is supported on Linux 3.17 and newer. I assume this probably won't be an issue, but if it is, it's not that hard to put a preprocessor directive around the kexec stuff to disable it for older kernels. Even RHEL is new enough now to not be an issue :) Closes: ostreedev#435
33c412d
to
d5bd0e0
Compare
Okay, I didn't realize this until now, but the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good!
return FALSE; | ||
|
||
|
||
if ((self->flags & OSTREE_SYSROOT_UPGRADER_FLAGS_KEXEC) > 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very minor style thing, having a {
is preferred on at least the outer conditional in these nested if setups.
@@ -44,6 +44,7 @@ typedef enum | |||
OSTREE_SYSROOT_UPGRADER_FLAGS_NONE = (1 << 0), | |||
OSTREE_SYSROOT_UPGRADER_FLAGS_IGNORE_UNCONFIGURED = (1 << 1), | |||
OSTREE_SYSROOT_UPGRADER_FLAGS_STAGE = (1 << 2), | |||
OSTREE_SYSROOT_UPGRADER_FLAGS_KEXEC = (1 << 3), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not opposed but do you think we still need this API flag though, versus just having callers chose to do it?
It feels like an optional secondary step, and it's basically a flag that just adds an API call that the invoking code can just run directly too.
@@ -268,4 +268,9 @@ gboolean ostree_sysroot_simple_write_deployment (OstreeSysroot *sysroot, const c | |||
OstreeSysrootSimpleWriteDeploymentFlags flags, | |||
GCancellable *cancellable, GError **error); | |||
|
|||
_OSTREE_PUBLIC | |||
gboolean | |||
ostree_sysroot_deployment_kexec_load (OstreeSysroot *self, OstreeDeployment *deployment, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When adding new API you'll need to also add this libostree-devel.sym
. There's a few subtleties around this and it's probably easier if I just add a commit for you to apply to your branch, will do in a bit.
Can you squash this into your commit?
|
Will do tomorrow when I test. Didn't realize there was more stuff to update, sorry! |
Adds a new
--kexec
flag toostree admin upgrade
which will causethe deployment to be loaded into kexec after the upgrade completes.
It is particularly useful in conjunction with the
--reboot
flag toperform a reboot into the new deployment without waiting for the
(often slow) firmware initialization to take place. (And in my case,
allows me to avoid a normal reboot, which can be unreliable on my
hardware).
After an image has been loaded (using the
kexec_file_load
syscall),the
systemctl-reboot
command (which is called when the existing-r
flag is included) will trigger a kexec on the loaded imagerather than a normal reboot. From
systemctl(1)
:If a new kernel has been loaded via kexec --load, a kexec will be
performed instead of a reboot, unless "SYSTEMCTL_SKIP_AUTO_KEXEC=1"
has been set. If a new root file system has been set up on
"/run/nextroot/", a soft-reboot will be performed instead of a
reboot, unless "SYSTEMCTL_SKIP_AUTO_SOFT_REBOOT=1" has been set.
A good in-depth technical explanation of kexec can be found here:
https://web.archive.org/web/20090505132901/http://www.ibm.com/developerworks/linux/library/l-kexec.html
My implementation uses the
kexec_file_load
syscall rather than theolder
kexec_load
syscall, which allows the kernel to verify thesignatures of the new kernel. It is supported on Linux 3.17 and
newer. I assume this probably won't be an issue, but if it is, it's
not that hard to put a preprocessor directive around the kexec stuff
to disable it for older kernels. Even RHEL is new enough now to
not be an issue :)
Closes: #435