all lists on 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 1/1] tree-wide: handle new unknown enum variants
Date: Wed, 12 Nov 2025 10:22:09 +0100	[thread overview]
Message-ID: <20251112092225.17890-6-s.hanreich@proxmox.com> (raw)
In-Reply-To: <20251112092225.17890-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-12  9:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-12  9:22 [pdm-devel] [RFC proxmox{, -yew-comp, -datacenter-manager}/yew-mobile-gui 0/6] Add fallback variant to enum properties in Proxmox VE Rust API types Stefan Hanreich
2025-11-12  9:22 ` [pdm-devel] [PATCH proxmox 1/3] pve-api-types: add FixedString type Stefan Hanreich
2025-11-12 10:50   ` Wolfgang Bumiller
2025-11-12 16:39     ` Stefan Hanreich
2025-11-12  9:22 ` [pdm-devel] [PATCH proxmox 2/3] pve-api-types: generate fallback variant for enums Stefan Hanreich
2025-11-12  9:22 ` [pdm-devel] [PATCH proxmox 3/3] pve-api-types: regenerate Stefan Hanreich
2025-11-12  9:22 ` [pdm-devel] [PATCH proxmox-yew-comp 1/1] pve: qemu: handle fallback enum variants Stefan Hanreich
2025-11-12  9:22 ` Stefan Hanreich [this message]
2025-11-12 12:25   ` [pdm-devel] [PATCH proxmox-datacenter-manager 1/1] tree-wide: handle new unknown " Lukas Wagner
2025-11-12  9:22 ` [pdm-devel] [PATCH pve-yew-mobile-gui 1/1] tree-wide: handle fallback enum values Stefan Hanreich

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=20251112092225.17890-6-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal