From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id CFE3D1FF17C for ; Wed, 3 Sep 2025 11:19:35 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 5D1D72F239; Wed, 3 Sep 2025 11:19:50 +0200 (CEST) Message-ID: <9d849f90-766f-4978-a37a-5a30a0931dbd@proxmox.com> Date: Wed, 3 Sep 2025 11:19:15 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Stefan Hanreich To: Proxmox Datacenter Manager development discussion , Lukas Wagner References: <20250902151427.425017-1-l.wagner@proxmox.com> <20250902151427.425017-8-l.wagner@proxmox.com> <3b096098-d5c9-4108-8a92-717af8cf3978@proxmox.com> Content-Language: en-US In-Reply-To: <3b096098-d5c9-4108-8a92-717af8cf3978@proxmox.com> X-SPAM-LEVEL: Spam detection results: 0 AWL 0.708 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 RCVD_IN_MSPIKE_H2 0.001 Average reputation (+2) RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [apt.rs, mod.rs, lib.rs, node.rs] Subject: Re: [pdm-devel] [PATCH proxmox-datacenter-manager 1/4] server: add api for getting available updates/changelogs for remote nodes 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" On 9/3/25 11:02 AM, Stefan Hanreich wrote: > On 9/2/25 5:14 PM, Lukas Wagner wrote: >> This adds new APIs for update management: >> >> GET /pve/remotes/{remote}/nodes/{node}/apt/changelog >> -> get package changelog >> GET /pve/remotes/{remote}/nodes/{node}/apt/update >> -> get list of updatable packages >> POST /pve/remotes/{remote}/nodes/{node}/apt/update >> -> refresh APT database >> >> At this time these just pass the call through to PVE with no caching >> involved on the PDM side. This should be fine for this API, but once >> we have an API for 'give me a view of ALL available remote updates', >> we need to introduce a cache that is periodically refreshed. >> >> Signed-off-by: Lukas Wagner >> --- >> server/src/api/pve/apt.rs | 119 +++++++++++++++++++++++++++++++++++ >> server/src/api/pve/mod.rs | 3 +- >> server/src/api/pve/node.rs | 1 + >> server/src/lib.rs | 1 + >> server/src/remote_updates.rs | 96 ++++++++++++++++++++++++++++ >> 5 files changed, 219 insertions(+), 1 deletion(-) >> create mode 100644 server/src/api/pve/apt.rs >> create mode 100644 server/src/remote_updates.rs >> >> diff --git a/server/src/api/pve/apt.rs b/server/src/api/pve/apt.rs >> new file mode 100644 >> index 00000000..f5027fb8 >> --- /dev/null >> +++ b/server/src/api/pve/apt.rs >> @@ -0,0 +1,119 @@ >> +use anyhow::Error; >> + >> +use proxmox_apt_api_types::{APTGetChangelogOptions, APTUpdateInfo}; >> +use proxmox_router::{list_subdirs_api_method, Permission, Router, SubdirMap}; >> +use proxmox_schema::api; >> +use proxmox_schema::api_types::NODE_SCHEMA; >> + >> +use pdm_api_types::{remotes::REMOTE_ID_SCHEMA, RemoteUpid, PRIV_RESOURCE_MODIFY}; >> + >> +use crate::{api::remotes::get_remote, remote_updates}; >> + >> +#[api( >> + input: { >> + properties: { >> + remote: { >> + schema: REMOTE_ID_SCHEMA, >> + }, >> + node: { >> + schema: NODE_SCHEMA, >> + }, >> + }, >> + }, >> + returns: { >> + description: "A list of packages with available updates.", >> + type: Array, >> + items: { >> + type: APTUpdateInfo >> + }, >> + }, >> + access: { >> + permission: &Permission::Privilege(&["resource", "{remote}", "node", "{node}", "system"], PRIV_RESOURCE_MODIFY, false), >> + }, >> +)] >> +/// List available APT updates for a remote PVE node. >> +async fn apt_update_available(remote: String, node: String) -> Result, Error> { > > potentially fine to take a ref here for both params as well? > >> + let (config, _digest) = pdm_config::remotes::config()?; >> + let remote = get_remote(&config, &remote)?; >> + >> + let updates = remote_updates::list_available_updates(remote.clone(), &node).await?; >> + >> + Ok(updates) >> +} >> + >> +#[api( >> + input: { >> + properties: { >> + remote: { >> + schema: REMOTE_ID_SCHEMA, >> + }, >> + node: { >> + schema: NODE_SCHEMA, >> + }, >> + }, >> + }, >> + access: { >> + permission: &Permission::Privilege(&["resource", "{remote}", "node", "{node}", "system"], PRIV_RESOURCE_MODIFY, false), >> + }, >> +)] >> +/// Update the APT database of a remote PVE node. >> +pub async fn apt_update_database(remote: String, node: String) -> Result { > > here too then > >> + let (config, _digest) = pdm_config::remotes::config()?; >> + let remote = get_remote(&config, &remote)?; >> + >> + let upid = remote_updates::update_apt_database(remote, &node).await?; >> + >> + Ok(upid) >> +} >> + >> +#[api( >> + input: { >> + properties: { >> + remote: { >> + schema: REMOTE_ID_SCHEMA, >> + }, >> + node: { >> + schema: NODE_SCHEMA, >> + }, >> + options: { >> + type: APTGetChangelogOptions, >> + flatten: true, >> + }, >> + }, >> + }, >> + returns: { >> + description: "The Package changelog.", >> + type: String, >> + }, >> + access: { >> + permission: &Permission::Privilege(&["resource", "{remote}", "node", "{node}", "system"], PRIV_RESOURCE_MODIFY, false), >> + }, >> +)] >> +/// Retrieve the changelog of the specified package for a remote PVE node. >> +async fn apt_get_changelog( >> + remote: String, >> + node: String, >> + options: APTGetChangelogOptions, > > here too then sorry, was too liberal when scanning the functions, those three cannot take a ref ofc [snip] _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel