[pdm-devel] [RFC datacenter-manager 5/5] pdm-api-types: calculate upwards trending datastore usage property
Christian Ebner
c.ebner at proxmox.com
Mon Oct 27 15:25:51 CET 2025
To allow filtering of PBS datastore resources with upwards trending
storage usage. Calculate base on the current system time.
Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
lib/pdm-api-types/src/resource.rs | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/lib/pdm-api-types/src/resource.rs b/lib/pdm-api-types/src/resource.rs
index 10ea123..c7f24c2 100644
--- a/lib/pdm-api-types/src/resource.rs
+++ b/lib/pdm-api-types/src/resource.rs
@@ -1,4 +1,5 @@
use std::convert::Infallible;
+use std::time::{SystemTime, UNIX_EPOCH};
use anyhow::{bail, Error};
use serde::{Deserialize, Serialize};
@@ -122,6 +123,17 @@ impl Resource {
if r.usage > PBS_DATASTORE_CRITICAL_USAGE_THRESHOLD {
properties.push("critical-usage".to_string());
}
+ if let Some(estimated_full) = r.estimated_full_date {
+ if let Ok(now) = SystemTime::now().duration_since(UNIX_EPOCH) {
+ let threshold = now.as_secs() + PBS_DATASTORE_FILLUP_THRESHOLD;
+ if estimated_full > 0
+ && (estimated_full as u64) > now.as_secs()
+ && (estimated_full as u64) < threshold
+ {
+ properties.push("uptrendig-usage".to_string());
+ }
+ }
+ }
}
properties.join(",")
}
--
2.47.3
More information about the pdm-devel
mailing list