* [PATCH datacenter-manager] server: location cache: also update cache if a location was removed
@ 2026-05-27 15:21 Shannon Sterz
2026-05-27 16:01 ` applied: " Thomas Lamprecht
0 siblings, 1 reply; 2+ messages in thread
From: Shannon Sterz @ 2026-05-27 15:21 UTC (permalink / raw)
To: pdm-devel
this removes all locations from the cache if the remote has no
location anymore. otherwise clients may be served inconsitent data
depending on how the max age property is set. showing no location when
max-age is provided with a low value, but the cached location if it
isn't.
note that removing it would leave us in a race with newer writers as
the `set_if_newer_with_timestamp` has no equivalent for remove. so set
`None` in the cache instead for those cases.
also this only affected removing the last (or only) location of a
remote. if the location of a single node in a cluster with other
locations was removed, that worked, because the entry would simply be
dropped in the cached hashmap.
Reported-by: Christoph Heiss <c.heiss@proxmox.com>
Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
server/src/location_cache.rs | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/server/src/location_cache.rs b/server/src/location_cache.rs
index bf73f36..9fe514b 100644
--- a/server/src/location_cache.rs
+++ b/server/src/location_cache.rs
@@ -39,20 +39,17 @@ pub async fn get_location_info_for_remote(
get_cached_location_info(&remote.id, u64::MAX).await?
}
};
- let info = match location_info {
- Some(info) => info,
- None => return Ok(None),
- };
+
let now = proxmox_time::epoch_i64();
if let Some(existing_state) =
- update_cached_location_info(&remote.id, info.clone(), now).await?
+ update_cached_location_info(&remote.id, location_info.clone(), now).await?
{
// Somebody else updated the cache while we performed the API request,
// return the more recent data instead of the data we just fetched.
return Ok(Some(existing_state));
}
- Ok(Some(info))
+ Ok(location_info)
}
}
@@ -76,14 +73,15 @@ async fn get_cached_location_info(
async fn update_cached_location_info(
remote: &str,
- info: CachedLocationInfo,
+ info: Option<CachedLocationInfo>,
now: i64,
) -> Result<Option<CachedLocationInfo>, Error> {
let cache = api_cache::write_remote(remote).await?;
Ok(cache
.set_if_newer_with_timestamp(LOCATION_STATE_CACHE_KEY, info, now)
- .await?)
+ .await?
+ .flatten())
}
/// Parse a PVE location property string (from the datacenter or a node config) into our [Location].
--
2.47.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* applied: [PATCH datacenter-manager] server: location cache: also update cache if a location was removed
2026-05-27 15:21 [PATCH datacenter-manager] server: location cache: also update cache if a location was removed Shannon Sterz
@ 2026-05-27 16:01 ` Thomas Lamprecht
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2026-05-27 16:01 UTC (permalink / raw)
To: pdm-devel, Shannon Sterz
On Wed, 27 May 2026 17:21:06 +0200, Shannon Sterz wrote:
> this removes all locations from the cache if the remote has no
> location anymore. otherwise clients may be served inconsitent data
> depending on how the max age property is set. showing no location when
> max-age is provided with a low value, but the cached location if it
> isn't.
>
> note that removing it would leave us in a race with newer writers as
> the `set_if_newer_with_timestamp` has no equivalent for remove. so set
> `None` in the cache instead for those cases.
>
> [...]
Applied, thanks!
[1/1] server: location cache: also update cache if a location was removed
commit: 50b8abaecbcfebcfc68e39af3fba6c2b089e4d94
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-05-27 16:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-27 15:21 [PATCH datacenter-manager] server: location cache: also update cache if a location was removed Shannon Sterz
2026-05-27 16:01 ` applied: " Thomas Lamprecht
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox