Skip to content

Commit 52543c2

Browse files
committed
Add function to write reboot-required file with context
This change adds a function that writes the /run/reboot-required file. This function is called from any deployment operation with the relevant context. Calling from rollback will ensure the rollback context along with the image digest is written to the file, while calling from upgrade or switch will write the deploy context for users to reference. This expands on the functionality requested in: #1574 Related to: #1583 Signed-off-by: Brendan Shephard <[email protected]>
1 parent 39b0a32 commit 52543c2

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

crates/lib/src/deploy.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,9 +792,17 @@ pub(crate) async fn stage(
792792
})
793793
.await;
794794

795+
let bootc_action: String = String::from("deploy");
796+
795797
// Unconditionally create or update /run/reboot-required to signal a reboot is needed.
796798
// This is monitored by kured (Kubernetes Reboot Daemon).
797-
let reboot_message = format!("bootc: Reboot required for image: {}", &spec.image.image);
799+
write_reboot_required(&image.manifest_digest.as_ref(), bootc_action.as_str())?;
800+
801+
Ok(())
802+
}
803+
804+
fn write_reboot_required(image: &str, action: &str) -> Result<()> {
805+
let reboot_message = format!("bootc {}: Reboot required for image: {}", action, image);
798806
let run_dir = Dir::open_ambient_dir("/run", cap_std::ambient_authority())?;
799807
run_dir
800808
.atomic_write("reboot-required", reboot_message.as_bytes())
@@ -870,6 +878,12 @@ pub(crate) async fn rollback(sysroot: &Storage) -> Result<()> {
870878
println!("Next boot: rollback deployment");
871879
}
872880

881+
let bootc_action: String = String::from("rollback");
882+
write_reboot_required(
883+
rollback_image.manifest_digest.as_ref(),
884+
bootc_action.as_str(),
885+
)?;
886+
873887
sysroot.update_mtime()?;
874888

875889
Ok(())

0 commit comments

Comments
 (0)