fix: Improve EFI component error handling for non-OSTree systems
Some checks failed
Build deb-bootupd Artifacts / build (push) Failing after 8m52s
Some checks failed
Build deb-bootupd Artifacts / build (push) Failing after 8m52s
- Fix EFI component Drop implementation to only unmount when mountpoint exists - Prevent 'No such file or directory' errors during EFI component cleanup - Add graceful error handling in generate_update_metadata for component failures - Allow metadata generation to continue even when some components fail - Provide clear warning messages for failed components - Maintain system stability during EFI component operations
This commit is contained in:
parent
dc5a2ab86d
commit
e054db031b
2 changed files with 42 additions and 11 deletions
|
|
@ -217,15 +217,39 @@ pub(crate) fn generate_update_metadata(sysroot_path: &str) -> Result<()> {
|
||||||
let updates_dir = Path::new(sysroot_path).join(crate::model::BOOTUPD_UPDATES_DIR);
|
let updates_dir = Path::new(sysroot_path).join(crate::model::BOOTUPD_UPDATES_DIR);
|
||||||
std::fs::create_dir_all(&updates_dir)
|
std::fs::create_dir_all(&updates_dir)
|
||||||
.with_context(|| format!("Failed to create updates dir {:?}", &updates_dir))?;
|
.with_context(|| format!("Failed to create updates dir {:?}", &updates_dir))?;
|
||||||
|
|
||||||
|
let mut successful_components = 0;
|
||||||
|
let mut failed_components = Vec::new();
|
||||||
|
|
||||||
for component in get_components().values() {
|
for component in get_components().values() {
|
||||||
let v = component.generate_update_metadata(sysroot_path)?;
|
match component.generate_update_metadata(sysroot_path) {
|
||||||
println!(
|
Ok(v) => {
|
||||||
"Generated update layout for {}: {}",
|
println!(
|
||||||
component.name(),
|
"Generated update layout for {}: {}",
|
||||||
v.version,
|
component.name(),
|
||||||
);
|
v.version,
|
||||||
|
);
|
||||||
|
successful_components += 1;
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
let error_msg = format!("{}: {}", component.name(), e);
|
||||||
|
println!("Warning: Failed to generate metadata for {}: {}", component.name(), e);
|
||||||
|
failed_components.push(error_msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If no components succeeded, return an error
|
||||||
|
if successful_components == 0 {
|
||||||
|
anyhow::bail!("Failed to generate metadata for any components: {}", failed_components.join("; "));
|
||||||
|
}
|
||||||
|
|
||||||
|
// If some components failed, log a warning but continue
|
||||||
|
if !failed_components.is_empty() {
|
||||||
|
println!("Note: {} component(s) failed, but {} component(s) succeeded",
|
||||||
|
failed_components.len(), successful_components);
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
15
src/efi.rs
15
src/efi.rs
|
|
@ -467,7 +467,7 @@ impl Component for Efi {
|
||||||
// move EFI files to updates dir from /usr/lib/ostree-boot
|
// move EFI files to updates dir from /usr/lib/ostree-boot
|
||||||
if ostreebootdir.exists() {
|
if ostreebootdir.exists() {
|
||||||
let grub_dir_name = debian_tools::get_grub_dir_name();
|
let grub_dir_name = debian_tools::get_grub_dir_name();
|
||||||
let cruft = ["loader", grub_dir_name];
|
let cruft = ["loader", grub_dir_name];
|
||||||
for p in cruft.iter() {
|
for p in cruft.iter() {
|
||||||
let p = ostreebootdir.join(p);
|
let p = ostreebootdir.join(p);
|
||||||
if p.exists() {
|
if p.exists() {
|
||||||
|
|
@ -495,7 +495,9 @@ impl Component for Efi {
|
||||||
});
|
});
|
||||||
packagesystem::query_files(sysroot, files)?
|
packagesystem::query_files(sysroot, files)?
|
||||||
} else {
|
} else {
|
||||||
anyhow::bail!("Failed to find {ostreebootdir}");
|
// On non-OSTree systems (like regular Debian), we can't generate EFI metadata
|
||||||
|
// Return a special error that indicates this component should be skipped
|
||||||
|
anyhow::bail!("EFI component not available on non-OSTree system: {ostreebootdir} not found");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -570,8 +572,13 @@ impl Component for Efi {
|
||||||
|
|
||||||
impl Drop for Efi {
|
impl Drop for Efi {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
log::debug!("Unmounting");
|
// Only try to unmount if we actually have a mountpoint
|
||||||
let _ = self.unmount();
|
if self.mountpoint.borrow().is_some() {
|
||||||
|
log::debug!("Unmounting");
|
||||||
|
let _ = self.unmount();
|
||||||
|
} else {
|
||||||
|
log::debug!("No mountpoint to unmount");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue