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 1D4261FF13B for ; Wed, 03 Jun 2026 13:54:53 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 5F483980F; Wed, 3 Jun 2026 13:54:50 +0200 (CEST) From: Shannon Sterz To: pdm-devel@lists.proxmox.com Subject: [PATCH datacenter-manager 1/2] server: subscription: always get fresh subscription info on update Date: Wed, 3 Jun 2026 13:54:41 +0200 Message-ID: <20260603115442.361184-2-s.sterz@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260603115442.361184-1-s.sterz@proxmox.com> References: <20260603115442.361184-1-s.sterz@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1780487649343 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.110 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 Message-ID-Hash: 2THG7W3OTGZLOZZRWH7UG3PKXSK4X27V X-Message-ID-Hash: 2THG7W3OTGZLOZZRWH7UG3PKXSK4X27V X-MailFrom: s.sterz@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: otherwise the cached information is used. since the cache does not include the server id, not suitable information will be detected. to avoid that freshly fetch the subscription info, including the server id, when updating the subscription status. Signed-off-by: Shannon Sterz --- server/src/api/nodes/subscription.rs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/server/src/api/nodes/subscription.rs b/server/src/api/nodes/subscription.rs index d6ae48b5..4ab36c36 100644 --- a/server/src/api/nodes/subscription.rs +++ b/server/src/api/nodes/subscription.rs @@ -163,12 +163,35 @@ pub async fn check_subscription() -> Result<(), Error> { if info.status == SubscriptionStatus::Active && info.level >= SubscriptionLevel::Basic && info.key.is_some() - && info.serverid.is_some() { log::info!( "Using subscription of node '{node}' of remote '{remote}' for enterprise \ repository access" ); + + // Get fresh subscription info. The cache does not store the serverid, so we + // need to fetch it from the remote. This has the upside of always yielding + // fresh results. + let (remote_config, _digest) = pdm_config::remotes::config()?; + let Some(remote) = remote_config.get(remote) else { + continue 'outer; + }; + let node_info = get_subscription_info_for_remote(remote, 0).await?; + let Some(info) = node_info.iter().find_map(|(_key, val)| { + if let Some(info) = val.as_ref() { + if info.status == SubscriptionStatus::Active + && info.level >= SubscriptionLevel::Basic + && info.key.is_some() + && info.serverid.is_some() + { + return Some(info.clone()); + } + } + None + }) else { + continue 'outer; + }; + update_apt_auth( APT_AUTH_FN, apt_auth_file_opts(), -- 2.47.3