public inbox for pdm-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Stefan Hanreich <s.hanreich@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [pdm-devel] [PATCH proxmox-datacenter-manager v2 1/1] tree-wide: handle new unknown enum variants
Date: Thu, 13 Nov 2025 16:09:30 +0100	[thread overview]
Message-ID: <20251113150934.611263-7-s.hanreich@proxmox.com> (raw)
In-Reply-To: <20251113150934.611263-1-s.hanreich@proxmox.com>

pve-api-types now generates a fallback enum variant in order to handle
encountering unknown values for enums more gracefully. Fix all
occurrences of enums that have changed that lead to compiler errors.

In the case of migrations an error is thrown, since it is impossible
to tell if it is okay to proceed migrating a guest with an unknown
state. In other cases simply log / print the unknown value.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
---
 server/src/metric_collection/rrd_task.rs | 4 ++++
 ui/src/pve/utils.rs                      | 1 +
 ui/src/widget/migrate_window.rs          | 6 ++++++
 3 files changed, 11 insertions(+)

diff --git a/server/src/metric_collection/rrd_task.rs b/server/src/metric_collection/rrd_task.rs
index 507d6b2..f48968b 100644
--- a/server/src/metric_collection/rrd_task.rs
+++ b/server/src/metric_collection/rrd_task.rs
@@ -140,6 +140,10 @@ fn store_metric_pve(cache: &RrdCache, remote_name: &str, data_point: &ClusterMet
         ClusterMetricsDataType::Gauge => DataSourceType::Gauge,
         ClusterMetricsDataType::Counter => DataSourceType::Counter,
         ClusterMetricsDataType::Derive => DataSourceType::Derive,
+        ClusterMetricsDataType::UnknownEnumValue(value) => {
+            log::warn!("encountered unknown metric type: {value}");
+            return;
+        }
     };
 
     cache.update_value(
diff --git a/ui/src/pve/utils.rs b/ui/src/pve/utils.rs
index 5923855..ef536da 100644
--- a/ui/src/pve/utils.rs
+++ b/ui/src/pve/utils.rs
@@ -289,5 +289,6 @@ pub(crate) fn render_content_type(ty: &StorageContent) -> String {
         StorageContent::Snippets => tr!("Snippets"),
         StorageContent::Vztmpl => tr!("Container template"),
         StorageContent::None => tr!("None"),
+        StorageContent::UnknownEnumValue(value) => tr!("unknown content type ({0})", value),
     }
 }
diff --git a/ui/src/widget/migrate_window.rs b/ui/src/widget/migrate_window.rs
index cb12a15..5fe7278 100644
--- a/ui/src/widget/migrate_window.rs
+++ b/ui/src/widget/migrate_window.rs
@@ -122,6 +122,9 @@ impl PdmMigrateWindow {
                 match status.status {
                     pdm_client::types::IsRunning::Running => tr!("Online"),
                     pdm_client::types::IsRunning::Stopped => tr!("Offline"),
+                    pdm_client::types::IsRunning::UnknownEnumValue(value) => {
+                        bail!("encountered unknown guest status: {value}")
+                    }
                 }
             }
             crate::pve::GuestType::Lxc => {
@@ -131,6 +134,9 @@ impl PdmMigrateWindow {
                 match status.status {
                     pdm_client::types::IsRunning::Running => tr!("Restart"),
                     pdm_client::types::IsRunning::Stopped => tr!("Offline"),
+                    pdm_client::types::IsRunning::UnknownEnumValue(value) => {
+                        bail!("encountered unknown guest status: {value}")
+                    }
                 }
             }
         };
-- 
2.47.3


_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel


  parent reply	other threads:[~2025-11-13 15:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-13 15:09 [pdm-devel] [RFC proxmox{, -yew-comp, -datacenter-manager}/yew-mobile-gui v2 0/7] Add fallback variant to enum properties in Proxmox VE Rust API types Stefan Hanreich
2025-11-13 15:09 ` [pdm-devel] [PATCH proxmox v2 1/4] pve-api-types: add FixedString type Stefan Hanreich
2025-11-13 15:09 ` [pdm-devel] [PATCH proxmox v2 2/4] pve-api-types: generate fallback variant for enums Stefan Hanreich
2025-11-13 15:09 ` [pdm-devel] [PATCH proxmox v2 3/4] pve-api-types: regenerate Stefan Hanreich
2025-11-13 15:09 ` [pdm-devel] [PATCH proxmox v2 4/4] pve-api-types: sdn: handle fallback variant Stefan Hanreich
2025-11-13 15:09 ` [pdm-devel] [PATCH proxmox-yew-comp v2 1/1] pve: qemu: handle fallback enum variants Stefan Hanreich
2025-11-13 15:09 ` Stefan Hanreich [this message]
2025-11-13 15:09 ` [pdm-devel] [PATCH pve-yew-mobile-gui v2 1/1] tree-wide: handle fallback enum values Stefan Hanreich
2025-11-13 20:33 ` [pdm-devel] [RFC proxmox{, -yew-comp, -datacenter-manager}/yew-mobile-gui v2 0/7] Add fallback variant to enum properties in Proxmox VE Rust API types Thomas Lamprecht
2025-11-13 21:28 ` [pdm-devel] applied-series: " Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251113150934.611263-7-s.hanreich@proxmox.com \
    --to=s.hanreich@proxmox.com \
    --cc=pdm-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal