* [PATCH datacenter-manager 0/2] fix an issue with cached subscription info
@ 2026-06-03 11:54 Shannon Sterz
2026-06-03 11:54 ` [PATCH datacenter-manager 1/2] server: subscription: always get fresh subscription info on update Shannon Sterz
2026-06-03 11:54 ` [PATCH datacenter-manager 2/2] server: cache: short-circuit on special max age value 0 Shannon Sterz
0 siblings, 2 replies; 3+ messages in thread
From: Shannon Sterz @ 2026-06-03 11:54 UTC (permalink / raw)
To: pdm-devel
and slightly improve the caching mechanism. the second patch here is
optional, it's just something i noticed while debugging.
Shannon Sterz (2):
server: subscription: always get fresh subscription info on update
server: cache: short-circuit on special max age value 0
server/src/api/nodes/subscription.rs | 25 ++++++++++++++++++++++++-
server/src/namespaced_cache.rs | 4 ++++
2 files changed, 28 insertions(+), 1 deletion(-)
--
2.47.3
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH datacenter-manager 1/2] server: subscription: always get fresh subscription info on update
2026-06-03 11:54 [PATCH datacenter-manager 0/2] fix an issue with cached subscription info Shannon Sterz
@ 2026-06-03 11:54 ` Shannon Sterz
2026-06-03 11:54 ` [PATCH datacenter-manager 2/2] server: cache: short-circuit on special max age value 0 Shannon Sterz
1 sibling, 0 replies; 3+ messages in thread
From: Shannon Sterz @ 2026-06-03 11:54 UTC (permalink / raw)
To: pdm-devel
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 <s.sterz@proxmox.com>
---
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH datacenter-manager 2/2] server: cache: short-circuit on special max age value 0
2026-06-03 11:54 [PATCH datacenter-manager 0/2] fix an issue with cached subscription info Shannon Sterz
2026-06-03 11:54 ` [PATCH datacenter-manager 1/2] server: subscription: always get fresh subscription info on update Shannon Sterz
@ 2026-06-03 11:54 ` Shannon Sterz
1 sibling, 0 replies; 3+ messages in thread
From: Shannon Sterz @ 2026-06-03 11:54 UTC (permalink / raw)
To: pdm-devel
a max age of 0 means that the cached information is always considered
outdated. instead of reading from the cache first and then checking
the max age parameter, simply return early.
Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
Notes:
note, currently the cache only reads from the tmpfs /run. so the
speed-up is likely minimal for now. however, once we persist the cache
further this should help a bit.
server/src/namespaced_cache.rs | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/server/src/namespaced_cache.rs b/server/src/namespaced_cache.rs
index 2f96df41..ccdec92f 100644
--- a/server/src/namespaced_cache.rs
+++ b/server/src/namespaced_cache.rs
@@ -554,6 +554,10 @@ fn get_impl<T: Serialize + DeserializeOwned>(
// Namespace should already be verified at this point, no point in checking it again.
ensure_valid_key(key)?;
+ if max_age == Some(0) {
+ return Ok(None);
+ }
+
let path = get_path(base, namespace, key);
Ok(get_from_path(&path, max_age)?.map(|a| a.value))
--
2.47.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-06-03 11:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-03 11:54 [PATCH datacenter-manager 0/2] fix an issue with cached subscription info Shannon Sterz
2026-06-03 11:54 ` [PATCH datacenter-manager 1/2] server: subscription: always get fresh subscription info on update Shannon Sterz
2026-06-03 11:54 ` [PATCH datacenter-manager 2/2] server: cache: short-circuit on special max age value 0 Shannon Sterz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox