public inbox for pdm-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Lukas Wagner <l.wagner@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [pdm-devel] [PATCH datacenter-manager 04/13] remote-updates: include version information in node update summary
Date: Thu, 27 Nov 2025 11:44:38 +0100	[thread overview]
Message-ID: <20251127104447.162951-10-l.wagner@proxmox.com> (raw)
In-Reply-To: <20251127104447.162951-1-l.wagner@proxmox.com>

Includes the versions of the 'pve-manager' or 'proxmox-backup-server'
packages in the node update summary response. The changed are done in
such a way that we could include other important versions as well
without any breaking changes (e.g. kernel version).

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
---
 lib/pdm-api-types/src/remote_updates.rs | 24 ++++++++++++++++
 server/src/remote_updates.rs            | 37 +++++++++++++++++++++++--
 2 files changed, 59 insertions(+), 2 deletions(-)

diff --git a/lib/pdm-api-types/src/remote_updates.rs b/lib/pdm-api-types/src/remote_updates.rs
index e42b6a96..05ff3379 100644
--- a/lib/pdm-api-types/src/remote_updates.rs
+++ b/lib/pdm-api-types/src/remote_updates.rs
@@ -106,6 +106,26 @@ pub enum NodeUpdateStatus {
 #[api]
 #[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
 #[serde(rename_all = "kebab-case")]
+/// Package version information.
+pub struct PackageVersion {
+    /// Name of the package.
+    pub package: String,
+    /// Version of the package.
+    pub version: String,
+}
+
+#[api(
+    properties: {
+        versions: {
+            type: Array,
+            items: {
+                type: PackageVersion,
+            }
+        }
+    }
+)]
+#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
+#[serde(rename_all = "kebab-case")]
 /// Per-node update summary.
 pub struct NodeUpdateSummary {
     /// Number of available updates.
@@ -115,5 +135,9 @@ pub struct NodeUpdateSummary {
     /// Status
     pub status: NodeUpdateStatus,
     /// Status message (e.g. error message)
+    #[serde(skip_serializing_if = "Option::is_none")]
     pub status_message: Option<String>,
+    /// Versions of the most important packages.
+    #[serde(default, skip_serializing_if = "Vec::is_empty")]
+    pub versions: Vec<PackageVersion>,
 }
diff --git a/server/src/remote_updates.rs b/server/src/remote_updates.rs
index 895381a5..ad85ee85 100644
--- a/server/src/remote_updates.rs
+++ b/server/src/remote_updates.rs
@@ -7,8 +7,8 @@ use serde::{Deserialize, Serialize};
 use proxmox_apt_api_types::APTUpdateInfo;
 
 use pdm_api_types::remote_updates::{
-    NodeUpdateStatus, NodeUpdateSummary, NodeUpdateSummaryWrapper, RemoteUpdateStatus,
-    RemoteUpdateSummary, UpdateSummary,
+    NodeUpdateStatus, NodeUpdateSummary, NodeUpdateSummaryWrapper, PackageVersion,
+    RemoteUpdateStatus, RemoteUpdateSummary, UpdateSummary,
 };
 use pdm_api_types::remotes::{Remote, RemoteType};
 use pdm_api_types::RemoteUpid;
@@ -24,6 +24,7 @@ pub const UPDATE_CACHE: &str = concat!(PDM_CACHE_DIR_M!(), "/remote-updates.json
 struct NodeUpdateInfo {
     updates: Vec<APTUpdateInfo>,
     last_refresh: i64,
+    versions: Vec<PackageVersion>,
 }
 
 impl From<NodeUpdateInfo> for NodeUpdateSummary {
@@ -33,6 +34,7 @@ impl From<NodeUpdateInfo> for NodeUpdateSummary {
             last_refresh: value.last_refresh,
             status: NodeUpdateStatus::Success,
             status_message: None,
+            versions: value.versions,
         }
     }
 }
@@ -224,6 +226,7 @@ pub async fn refresh_update_summary_cache(remotes: Vec<Remote>) -> Result<(), Er
                                     last_refresh: 0,
                                     status: NodeUpdateStatus::Error,
                                     status_message: Some(format!("{err:#}")),
+                                    versions: Vec::new(),
                                 },
                             );
                             log::error!(
@@ -263,18 +266,34 @@ async fn fetch_available_updates(
                 .map(map_pve_update_info)
                 .collect();
 
+            let versions = client.get_package_versions(&node).await?;
+            let versions = versions
+                .into_iter()
+                .filter(|v| v.package == "pve-manager")
+                .map(map_pve_package_version)
+                .collect();
+
             Ok(NodeUpdateInfo {
                 last_refresh: proxmox_time::epoch_i64(),
                 updates,
+                versions,
             })
         }
         RemoteType::Pbs => {
             let client = connection::make_pbs_client(&remote)?;
             let updates = client.list_available_updates().await?;
 
+            let versions = client.get_package_versions().await?;
+            let versions = versions
+                .into_iter()
+                .filter(|v| v.package == "proxmox-backup-server")
+                .map(map_pbs_package_version)
+                .collect();
+
             Ok(NodeUpdateInfo {
                 last_refresh: proxmox_time::epoch_i64(),
                 updates,
+                versions,
             })
         }
     }
