From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 8C9CE1FF17E for ; Thu, 27 Nov 2025 11:45:15 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id CC104119; Thu, 27 Nov 2025 11:45:35 +0100 (CET) From: Lukas Wagner To: pdm-devel@lists.proxmox.com Date: Thu, 27 Nov 2025 11:44:38 +0100 Message-ID: <20251127104447.162951-10-l.wagner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251127104447.162951-1-l.wagner@proxmox.com> References: <20251127104447.162951-1-l.wagner@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1764240257272 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.032 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pdm-devel] [PATCH datacenter-manager 04/13] remote-updates: include version information in node update summary X-BeenThere: pdm-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Datacenter Manager development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pdm-devel-bounces@lists.proxmox.com Sender: "pdm-devel" 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 --- 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, + /// Versions of the most important packages. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub versions: Vec, } 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, last_refresh: i64, + versions: Vec, } impl From for NodeUpdateSummary { @@ -33,6 +34,7 @@ impl From 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) -> 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