From: Shannon Sterz <s.sterz@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH installer 2/2] post-hook: make post hook more failure tolerant
Date: Wed, 20 May 2026 12:22:43 +0200 [thread overview]
Message-ID: <20260520102243.129230-3-s.sterz@proxmox.com> (raw)
In-Reply-To: <20260520102243.129230-1-s.sterz@proxmox.com>
by logging an error and providing an "unknown" or empty value where
possible. this should avoid a single command failing from aborting the
whole post hook by bubbling up an error.
there are a couple of exceptions that will still bubble up:
- if the low level installer config cannot be read or loaded
- if the udev information cannot be read or parsed
- if the product info cannot be gathered
- if the file system details cannot be gathered
the first two should always be present after a proper installation and
something going wrong there points to a larger issue that should be
fixed.
the product info should also always be present, but we are lacking a
sensible default we can return here instead, because the
`ProxmoxProduct` enum does not have a "unknown" variant. so if an
error is encountered we would report a potentially wrong product.
file system details should also always be present and the
`FilesystemType` enum also lacks a sensible "unknown" variant.
Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
proxmox-post-hook/src/main.rs | 70 +++++++++++++++++++++++++++++------
1 file changed, 58 insertions(+), 12 deletions(-)
diff --git a/proxmox-post-hook/src/main.rs b/proxmox-post-hook/src/main.rs
index 97c36ef..2a36bbc 100644
--- a/proxmox-post-hook/src/main.rs
+++ b/proxmox-post-hook/src/main.rs
@@ -25,7 +25,7 @@ const POST_HOOK_SCHEMA_VERSION: &str = "1.2";
mod detail {
use anyhow::{Context, Result, anyhow, bail};
use std::{
- collections::HashSet,
+ collections::{HashMap, HashSet},
ffi::CStr,
fs::{self, File},
io::BufReader,
@@ -39,7 +39,7 @@ mod detail {
setup::{InstallConfig, RuntimeInfo, SetupInfo, load_installer_setup_files},
};
use proxmox_installer_types::{
- ProxmoxProduct, UdevInfo,
+ ProxmoxProduct, SystemDMI, UdevInfo,
answer::{AutoInstallerConfig, FqdnConfig, FqdnFromDhcpConfig, FqdnSourceMode},
post_hook::{
BootInfo, CpuInfo, DiskInfo, KernelVersionInformation, NetworkInterfaceInfo,
@@ -115,25 +115,71 @@ mod detail {
schema: PostHookInfoSchema {
version: super::POST_HOOK_SCHEMA_VERSION.to_owned(),
},
- debian_version: read_file("/etc/debian_version")?,
+ debian_version: read_file("/etc/debian_version").unwrap_or_else(|e| {
+ eprintln!("could not gather debian version: {e:#}");
+ "unknown".to_string()
+ }),
product: gather_product_info(&setup_info, &run_cmd)?,
iso: setup_info.iso_info,
- kernel_version: gather_kernel_version(&run_cmd, &open_file)?,
+ kernel_version: gather_kernel_version(&run_cmd, &open_file).unwrap_or_else(|e| {
+ eprintln!("could not gather kernel version: {e:#}");
+ KernelVersionInformation {
+ sysname: "unknown".to_string(),
+ release: "unknown".to_string(),
+ version: "unknown".to_string(),
+ machine: "unknown".to_string(),
+ }
+ }),
boot_info: BootInfo {
mode: run_env.boot_type,
secureboot: run_env.secure_boot,
},
- cpu_info: gather_cpu_info(&run_env)?,
- dmi: proxmox_installer_common::dmi::get()?,
+ cpu_info: gather_cpu_info(&run_env).unwrap_or_else(|e| {
+ eprintln!("could not gather cpu info: {e:#}");
+ CpuInfo {
+ cores: 0,
+ cpus: 0,
+ flags: "unknown".to_string(),
+ hvm: false,
+ model: "unknown".to_string(),
+ sockets: 0,
+ }
+ }),
+ dmi: proxmox_installer_common::dmi::get().unwrap_or_else(|e| {
+ eprintln!("could not gather dmi: {e:#}");
+ SystemDMI {
+ baseboard: HashMap::new(),
+ chassis: HashMap::new(),
+ system: HashMap::new(),
+ }
+ }),
filesystem: answer.disks.filesystem_details()?.to_type(),
fqdn,
- machine_id: read_file("/etc/machine-id")?,
- disks: gather_disks(&config, &run_env, &udev)?,
- network_interfaces: gather_nic(&config, &run_env, &udev)?,
+ machine_id: read_file("/etc/machine-id").unwrap_or_else(|e| {
+ eprintln!("could not gather machine-id: {e:#}");
+ "unknown".to_string()
+ }),
+ disks: gather_disks(&config, &run_env, &udev).unwrap_or_else(|e| {
+ eprintln!("could not gather disks: {e:#}");
+ Vec::new()
+ }),
+ network_interfaces: gather_nic(&config, &run_env, &udev).unwrap_or_else(|e| {
+ eprintln!("could not gather network interfaces: {e:#}");
+ Vec::new()
+ }),
ssh_public_host_keys: SshPublicHostKeys {
- ecdsa: read_file("/etc/ssh/ssh_host_ecdsa_key.pub")?,
- ed25519: read_file("/etc/ssh/ssh_host_ed25519_key.pub")?,
- rsa: read_file("/etc/ssh/ssh_host_rsa_key.pub")?,
+ ecdsa: read_file("/etc/ssh/ssh_host_ecdsa_key.pub").unwrap_or_else(|e| {
+ eprintln!("could not gather ecdsa SSH key: {e:#}");
+ "unknown".to_string()
+ }),
+ ed25519: read_file("/etc/ssh/ssh_host_ed25519_key.pub").unwrap_or_else(|e| {
+ eprintln!("could not gather ed25519 SSH key: {e:#}");
+ "unknown".to_string()
+ }),
+ rsa: read_file("/etc/ssh/ssh_host_rsa_key.pub").unwrap_or_else(|e| {
+ eprintln!("could not gather rsa SSH key: {e:#}");
+ "unknown".to_string()
+ }),
},
reboot_mode: answer.global.reboot_mode,
})
--
2.47.3
next prev parent reply other threads:[~2026-05-20 10:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-20 10:22 [PATCH installer 0/2] fix post-hook kernel version on newer installs and improve failure tolerance Shannon Sterz
2026-05-20 10:22 ` [PATCH installer 1/2] post-hook: detect last listed kernel package as installed kernel package Shannon Sterz
2026-05-20 10:22 ` Shannon Sterz [this message]
2026-05-20 11:31 ` applied: [PATCH installer 0/2] fix post-hook kernel version on newer installs and improve failure tolerance Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260520102243.129230-3-s.sterz@proxmox.com \
--to=s.sterz@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.