[pbs-devel] [PATCH proxmox-datacenter-manager 1/1] tree-wide: add enum fallback variants for pbs api types
Stefan Hanreich
s.hanreich at proxmox.com
Thu Nov 20 15:50:14 CET 2025
pbs-api-types added fallback variants to all enums that are part of
the REST API. Fix all occurences of the enums that got new fallback
variants in PDM by handling them properly. In the backend, unknown
values are logged, while in the frontend they're simply rendered with
a special icon / font color.
Signed-off-by: Stefan Hanreich <s.hanreich at proxmox.com>
---
Cargo.toml | 2 +-
server/src/metric_collection/rrd_task.rs | 4 ++++
ui/Cargo.toml | 2 +-
ui/src/pbs/snapshot_list.rs | 7 +++++++
4 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/Cargo.toml b/Cargo.toml
index 6ae8f69..c44b181 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -83,7 +83,7 @@ proxmox-node-status = "1"
# API types for PVE (and later PMG?)
pve-api-types = "8.1.0"
# API types for PBS
-pbs-api-types = "1.0.5"
+pbs-api-types = { version = "1.0.5", features = [ "enum-fallback" ] }
# PDM workspace
server = { path = "server" }
diff --git a/server/src/metric_collection/rrd_task.rs b/server/src/metric_collection/rrd_task.rs
index f48968b..48b6de9 100644
--- a/server/src/metric_collection/rrd_task.rs
+++ b/server/src/metric_collection/rrd_task.rs
@@ -165,6 +165,10 @@ fn store_metric_pbs(cache: &RrdCache, remote_name: &str, data_point: &MetricData
MetricDataType::Gauge => DataSourceType::Gauge,
MetricDataType::Counter => DataSourceType::Counter,
MetricDataType::Derive => DataSourceType::Derive,
+ MetricDataType::UnknownEnumValue(s) => {
+ log::warn!("unknown metric data type: {s}");
+ return;
+ }
};
cache.update_value(
diff --git a/ui/Cargo.toml b/ui/Cargo.toml
index d9acbe9..ef032ea 100644
--- a/ui/Cargo.toml
+++ b/ui/Cargo.toml
@@ -40,7 +40,7 @@ proxmox-login = "1"
proxmox-schema = "5"
proxmox-rrd-api-types = "1"
proxmox-node-status = "1"
-pbs-api-types = "1.0.3"
+pbs-api-types = { version = "1.0.3", features = [ "enum-fallback" ] }
pdm-api-types = { version = "0.9", path = "../lib/pdm-api-types" }
pdm-client = { version = "0.9", path = "../lib/pdm-client" }
diff --git a/ui/src/pbs/snapshot_list.rs b/ui/src/pbs/snapshot_list.rs
index b82ffd5..564288b 100644
--- a/ui/src/pbs/snapshot_list.rs
+++ b/ui/src/pbs/snapshot_list.rs
@@ -114,6 +114,7 @@ impl SnapshotListComp {
BackupType::Vm => "desktop",
BackupType::Ct => "cube",
BackupType::Host => "building",
+ BackupType::UnknownEnumValue(_) => "question-circle-o",
},
group.to_string(),
),
@@ -234,6 +235,7 @@ impl Component for SnapshotListComp {
match state.state {
VerifyState::Ok => verify_state.ok += 1,
VerifyState::Failed => verify_state.failed += 1,
+ VerifyState::UnknownEnumValue(_) => {}
}
let age_days = (now - state.upid.starttime) / (30 * 24 * 60 * 60);
@@ -436,6 +438,11 @@ fn render_verification(entry: &SnapshotTreeEntry) -> Html {
let (text, icon_class, class) = match state.state {
VerifyState::Ok => (tr!("Ok"), "check", FontColor::Success),
VerifyState::Failed => (tr!("Failed"), "times", FontColor::Warning),
+ VerifyState::UnknownEnumValue(s) => (
+ tr!("Unknown ({0})", s),
+ "question-circle-o",
+ FontColor::Error,
+ ),
};
let icon = Fa::new(icon_class).class(class).padding_end(2);
Tooltip::new(html! {<>{icon}<span>{text}</span></>})
--
2.47.3
More information about the pbs-devel
mailing list