[pdm-devel] [PATCH datacenter-manager v3 15/19] server: resources: extend datastore status counters by multiple states
Christian Ebner
c.ebner at proxmox.com
Tue Oct 21 13:11:25 CEST 2025
Account for some more states which will be shown in the datastore
status panel of the dashboard.
Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
Changes since version 2:
- not present in previous version
lib/pdm-api-types/src/resource.rs | 3 +++
server/src/api/resources.rs | 25 +++++++++++++++++++++++--
2 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/lib/pdm-api-types/src/resource.rs b/lib/pdm-api-types/src/resource.rs
index b779825..cc467d5 100644
--- a/lib/pdm-api-types/src/resource.rs
+++ b/lib/pdm-api-types/src/resource.rs
@@ -7,6 +7,9 @@ use proxmox_schema::{api, ApiStringFormat, ApiType, EnumEntry, OneOfSchema, Sche
use super::remotes::{RemoteType, REMOTE_ID_SCHEMA};
+/// High PBS datastore usage threshold
+pub const PBS_DATASTORE_HIGH_USAGE_THRESHOLD: f64 = 0.75;
+
#[api(
"id-property": "id",
"id-schema": {
diff --git a/server/src/api/resources.rs b/server/src/api/resources.rs
index 793abfc..3b629d1 100644
--- a/server/src/api/resources.rs
+++ b/server/src/api/resources.rs
@@ -13,7 +13,7 @@ use pdm_api_types::remotes::{Remote, RemoteType};
use pdm_api_types::resource::{
FailedRemote, PbsDatastoreResource, PbsNodeResource, PveLxcResource, PveNodeResource,
PveQemuResource, PveSdnResource, PveStorageResource, RemoteResources, Resource, ResourceType,
- ResourcesStatus, SdnStatus, SdnZoneResource, TopEntities,
+ ResourcesStatus, SdnStatus, SdnZoneResource, TopEntities, PBS_DATASTORE_HIGH_USAGE_THRESHOLD,
};
use pdm_api_types::subscription::{
NodeSubscriptionInfo, RemoteSubscriptionState, RemoteSubscriptions, SubscriptionLevel,
@@ -450,7 +450,28 @@ pub async fn get_status(
}
// FIXME better status for pbs/datastores
Resource::PbsNode(_) => counts.pbs_nodes.online += 1,
- Resource::PbsDatastore(_) => counts.pbs_datastores.available += 1,
+ Resource::PbsDatastore(r) => {
+ if r.maintenance.is_none() {
+ counts.pbs_datastores.online += 1;
+ } else {
+ *counts.pbs_datastores.in_maintenance.get_or_insert_default() += 1;
+ }
+ if r.usage > PBS_DATASTORE_HIGH_USAGE_THRESHOLD {
+ *counts.pbs_datastores.high_usage.get_or_insert_default() += 1;
+ }
+ if r.backing_device.is_some() {
+ *counts.pbs_datastores.removable.get_or_insert_default() += 1;
+ }
+ match r.backend_type.as_deref() {
+ Some("s3") => {
+ *counts.pbs_datastores.s3_backend.get_or_insert_default() += 1;
+ }
+ Some("unknown") => {
+ *counts.pbs_datastores.unknown.get_or_insert_default() += 1;
+ }
+ _ => (),
+ }
+ }
}
}
}
--
2.47.3
More information about the pdm-devel
mailing list