@@ -294,3 +313,17 @@ fn map_pve_update_info(info: pve_api_types::AptUpdateInfo) -> APTUpdateInfo {
         extra_info: None,
     }
 }
+
+fn map_pve_package_version(info: pve_api_types::InstalledPackage) -> PackageVersion {
+    PackageVersion {
+        package: info.package,
+        version: info.old_version.unwrap_or_default(),
+    }
+}
+
+fn map_pbs_package_version(info: pbs_api_types::APTUpdateInfo) -> PackageVersion {
+    PackageVersion {
+        package: info.package,
+        version: info.old_version.unwrap_or_default(),
+    }
+}
-- 
2.47.3



_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel


  parent reply	other threads:[~2025-11-27 10:45 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-27 10:44 [pdm-devel] [PATCH datacenter-manager/proxmox{, -yew-comp} 00/18] remote update view: include product version and repository status Lukas Wagner
2025-11-27 10:44 ` [pdm-devel] [PATCH proxmox 1/4] add bindings for /nodes/{node}/apt/versions Lukas Wagner
2025-11-27 20:46   ` [pdm-devel] applied: " Thomas Lamprecht
2025-11-27 10:44 ` [pdm-devel] [PATCH proxmox 2/4] add bindings for /nodes/{node}/apt/repositories Lukas Wagner
2025-11-27 20:46   ` [pdm-devel] applied: " Thomas Lamprecht
2025-11-27 10:44 ` [pdm-devel] [PATCH proxmox 3/4] make refresh Lukas Wagner
2025-11-27 10:44 ` [pdm-devel] [PATCH proxmox 4/4] proxmox-apt-api-types: make APTStandardRepository compatible with PVE's serialization of the type Lukas Wagner
2025-11-27 20:46   ` [pdm-devel] applied: " Thomas Lamprecht
2025-11-27 10:44 ` [pdm-devel] [PATCH proxmox-yew-comp 1/1] apt repositories: add 'status_only' property Lukas Wagner
2025-11-27 21:26   ` [pdm-devel] applied: " Thomas Lamprecht
2025-11-27 10:44 ` [pdm-devel] [PATCH datacenter-manager 01/13] pdm-api-types: reuse APTUpdateInfo from proxmox_apt_api_types Lukas Wagner
2025-11-27 10:44 ` [pdm-devel] [PATCH datacenter-manager 02/13] pbs-client: add bindings for /nodes/localhost/apt/versions Lukas Wagner
2025-11-27 10:44 ` [pdm-devel] [PATCH datacenter-manager 03/13] pbs-client: add bindings for /nodes/localhost/apt/repositories Lukas Wagner
2025-11-27 10:44 ` Lukas Wagner [this message]
2025-11-27 10:44 ` [pdm-devel] [PATCH datacenter-manager 05/13] remote updates: include repository status in node summary Lukas Wagner
2025-11-27 10:44 ` [pdm-devel] [PATCH datacenter-manager 06/13] api: pve/pbs: add passthrough endpoint for APT repo configuration Lukas Wagner
2025-11-27 10:44 ` [pdm-devel] [PATCH datacenter-manager 07/13] ui: remote updates: show table header Lukas Wagner
2025-11-27 10:44 ` [pdm-devel] [PATCH datacenter-manager 08/13] ui: remote updates: show main product version in overview table Lukas Wagner
2025-11-27 10:44 ` [pdm-devel] [PATCH datacenter-manager 09/13] ui: remote updates: show repository status column Lukas Wagner
2025-11-27 10:44 ` [pdm-devel] [PATCH datacenter-manager 10/13] ui: remote updates: show repo status details when selecting a node Lukas Wagner
2025-11-27 10:44 ` [pdm-devel] [PATCH datacenter-manager 11/13] ui: remote updates: don't attempt to load current status for unavailable nodes Lukas Wagner
2025-11-27 10:44 ` [pdm-devel] [PATCH datacenter-manager 12/13] ui: remote updates: use 'building-o' icon for PBS nodes Lukas Wagner
2025-11-27 10:44 ` [pdm-devel] [PATCH datacenter-manager 13/13] ui: remote updates: use explicit indices for parameters in tr! macro Lukas Wagner
2025-11-27 10:47 ` [pdm-devel] [PATCH datacenter-manager/proxmox{, -yew-comp} 00/18] remote update view: include product version and repository status Lukas Wagner

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=20251127104447.162951-10-l.wagner@proxmox.com \
    --to=l.wagner@proxmox.com \
    --cc=pdm-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 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