public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH installer 0/2] fix post-hook kernel version on newer installs and improve failure tolerance
@ 2026-05-20 10:22 Shannon Sterz
  2026-05-20 10:22 ` [PATCH installer 1/2] post-hook: detect last listed kernel package as installed kernel package Shannon Sterz
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Shannon Sterz @ 2026-05-20 10:22 UTC (permalink / raw)
  To: pve-devel

this series improves the proxmox-post-hook by using the proper kernel
version for installs using the proxmox-kernel-7.0 meta package and
also improves over-all failure tolerance. after these changes the hook
returns empty/unknown values in most cases instead of outright
failing.

Shannon Sterz (2):
  post-hook: detect last listed kernel package as installed kernel
    package
  post-hook: make post hook more failure tolerant

 proxmox-post-hook/src/main.rs | 107 +++++++++++++++++++++++++++++-----
 1 file changed, 93 insertions(+), 14 deletions(-)

--
2.47.3





^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH installer 1/2] post-hook: detect last listed kernel package as installed kernel package
  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 ` Shannon Sterz
  2026-05-20 10:22 ` [PATCH installer 2/2] post-hook: make post hook more failure tolerant Shannon Sterz
  2026-05-20 11:31 ` applied: [PATCH installer 0/2] fix post-hook kernel version on newer installs and improve failure tolerance Thomas Lamprecht
  2 siblings, 0 replies; 4+ messages in thread
From: Shannon Sterz @ 2026-05-20 10:22 UTC (permalink / raw)
  To: pve-devel

this fixes an issue where the meta package was picked up as the
installed kernel package, due to a change in its architecture from
"all" to "amd64". meaning that `find_kernel_image_path` could not find
the image path, as the meta package does not provide an image itself.
that in turn caused the whole proxmox-post-hook to fail.

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
 proxmox-post-hook/src/main.rs | 37 +++++++++++++++++++++++++++++++++--
 1 file changed, 35 insertions(+), 2 deletions(-)

diff --git a/proxmox-post-hook/src/main.rs b/proxmox-post-hook/src/main.rs
index 90c1d01..97c36ef 100644
--- a/proxmox-post-hook/src/main.rs
+++ b/proxmox-post-hook/src/main.rs
@@ -427,6 +427,8 @@ mod detail {
         //   ii |all|proxmox-kernel-6.8
         //   un ||proxmox-kernel-6.8.8-2-pve
         //   ii |amd64|proxmox-kernel-6.8.8-2-pve-signed
+        let mut to_return = Err(anyhow!("failed to find installed kernel package"));
+
         for pkg in kernel_pkgs.lines() {
             let parts = pkg.split('|').collect::<Vec<&str>>();
 
@@ -434,11 +436,11 @@ mod detail {
                 && status.trim() == "ii"
                 && arch.trim() == dpkg_arch
             {
-                return Ok(name.trim().to_owned());
+                to_return = Ok(name.trim().to_owned());
             }
         }
 
-        bail!("failed to find installed kernel package")
+        to_return
     }
 
     /// Retrieves some basic information about the CPU in the running system,
@@ -536,6 +538,37 @@ ii |amd64|proxmox-kernel-6.8.8-2-pve-signed
             );
         }
 
+        #[test]
+        fn finds_correct_kernel_package_name_when_meta_package_architecture_matches() {
+            let mocked_run_cmd = |cmd: &[&str]| {
+                if cmd[0] == "dpkg" {
+                    assert_eq!(cmd, &["dpkg", "--print-architecture"]);
+                    Ok("amd64\n".to_owned())
+                } else {
+                    assert_eq!(
+                        cmd,
+                        &[
+                            "dpkg-query",
+                            "--showformat",
+                            "${db:Status-Abbrev}|${Architecture}|${Package}\\n",
+                            "--show",
+                            "proxmox-kernel-[0-9]*",
+                        ]
+                    );
+                    Ok(r#"ii |amd64|proxmox-kernel-7.0
+un ||proxmox-kernel-7.0.2-5-pve
+ii |amd64|proxmox-kernel-7.0.2-5-pve-signed
+                "#
+                    .to_owned())
+                }
+            };
+
+            assert_eq!(
+                find_kernel_package_name(&mocked_run_cmd).unwrap(),
+                "proxmox-kernel-7.0.2-5-pve-signed"
+            );
+        }
+
         #[test]
         fn finds_correct_kernel_package_name_arm64() {
             let mocked_run_cmd = |cmd: &[&str]| {
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH installer 2/2] post-hook: make post hook more failure tolerant
  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
  2026-05-20 11:31 ` applied: [PATCH installer 0/2] fix post-hook kernel version on newer installs and improve failure tolerance Thomas Lamprecht
  2 siblings, 0 replies; 4+ messages in thread
From: Shannon Sterz @ 2026-05-20 10:22 UTC (permalink / raw)
  To: pve-devel

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





^ permalink raw reply related	[flat|nested] 4+ messages in thread

* applied: [PATCH installer 0/2] fix post-hook kernel version on newer installs and improve failure tolerance
  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 ` [PATCH installer 2/2] post-hook: make post hook more failure tolerant Shannon Sterz
@ 2026-05-20 11:31 ` Thomas Lamprecht
  2 siblings, 0 replies; 4+ messages in thread
From: Thomas Lamprecht @ 2026-05-20 11:31 UTC (permalink / raw)
  To: pve-devel, Shannon Sterz

On Wed, 20 May 2026 12:22:41 +0200, Shannon Sterz wrote:
> this series improves the proxmox-post-hook by using the proper kernel
> version for installs using the proxmox-kernel-7.0 meta package and
> also improves over-all failure tolerance. after these changes the hook
> returns empty/unknown values in most cases instead of outright
> failing.
> 
> Shannon Sterz (2):
>   post-hook: detect last listed kernel package as installed kernel
>     package
>   post-hook: make post hook more failure tolerant
> 
> [...]

Applied, thanks!

[1/2] post-hook: detect last listed kernel package as installed kernel package
      commit: 26023a3363f35f0d802dfadd0f225ea56bd4aecc
[2/2] post-hook: make post hook more failure tolerant
      commit: 7cb292b1790eb4d518773c6af3e99d78f1164176




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-05-20 11:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH installer 2/2] post-hook: make post hook more failure tolerant Shannon Sterz
2026-05-20 11:31 ` applied: [PATCH installer 0/2] fix post-hook kernel version on newer installs and improve failure tolerance Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal